Thanks Sylvain.
Is there any way to create a composite key with only one column in Cassandra 
when creating a table, or should creating a CompositeType instance with a 
single column be prohibited?


From: Sylvain Lebresne [mailto:sylv...@datastax.com]
Sent: Monday, March 30, 2015 1:57 PM
To: user@cassandra.apache.org
Subject: Re: sstable writer and creating bytebuffers

No, it's not a bug. In a composite every elements start by a 2 short indicating 
the size of the element, plus an extra byte that is used for sorting purposes. 
A little bit more details can be found in the CompositeType class javadoc if 
you're interested. It's not the most compact format there is but changing it 
would break backward compatibility anyway.

On Mon, Mar 30, 2015 at 12:38 PM, Peer, Oded 
<oded.p...@rsa.com<mailto:oded.p...@rsa.com>> wrote:
I am writing code to bulk load data into Cassandra using 
SSTableSimpleUnsortedWriter
I changed my partition key from a composite key (long, int) to a single column 
key (long).
For creating the composite key I used a CompositeType, and I kept using it 
after changing the key to a single column.
My code didn’t work until I changed the way I create the ByteBuffer not to use 
CompositeType.

The following code prints ‘false’.
Do you consider this a bug?

              long val = 123L;
              ByteBuffer direct = bytes( val );
              ByteBuffer composite = CompositeType.getInstance( 
LongType.instance ).builder().add( bytes( val ) ).build();
              System.out.println( direct.equals( composite ) );


Reply via email to