I'm not sure but I think you can't add a column outside the super column because the system doesn't know how to compare them.
So U need to add columns under the super column.
In fact I've never try this so may be someone else can confirm this.
 

On Tue, Jan 26, 2010 at 11:52 PM, Patrick de Torcy <pdetorcy@gmail.com> wrote:
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