so i flipped the composite around to;

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


and now i'm getting what i expected the first time. i can get a range of types.

thanks,



On 2/16/2012 6:13 PM, Deno Vichas wrote:
On 2/16/2012 12:46 AM, aaron morton wrote:
 split this CF into two?
Or change the order of the column components as suggested.

as suggested - where?

are you saying if the flip the composite i'll be able to ask for a range by type? and cassandra is going to order by columns like;

ticks:1
ticks:2
ticks:3
quotes:1
quotes:2
quotes:3


thanks,
deno

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 <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





Reply via email to