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 69DEC90DC for ; Fri, 17 Feb 2012 02:14:01 +0000 (UTC) Received: (qmail 30254 invoked by uid 500); 17 Feb 2012 02:13:59 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 30224 invoked by uid 500); 17 Feb 2012 02:13:59 -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 30216 invoked by uid 99); 17 Feb 2012 02:13:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Feb 2012 02:13:59 +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 (nike.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; Fri, 17 Feb 2012 02:13:50 +0000 Received: from c-24-7-82-252.hsd1.ca.comcast.net ([24.7.82.252]:52602 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 1RyDKB-000210-RP; Thu, 16 Feb 2012 18:13:28 -0800 Message-ID: <4F3DB7CC.7020608@syncopated.net> Date: Thu, 16 Feb 2012 18:13:32 -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 CC: aaron morton Subject: Re: problem with sliceQuery with composite column References: <4F34EA61.7030602@syncopated.net> <338942EA-B07A-4D15-9B6B-A31ADA4DE1E6@thelastpickle.com> <4F3CBB5B.3030005@syncopated.net> In-Reply-To: Content-Type: multipart/alternative; boundary="------------030302020206080600010603" X-Authenticated-User: 32415 deno@syncopated.net X-Spam-Level: X-Virus-Checked: Checked by ClamAV on apache.org 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. --------------030302020206080600010603 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 >>> >>> 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 >>> >> > --------------030302020206080600010603 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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

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




--------------030302020206080600010603--