You should be able to call CompositeType.getInstance(List<AbstractType<?>> types) to construct a CompositeType with the appropriate components. Then call CompositeType.decompose() with a list of the values for the key, that will get you a byte buffer.
Cheers ----------------- Aaron Morton Freelance Cassandra Consultant New Zealand @aaronmorton http://www.thelastpickle.com On 22/04/2013, at 11:40 AM, David McNelis <dmcne...@gmail.com> wrote: > I figured that the primary key and how to define it was the issue. > > What I don't get is how to structure my > SSTableSimpleUnsortedWriter.newRow() call to support the CQL3 style composite > primary keys. It takes only a ByteBuffer as an argument... > > I guess I'm looking for some kind of example of a newRow() through > addColumns() example of how to write an SSTable that can be imported to a > CQL3 table using the sstableloader. > > For example, should I convert both to a string, concat them with a : and then > bytebuffer that string, as if I were inserting a composite column from > cassandra-cli? > > > On Sun, Apr 21, 2013 at 3:55 PM, aaron morton <aa...@thelastpickle.com> wrote: > The key to your problem is likely the row key. > > Take a look in at the table schema / sample data in the cassandra-cli to see > how CQL uses composites also > http://thelastpickle.com/2013/01/11/primary-keys-in-cql/ > > The simple thing to do is use COMPACT STORAGE but that may not suite all use > cases http://www.datastax.com/docs/1.2/cql_cli/cql/CREATE_TABLE > > Cheers > > ----------------- > Aaron Morton > Freelance Cassandra Consultant > New Zealand > > @aaronmorton > http://www.thelastpickle.com > > On 20/04/2013, at 4:36 PM, David McNelis <dmcne...@gmail.com> wrote: > >> Was trying to do a test of writing SSTs for a CQL3 table. So I created the >> following table: >> >> CREATE TABLE test_sst_load ( >> mykey1 ascii, >> mykey2 ascii, >> value1 ascii, >> PRIMARY KEY (mykey1, mykey2) >> ) >> >> I then set up my writer like so: (moved to gist: >> https://gist.github.com/dmcnelis/5424756 ) >> >> This created my SST files ok and they imported without throwing any sorts of >> errors (had -v and --debug on) when using sstableloader. >> >> When I went to query my data in cqlsh, I got an rpc error. In my system.log >> I saw an exception: java.lang.RuntimeException: >> java.lang.IllegalArgumentException >> (also at the gist above). >> >> I had a feeling that it wouldn't work.. but I can't see a way with the >> SSTableSimpleUnsortedWriter (or in the AbstractSSTableWriter) to create an >> sstable file that is going to work with the CQL3 tables. I know its got to >> be possible, I can import SSTs with the sstableloader from one cluster to >> another, where the tables are CQL3. >> >> What am I missing here? >> >> >> >> > >