cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick de Torcy <pdeto...@gmail.com>
Subject Re: how to insert a supercolumn with java ?
Date Tue, 26 Jan 2010 21:52:44 GMT
Thanks, it works ! Nothing is better than a good code sample ;-)

Another question : how to add a Column in the same Rowdata ?

I tried :

Column myColumn = new Column(("colname1").getBytes("
UTF-8"), colvalue1.getBytes("UTF-8"), timestamp);

ColumnOrSuperColumn columnOrSuperColumn = new ColumnOrSuperColumn();
columnOrSuperColumn.setColumn(myColumn);
rowData.add(columnOrSuperColumn);

but it didn't work ! Is it possible to mix columns and SC in the same
rowData?

On Mon, Jan 25, 2010 at 10:43 AM, Richard Grossman <richiesgr@gmail.com>wrote:

> Here is a code to insert SuperColumn with batch_insert
>
>     Map<String, List<ColumnOrSuperColumn>> insertDataMap = new
> HashMap<String, List<ColumnOrSuperColumn>>();
>         List<ColumnOrSuperColumn> rowData = new
> ArrayList<ColumnOrSuperColumn>();
>         List<Column> columns = new ArrayList<Column>();
>
>         long timestamp = System.currentTimeMillis();
>
>         // THESE ARE THE SUPERCOLUMN COLUMNS
>         columns.add(new Column(("colname1").getBytes("UTF-8"),
> colvalue1.getBytes("UTF-8"), timestamp));
>         columns.add(new Column(("colname2").getBytes("UTF-8"),
> colvalue2.getBytes("UTF-8"), timestamp));
>         columns.add(new Column(("colname3").getBytes("UTF-8"),
> colvalue2.getBytes("UTF-8"), timestamp));
>
>         // HERE THE SUPER COLUMN
>         SuperColumn superColumn =  new
> SuperColumn(superColumnNAME.getBytes("UTF-8"), columns);
>         ColumnOrSuperColumn columnOrSuperColumn = new
> ColumnOrSuperColumn();
>         columnOrSuperColumn.setSuper_column(superColumn);
>
>         rowData.add(columnOrSuperColumn);
>         insertDataMap.put(ColumnFamilyName, rowData);
>
>         clientCassandra.batch_insert("Keyspace1", Key, insertDataMap,
> ConsistencyLevel.QUORUM);
>
>
> On Mon, Jan 25, 2010 at 2:58 AM, Patrick de Torcy <pdetorcy@gmail.com>wrote:
>
>>
>> Despite a lot of googling, I couldn't find any example of how to create
>> and insert a super column in Cassandra with java. I think that I have to use
>> batch_insert, but it needs the class BatchMutation, which is not described
>> in the javadoc.
>> Where can I find examples of how to use the API in java ? The javadoc
>> seems completely out of date and clientExamples is very, very short !
>>
>> Thanks
>
>
>

Mime
View raw message