You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by David Turnbull <da...@broodax.net> on 2012/08/15 06:10:42 UTC

Partial composite result limit possible?

Hi, I have a CF with a composite type (LongType, IntegerType) with some data like this:

RowKey: hihi
=> (column=1000:1, value=616263)
=> (column=1000:2, value=6465)
=> (column=1000:3, value=66)
=> (column=1000:4, value=6768)
=> (column=2000:1, value=616263)
=> (column=2000:2, value=6465)
=> (column=2000:3, value=66)
=> (column=2000:4, value=6768)

I want to query from (1000,0 to 2000,2) such that I get 1000:1, 1000:2, 2000:1 and 2000:2 back.
Is this possible?

In pycassa, I can do cf.get('hihi', column_start=(1000,0), column_finish=(2000,2) but that gives me 1000:1-4 and 2000:1-2.
Specifying a limit of 2 columns for the query just applies to the total results, i.e. only 1000:1 and 1000:2.

I could specify the composite columns fully in the query, but I'm hoping to query over at least 300 columns, which seems bad.


Re: Partial composite result limit possible?

Posted by aaron morton <aa...@thelastpickle.com>.
You cannot do that in a single query. 

The order of columns in output is the order they are stored in. And the API can only return a contiguous range of columns.  

In this case I would get the larger slice and then discard columns client side. Or build a second row that has the order of the columns reversed so you can select from (0, null) to (2, null).

http://pycassa.github.com/pycassa/assorted/composite_types.html?#fetching-compositetype-data

Hope that helps. 

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

On 15/08/2012, at 4:10 PM, David Turnbull <da...@broodax.net> wrote:

> Hi, I have a CF with a composite type (LongType, IntegerType) with some data like this:
> 
> RowKey: hihi
> => (column=1000:1, value=616263)
> => (column=1000:2, value=6465)
> => (column=1000:3, value=66)
> => (column=1000:4, value=6768)
> => (column=2000:1, value=616263)
> => (column=2000:2, value=6465)
> => (column=2000:3, value=66)
> => (column=2000:4, value=6768)
> 
> I want to query from (1000,0 to 2000,2) such that I get 1000:1, 1000:2, 2000:1 and 2000:2 back.
> Is this possible?
> 
> In pycassa, I can do cf.get('hihi', column_start=(1000,0), column_finish=(2000,2) but that gives me 1000:1-4 and 2000:1-2.
> Specifying a limit of 2 columns for the query just applies to the total results, i.e. only 1000:1 and 1000:2.
> 
> I could specify the composite columns fully in the query, but I'm hoping to query over at least 300 columns, which seems bad.
>