You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Matthieu Nahoum <ma...@gmail.com> on 2011/07/14 18:07:57 UTC

Range query ordering with CQL JDBC

Hi,

I am trying to range-query a column family on which the keys are epochs
(similar to the output of System.currentTimeMillis() in Java).
In CQL (Cassandra 0.8.1 with JDBC driver):

SELECT * FROM columnFamily WHERE KEY > '1309205000000';

I can't get to have a result that make sense, it always returns wrong
timestamps. So I must make an error somewhere in the way I input the
querying value.
I tried in clear (like above), in hexadecimal, etc.

What is the correct way of doing this? Is it possible that my key is too
long?

Thanks,

Matthieu Nahoum

Re: Range query ordering with CQL JDBC

Posted by samal <sa...@wakya.in>.
I haven't used CQL functionality much, but thirft client

I think what I encounter is exactly this problem!
>
If you want to query over key, you can index keys to other CF, get the
column names (that is key of other CF ). and then query actual CF with keys.

switch away from the random partitioner.
>
switching away is not a good choice, RP is very good for load distribution.

Re: Range query ordering with CQL JDBC

Posted by Matthieu Nahoum <ma...@gmail.com>.
Aaron, thanks for the reply.

I think what I encounter is exactly this problem!

I'll try the suggestions, or switch away from the random partitioner.

Cordially,

Matthieu Nahoum

On Sun, Jul 17, 2011 at 5:50 PM, aaron morton <aa...@thelastpickle.com>wrote:

> You are probably seeing this http://wiki.apache.org/cassandra/FAQ#range_rp
>
> Row keys are not ordered by their key, they are ordered by the token
> created by the partitioner.
>
> If you still think there is a problem provide an example of the data your
> are seeing and what you expected to see.
>
> Cheers
>
>
> -----------------
> Aaron Morton
> Freelance Cassandra Developer
> @aaronmorton
> http://www.thelastpickle.com
>
> On 16 Jul 2011, at 06:09, Matthieu Nahoum wrote:
>
> Hi Eric,
>
> I am using the default partitioner, which is the RandomPartitioner I guess.
> The key type is String. Are Strings ordered by lexicographic rules?
>
> Thanks
>
> On Fri, Jul 15, 2011 at 12:04 PM, Eric Evans <ee...@rackspace.com> wrote:
>
>> On Thu, 2011-07-14 at 11:07 -0500, Matthieu Nahoum wrote:
>> > I am trying to range-query a column family on which the keys are
>> > epochs (similar to the output of System.currentTimeMillis() in Java).
>> > In CQL (Cassandra 0.8.1 with JDBC driver):
>> >
>> > SELECT * FROM columnFamily WHERE KEY > '1309205000000';
>> >
>> > I can't get to have a result that make sense, it always returns wrong
>> > timestamps. So I must make an error somewhere in the way I input the
>> > querying value. I tried in clear (like above), in hexadecimal, etc.
>> >
>> > What is the correct way of doing this? Is it possible that my key is
>> > too long?
>>
>> What partitioner are you using?  What is the key type?
>>
>> --
>> Eric Evans
>> eevans@rackspace.com
>>
>>
>
>
>

Re: Range query ordering with CQL JDBC

Posted by aaron morton <aa...@thelastpickle.com>.
You are probably seeing this http://wiki.apache.org/cassandra/FAQ#range_rp

Row keys are not ordered by their key, they are ordered by the token created by the partitioner.

If you still think there is a problem provide an example of the data your are seeing and what you expected to see. 

Cheers


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

On 16 Jul 2011, at 06:09, Matthieu Nahoum wrote:

> Hi Eric,
> 
> I am using the default partitioner, which is the RandomPartitioner I guess.
> The key type is String. Are Strings ordered by lexicographic rules?
> 
> Thanks 
> 
> On Fri, Jul 15, 2011 at 12:04 PM, Eric Evans <ee...@rackspace.com> wrote:
> On Thu, 2011-07-14 at 11:07 -0500, Matthieu Nahoum wrote:
> > I am trying to range-query a column family on which the keys are
> > epochs (similar to the output of System.currentTimeMillis() in Java).
> > In CQL (Cassandra 0.8.1 with JDBC driver):
> >
> > SELECT * FROM columnFamily WHERE KEY > '1309205000000';
> >
> > I can't get to have a result that make sense, it always returns wrong
> > timestamps. So I must make an error somewhere in the way I input the
> > querying value. I tried in clear (like above), in hexadecimal, etc.
> >
> > What is the correct way of doing this? Is it possible that my key is
> > too long?
> 
> What partitioner are you using?  What is the key type?
> 
> --
> Eric Evans
> eevans@rackspace.com
> 
> 
> 
> 
> -- 
> ---------------------------------------
> Engineer at NAVTEQ
> Berkeley Systems Engineer '10
> ENAC Engineer '09
> 
> 151 N. Michigan Ave.
> Appt. 3716
> Chicago, IL, 60601
> USA
> Cell: +1 (510) 423-1835
> 
> http://www.linkedin.com/in/matthieunahoum
> 


Re: Range query ordering with CQL JDBC

Posted by Matthieu Nahoum <ma...@gmail.com>.
Hi Eric,

I am using the default partitioner, which is the RandomPartitioner I guess.
The key type is String. Are Strings ordered by lexicographic rules?

Thanks

On Fri, Jul 15, 2011 at 12:04 PM, Eric Evans <ee...@rackspace.com> wrote:

> On Thu, 2011-07-14 at 11:07 -0500, Matthieu Nahoum wrote:
> > I am trying to range-query a column family on which the keys are
> > epochs (similar to the output of System.currentTimeMillis() in Java).
> > In CQL (Cassandra 0.8.1 with JDBC driver):
> >
> > SELECT * FROM columnFamily WHERE KEY > '1309205000000';
> >
> > I can't get to have a result that make sense, it always returns wrong
> > timestamps. So I must make an error somewhere in the way I input the
> > querying value. I tried in clear (like above), in hexadecimal, etc.
> >
> > What is the correct way of doing this? Is it possible that my key is
> > too long?
>
> What partitioner are you using?  What is the key type?
>
> --
> Eric Evans
> eevans@rackspace.com
>
>


-- 
---------------------------------------
Engineer at *NAVTEQ*
Berkeley Systems Engineer '10
ENAC Engineer '09

151 N. Michigan Ave.
Appt. 3716
Chicago, IL, 60601
USA
Cell: +1 (510) 423-1835

http://www.linkedin.com/in/matthieunahoum

Re: Range query ordering with CQL JDBC

Posted by Eric Evans <ee...@rackspace.com>.
On Thu, 2011-07-14 at 11:07 -0500, Matthieu Nahoum wrote:
> I am trying to range-query a column family on which the keys are
> epochs (similar to the output of System.currentTimeMillis() in Java).
> In CQL (Cassandra 0.8.1 with JDBC driver): 
> 
> SELECT * FROM columnFamily WHERE KEY > '1309205000000'; 
> 
> I can't get to have a result that make sense, it always returns wrong
> timestamps. So I must make an error somewhere in the way I input the
> querying value. I tried in clear (like above), in hexadecimal, etc. 
> 
> What is the correct way of doing this? Is it possible that my key is
> too long? 

What partitioner are you using?  What is the key type?

-- 
Eric Evans
eevans@rackspace.com