Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 371EF90B4 for ; Thu, 16 Feb 2012 08:16:53 +0000 (UTC) Received: (qmail 92434 invoked by uid 500); 16 Feb 2012 08:16:51 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 92406 invoked by uid 500); 16 Feb 2012 08:16:50 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 92398 invoked by uid 99); 16 Feb 2012 08:16:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2012 08:16:50 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [64.13.192.22] (HELO cl13.gs01.gridserver.com) (64.13.192.22) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2012 08:16:43 +0000 Received: from c-24-7-82-252.hsd1.ca.comcast.net ([24.7.82.252]:51894 helo=[192.168.26.116]) by cl13.gs01.gridserver.com with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.69) (envelope-from ) id 1RxwVq-000120-0T for user@cassandra.apache.org; Thu, 16 Feb 2012 00:16:22 -0800 Message-ID: <4F3CBB5B.3030005@syncopated.net> Date: Thu, 16 Feb 2012 00:16:27 -0800 From: Deno Vichas User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.1) Gecko/20120208 Thunderbird/10.0.1 MIME-Version: 1.0 To: user@cassandra.apache.org Subject: Re: problem with sliceQuery with composite column References: <4F34EA61.7030602@syncopated.net> <338942EA-B07A-4D15-9B6B-A31ADA4DE1E6@thelastpickle.com> In-Reply-To: <338942EA-B07A-4D15-9B6B-A31ADA4DE1E6@thelastpickle.com> Content-Type: multipart/alternative; boundary="------------040003000500070803060305" X-Authenticated-User: 32415 deno@syncopated.net X-Spam-Level: X-Old-Spam-Status: "score=-0.4 tests=ALL_TRUSTED, HTML_MESSAGE version=3.1.7" This is a multi-part message in MIME format. --------------040003000500070803060305 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 sliceQuery = >> HFactory.createSliceQuery(_keyspace, >> _stringSerializer, new CompositeSerializer(), _stringSerializer); >> sliceQuery.setColumnFamily(CF_STOCK_HISTORY).setKey(symbol); >> sliceQuery.setRange(start, end, false, 10); >> >> QueryResult> result = >> sliceQuery.execute(); >> ColumnSlice cs = result.get(); >> SortedSet historyJSON = new TreeSet(); >> for ( HColumn 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 > --------------040003000500070803060305 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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

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


--------------040003000500070803060305--