incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aaron morton <aa...@thelastpickle.com>
Subject Re: problem with sliceQuery with composite column
Date Thu, 16 Feb 2012 08:46:34 GMT
> but it still seem a bit strange coming from years and years of sql. 
Think of the composite column name as a composite key. You want to write an efficient query
that uses a seek and partial scan of the index b-tree, rather than a full scan. 
 
>  split this CF into two?
Or change the order of the column components as suggested. 

Cheers

-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 16/02/2012, at 9:16 PM, Deno Vichas wrote:

> thanks for the reply.  i understand why, but it still seem a bit strange coming from
years and years of sql.   so if i want to avoid the extra load from fetching way more than
i needed would i be best off split this CF into two?
> 
> thanks,
> deno
> 
> On 2/13/2012 10:41 AM, aaron morton wrote:
>> 
>> My understanding is you expected to see 
>> 
>> 111:ticks
>> 222:ticks
>> 333:ticks
>> 444:ticks
>> 
>> But instead you are getting 
>> 
>> 111:ticks
>> 111:quote
>> 222:ticks
>> 222:quote
>> 333:ticks
>> 333:quote
>> 444:ticks
>> 
>> If that is the case things are working as expected. 
>> 
>> The slice operation gets a column range. So if you start at 111:ticks and end at
444:ticks you are asking for all the column in between. 
>> 
>> it is not possible to filter at each level of a composite column. 
>> 
>> Hope that helps.
>>  
>> -----------------
>> Aaron Morton
>> Freelance Developer
>> @aaronmorton
>> http://www.thelastpickle.com
>> 
>> On 10/02/2012, at 10:58 PM, Deno Vichas wrote:
>> 
>>> 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