[ 
https://issues.apache.org/jira/browse/CASSANDRA-2212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12998462#comment-12998462
 ] 

Sylvain Lebresne commented on CASSANDRA-2212:
---------------------------------------------

Sure.

The problem is that we were not picking the right index slot for reverse query. 
Let's take the example from the unit test, and say your index look like this:
  [0..5][10..15][20..25]

And say you look for the slice [13..17]. When doing forward slice, we we doing 
a binary search comparing 13 (the start of the query) to the lastName part of 
the index slot, which is fine. You'll end up with the "first" slot, going from 
left to right, that may contain the start.

When doing a reverse query, we were doing the same thing, only using as a start 
column the end of the query, aka 17 in my example. However, comparing 17 with 
the lastName of each index slot, you end up selecting the last slot, which is 
wrong (the slice exit early since 17 is not in the range).

What you want to do is pick the "first" slot, but now going from right to left, 
that may contain start. So you want to find the slot where firstName > start 
and take the slot just before.

I hope I'm clear. Anyway, that's what the patch does. 

> Cannot get range slice of super columns in reversed order
> ---------------------------------------------------------
>
>                 Key: CASSANDRA-2212
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-2212
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 0.7.2
>         Environment: Fedore 11, Intel Core i5
>            Reporter: Muga Nishizawa
>            Assignee: Sylvain Lebresne
>             Fix For: 0.7.3
>
>         Attachments: 0001-Fix-IndexHelp.indexFor-for-reverse-query.patch, 
> cassandra_sample_insert.py, cassandra_sample_rangeslice.py, create_table.cli
>
>
> I cannot get range slice of super columns in reversed order.  These data are 
> stored in Cassandra in advance.  On the other hand, range slice of these data 
> in normal order can be acquired.
> You can reproduce the bug by executing attached programs.  
> - 1. Start Cassandra daemon on localhost (number of thrift port is 9160)
> - 2. Create keyspace and column family, according to "create_table.cli", 
> - 3. Execute "cassandra_sample_insert.py", storing pairs of row keys and 
> super columns
> - 4. Execute "cassandra_sample_rangeslice.py" and get range slice of stored 
> super columns
> "cassandra_sample_insert.py" and "cassandra_sample_rangeslice.py" require 
> pycassa.  
> You will need to execute 4."cassandra_sample_rangeslice.py" with following 
> options so that you get range slice of super columns in reversed order.  
>  % python cassandra_sample_rangeslice.py -r 00082 00083
> On the other hand, to get range slice in normal order, you will need to use 
> following options.  
>  % python cassandra_sample_rangeslice.py -f 00082 00083
> 00082 and 00083 are the specified key range.  Range slice can be acquired in 
> normal order but, I cannot get it in reversed order.  
> I assume that there may be a bug within the code for acquiring the index 
> block of specified range.  In fact, 00083 is included in gap between lastName 
> of index block and firstName of next index block.   

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to