incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deno Vichas <d...@syncopated.net>
Subject problem with sliceQuery with composite column
Date Fri, 10 Feb 2012 09:58:57 GMT
all,

could somebody clue me to why the below code doesn't work.  my schema is;

create column family StockHistory
     with comparator = 'CompositeType(LongType,UTF8Type)'
     and default_validation_class = 'UTF8Type'
     and key_validation_class = 'UTF8Type';


  the time part works but i'm getting other column with the second half 
not equaling the value set.  it's like it's ignoring the string part of 
the composite.

         Composite start = new Composite();
         Composite end = new Composite();
         start.addComponent(0, 
startDate.toDateTimeAtStartOfDay().toDate().getTime(), 
Composite.ComponentEquality.EQUAL);
         end.addComponent(0, 
endDate.toDateMidnight().toDate().getTime(), 
Composite.ComponentEquality.EQUAL);

         start.addComponent(1, "ticks", Composite.ComponentEquality.EQUAL);
         end.addComponent(1, "ticks", 
Composite.ComponentEquality.GREATER_THAN_EQUAL);

         SliceQuery<String, Composite, String> sliceQuery =
                 HFactory.createSliceQuery(_keyspace, _stringSerializer, 
new CompositeSerializer(), _stringSerializer);
         sliceQuery.setColumnFamily(CF_STOCK_HISTORY).setKey(symbol);
         sliceQuery.setRange(start, end, false, 10);

         QueryResult<ColumnSlice<Composite, String>> result = 
sliceQuery.execute();
         ColumnSlice<Composite, String> cs = result.get();
         SortedSet<String> historyJSON = new TreeSet<String>();
         for ( HColumn<Composite, String> col: cs.getColumns() ) {
             System.out.println(col.getName().get(0, _longSerializer) 
+"|"+ col.getName().get(1,StringSerializer.get()));
         }


this outputs the following;

     1327035600000|ticks
     1327046400000|quote
     1327294800000|ticks
     1327305600000|quote
     1327381200000|ticks
     1327392000000|quote
     1327467600000|ticks
     1327478400000|quote
     1327554000000|ticks
     1327564800000|quote

thanks,
deno

Mime
View raw message