incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peer, Oded" <>
Subject RE: Problem using sstableloader with SSTableSimpleUnsortedWriter and a composite key
Date Sun, 30 Jun 2013 07:13:54 GMT
Thank you Aaaron!

Your blog post helped me understand how a row with a compound key is stored and this helped
me understand how to create the sstable files.
For anyone who needs it this is how it works:

In Cassandra-cli the row looks like this:
RowKey: 5
=> (column=10:created, value=0000013f84be6288, timestamp=1372321637000000)

>From this we see that the row key is a single Long value "5", and it has one composite
column "10:created" with a timestamp value.
Thus the code should look like this:

   File directory = new File( System.getProperty( "output" ) );
   IPartitioner partitioner = new Murmur3Partitioner();
   String keyspace = "test_keyspace";
   String columnFamily = "test_table";
   List<AbstractType<?>> compositeList = new ArrayList<AbstractType<?>>();
   compositeList.add( LongType.instance );
   compositeList.add( LongType.instance );
   CompositeType compositeType = CompositeType.getInstance( compositeList );
   SSTableSimpleUnsortedWriter sstableWriter = new SSTableSimpleUnsortedWriter(
      64 );
   long timestamp = 1372321637000L;
   long nanotimestamp = timestamp * 1000;
   long k1 = 5L;
   long k2 = 10L;
   sstableWriter.newRow( bytes( k1 ) );
   sstableWriter.addColumn( compositeType.builder().add( bytes( k2 ) ).add( bytes( "created"
) ).build(), bytes( timestamp ), nanotimestamp );

View raw message