You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2017/11/15 18:48:12 UTC

[17/37] phoenix git commit: PHOENIX-4322 DESC primary key column with variable length does not work in SkipScanFilter

PHOENIX-4322 DESC primary key column with variable length does not work in SkipScanFilter


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/3df249cf
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/3df249cf
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/3df249cf

Branch: refs/heads/4.x-HBase-1.1
Commit: 3df249cf55806dd523cd72328df8713344173e36
Parents: e319ff0
Author: maryannxue <ma...@gmail.com>
Authored: Mon Oct 30 11:49:40 2017 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Wed Nov 15 10:46:39 2017 -0800

----------------------------------------------------------------------
 .../src/it/java/org/apache/phoenix/end2end/SortOrderIT.java | 9 +++++++++
 .../src/main/java/org/apache/phoenix/util/ScanUtil.java     | 7 +++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/3df249cf/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java
index 655dbb1..58bbabb 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java
@@ -167,6 +167,15 @@ public class SortOrderIT extends ParallelStatsDisabledIT {
         runQueryTest(ddl, upsert("oid", "code"), insertedRows, new Object[][]{{"o2", 2}}, new WhereCondition("oid", "IN", "('o2')"),
             table);
     }
+
+    @Test
+    public void inDescCompositePK3() throws Exception {
+        String table = generateUniqueName();
+        String ddl = "CREATE table " + table + " (oid INTEGER NOT NULL, code VARCHAR NOT NULL constraint pk primary key (oid DESC, code DESC))";
+        Object[][] insertedRows = new Object[][]{{1, "o1"}, {2, "o2"}, {3, "o3"}};
+        runQueryTest(ddl, upsert("oid", "code"), insertedRows, new Object[][]{{2, "o2"}, {1, "o1"}},
+            new WhereCondition("(oid, code)", "IN", "((1, 'o1'), (2, 'o2'))"), table);
+    }
     
     @Test
     public void likeDescCompositePK1() throws Exception {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/3df249cf/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
index a844226..8ab4f20 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
@@ -431,8 +431,11 @@ public class ScanUtil {
             anyInclusiveUpperRangeKey |= !range.isSingleKey() && inclusiveUpper;
             // A null or empty byte array is always represented as a zero byte
             byte sepByte = SchemaUtil.getSeparatorByte(schema.rowKeyOrderOptimizable(), bytes.length == 0, field);
-            
-            if ( !isFixedWidth && ( sepByte == QueryConstants.DESC_SEPARATOR_BYTE 
+            // The result of an RVC evaluation can come with a trailing separator already, so we
+            // should avoid adding another one.
+            if ( !isFixedWidth
+                    && ( bytes.length == 0 || key[offset - 1] != sepByte )
+                    && ( sepByte == QueryConstants.DESC_SEPARATOR_BYTE
                                     || ( !exclusiveUpper 
                                          && (fieldIndex < schema.getMaxFields() || inclusiveUpper || exclusiveLower) ) ) ) {
                 key[offset++] = sepByte;