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

James Taylor commented on PHOENIX-1211:
---------------------------------------

Yep, you're right. The places where we increment the position array needs to 
take into account the slotSpan array instead of assuming the increment is 
always +1. You'd increment by slotSpan[i]+1 instead:

{code}
    private int nextPosition(int i) {
        while (i >= 0 && slots.get(i).get(position[i]).isSingleKey() && 
(position[i] = (position[i] + 1) % slots.get(i).size()) == 0) {
            i--; // TODO: use slotSpan to decrement
        }
        return i;
    }
{code}

{code}
    private int previousPosition(int i) {
        while (i >= 0 && --position[i] < 0) {
            position[i] = slots.get(i).size()-1;
            i--; // TODO: use slotSpan to decrement
        }
        return i;
    }
{code}

In navigate:
{code}
                // If we're positioned at a single key, no need to copy the 
current key and get the next key .
                // Instead, just increment to the next key and continue.
                boolean incremented = false;
                while (j >= 0 && slots.get(j).get(position[j]).isSingleKey() && 
(incremented=true) && (position[j] = (position[j] + 1) % slots.get(j).size()) 
== 0) {
                    j--; // TODO: use slotSpan to decrement
                    incremented = false;
                }
{code}

And yes, it'd be nice to have a single nextPosition() and previousPosition() 
method, but it's tough b/c we depend on some extra state sometimes. Maybe see 
if the above fixes the current issue and if so, think about this one to see 
what you can come up with?

> Use skip scan when row value constructor uses leading row key columns 
> ----------------------------------------------------------------------
>
>                 Key: PHOENIX-1211
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1211
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: James Taylor
>            Assignee: Kyle Buzsaki
>         Attachments: PHOENIX-1211-diff.patch
>
>
> We currently only use a skip scan for a row value constructor equality or in 
> list expression is fully qualified. We can fairly easily use it when only 
> some of the leading pk columns are used.
> For example:
> {code}
> WHERE (a,b) IN ((1,2),(3,4))
> {code}
> If the PK is (a,b,c), we can still use a skip scan. We need to pass through 
> the slotSpan array in this case too, to the SkipScanFilter.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to