[1/2] PHOENIX-1140 Incorrect padding for row key columns (Samarth Jain)

2014-08-04 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/3.0 ddf970a38 - e574d1ea8


http://git-wip-us.apache.org/repos/asf/phoenix/blob/e574d1ea/phoenix-core/src/test/java/org/apache/phoenix/util/ScanUtilTest.java
--
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/util/ScanUtilTest.java 
b/phoenix-core/src/test/java/org/apache/phoenix/util/ScanUtilTest.java
index 8fa5314..b1246b8 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/util/ScanUtilTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/util/ScanUtilTest.java
@@ -128,7 +128,7 @@ public class ScanUtilTest {
 PDataType.CHAR.getKeyRange(Bytes.toBytes(1), true, 
Bytes.toBytes(1), true),},{
 PDataType.CHAR.getKeyRange(Bytes.toBytes(A), true, 
Bytes.toBytes(A), true),}},
 new int[] {1,1,1},
-ByteUtil.fillKey(PDataType.VARCHAR.toBytes(a1A), 3),
+PDataType.CHAR.toBytes(a1A),
 Bound.LOWER
 ));
 // 2, Lower bound, all range keys, all inclusive.
@@ -138,7 +138,7 @@ public class ScanUtilTest {
 PDataType.CHAR.getKeyRange(Bytes.toBytes(1), true, 
Bytes.toBytes(2), true),},{
 PDataType.CHAR.getKeyRange(Bytes.toBytes(A), true, 
Bytes.toBytes(B), true),}},
 new int[] {1,1,1},
-ByteUtil.fillKey(PDataType.VARCHAR.toBytes(a1A), 3),
+PDataType.CHAR.toBytes(a1A),
 Bound.LOWER
 ));
 // 3, Lower bound, mixed single and range keys, all inclusive.
@@ -148,7 +148,7 @@ public class ScanUtilTest {
 PDataType.CHAR.getKeyRange(Bytes.toBytes(1), true, 
Bytes.toBytes(2), true),},{
 PDataType.CHAR.getKeyRange(Bytes.toBytes(A), true, 
Bytes.toBytes(A), true),}},
 new int[] {1,1,1},
-ByteUtil.fillKey(PDataType.VARCHAR.toBytes(a1A), 3),
+PDataType.CHAR.toBytes(a1A),
 Bound.LOWER
 ));
 // 4, Lower bound, all range key, all exclusive on lower bound.
@@ -158,7 +158,7 @@ public class ScanUtilTest {
 PDataType.CHAR.getKeyRange(Bytes.toBytes(1), false, 
Bytes.toBytes(2), true),},{
 PDataType.CHAR.getKeyRange(Bytes.toBytes(A), false, 
Bytes.toBytes(B), true),}},
 new int[] {1,1,1},
-ByteUtil.fillKey(PDataType.VARCHAR.toBytes(b2B), 3),
+PDataType.CHAR.toBytes(b2B),
 Bound.LOWER
 ));
 // 5, Lower bound, all range key, some exclusive.
@@ -168,7 +168,7 @@ public class ScanUtilTest {
 PDataType.CHAR.getKeyRange(Bytes.toBytes(1), true, 
Bytes.toBytes(2), true),},{
 PDataType.CHAR.getKeyRange(Bytes.toBytes(A), false, 
Bytes.toBytes(B), true),}},
 new int[] {1,1,1},
-ByteUtil.fillKey(PDataType.VARCHAR.toBytes(b1B), 3),
+PDataType.CHAR.toBytes(b1B),
 Bound.LOWER
 ));
 // 6, Lower bound, mixed single and range key, mixed inclusive and 
exclusive.
@@ -178,7 +178,7 @@ public class ScanUtilTest {
 PDataType.CHAR.getKeyRange(Bytes.toBytes(1), true, 
Bytes.toBytes(2), true),},{
 PDataType.CHAR.getKeyRange(Bytes.toBytes(A), false, 
Bytes.toBytes(B), true),}},
 new int[] {1,1,1},
-ByteUtil.fillKey(PDataType.VARCHAR.toBytes(a1B), 3),
+PDataType.CHAR.toBytes(a1B),
 Bound.LOWER
 ));
 // 7, Lower bound, unbound key in the middle, fixed length.
@@ -188,7 +188,7 @@ public class ScanUtilTest {
 KeyRange.EVERYTHING_RANGE,},{
 PDataType.CHAR.getKeyRange(Bytes.toBytes(A), false, 
Bytes.toBytes(B), true),}},
 new int[] {1,1,1},
-ByteUtil.fillKey(PDataType.VARCHAR.toBytes(a), 1),
+PDataType.CHAR.toBytes(a),
 Bound.LOWER
 ));
 // 8, Lower bound, unbound key in the middle, variable length.
@@ -197,7 +197,7 @@ public class ScanUtilTest {
 PDataType.CHAR.getKeyRange(Bytes.toBytes(a), true, 
Bytes.toBytes(a), true),},{
 KeyRange.EVERYTHING_RANGE,}},
 new int[] {1,1},
-ByteUtil.concat(PDataType.VARCHAR.toBytes(a)),
+PDataType.CHAR.toBytes(a),
 Bound.LOWER
 ));
 // 9, Lower bound, unbound key at end, variable length.
@@ -207,7 +207,7 @@ public class ScanUtilTest {
 KeyRange.EVERYTHING_RANGE,},{
 PDataType.CHAR.getKeyRange(Bytes.toBytes(A), true, 
Bytes.toBytes(B), true),}},
 new int[] {1,1,1},
-

[2/2] git commit: PHOENIX-1140 Incorrect padding for row key columns (Samarth Jain)

2014-08-04 Thread jamestaylor
PHOENIX-1140 Incorrect padding for row key columns (Samarth Jain)


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

Branch: refs/heads/3.0
Commit: e574d1ea888d8d2e29ed787b8ed8edf54905c68b
Parents: ddf970a
Author: James Taylor jtay...@salesforce.com
Authored: Mon Aug 4 11:57:50 2014 -0700
Committer: James Taylor jtay...@salesforce.com
Committed: Mon Aug 4 11:57:50 2014 -0700

--
 .../org/apache/phoenix/end2end/QueryMoreIT.java |  19 ++-
 .../org/apache/phoenix/end2end/QueryPlanIT.java |   5 +-
 .../phoenix/end2end/RowValueConstructorIT.java  | 136 +++
 .../phoenix/end2end/VariableLengthPKIT.java |  10 +-
 .../org/apache/phoenix/compile/ScanRanges.java  |  12 +-
 .../apache/phoenix/compile/WhereOptimizer.java  |  21 ++-
 .../phoenix/expression/CaseExpression.java  |   6 -
 .../phoenix/expression/InListExpression.java|  29 +---
 .../expression/function/PrefixFunction.java |  35 ++--
 .../expression/function/RTrimFunction.java  |  27 ++-
 .../expression/function/ScalarFunction.java |   9 +
 .../java/org/apache/phoenix/query/KeyRange.java |  29 
 .../org/apache/phoenix/schema/PDataType.java|  25 +++
 .../org/apache/phoenix/schema/PTableImpl.java   |   9 +-
 .../java/org/apache/phoenix/util/ByteUtil.java  |  19 ++-
 .../java/org/apache/phoenix/util/ScanUtil.java  |  16 +-
 .../phoenix/compile/QueryCompilerTest.java  |   8 +-
 .../compile/StatementHintsCompilationTest.java  |   2 +-
 .../phoenix/compile/WhereCompilerTest.java  |  10 +-
 .../phoenix/compile/WhereOptimizerTest.java | 166 +++
 .../org/apache/phoenix/util/ScanUtilTest.java   |  36 ++--
 21 files changed, 450 insertions(+), 179 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/e574d1ea/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
index 50b3d47..5173b0e 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
@@ -17,7 +17,6 @@
  */
 package org.apache.phoenix.end2end;
 
-import static org.apache.commons.lang.StringUtils.rightPad;
 import static org.junit.Assert.assertEquals;
 
 import java.sql.Connection;
@@ -95,15 +94,20 @@ public class QueryMoreIT extends BaseHBaseManagedTimeIT {
 conn.createStatement().execute(baseDataTableDDL);
 conn.close();
 
-//upsert rows in the history table.
+//upsert rows in the data table.
 MapString, ListString historyIdsPerTenant = 
createHistoryTableRows(dataTableName, tenantIds, numRowsPerTenant);
 
-//create sequence. Use the sequence to upsert select records in cursor 
table.
 String tenantId = tenantIds[0];
 String cursorQueryId = 00TcursrqueryId;
 String tenantViewName = dataTableMultiTenant ? (HISTORY_TABLE + _ 
+ tenantId) : null;
 assertEquals(numRowsPerTenant, 
upsertSelectRecordsInCursorTableForTenant(dataTableName, dataTableMultiTenant, 
tenantId, tenantViewName, cursorQueryId));
 
+Connection conn2 = DriverManager.getConnection(getUrl());
+ResultSet rs = conn2.createStatement().executeQuery(SELECT count(*) 
from  + cursorTableName);
+rs.next();
+assertEquals(numRowsPerTenant, rs.getInt(1));
+conn2.close();
+
 int startOrder = 0;
 int endOrder = 5;
 int numRecordsThatShouldBeRetrieved = 5;
@@ -132,9 +136,10 @@ public class QueryMoreIT extends BaseHBaseManagedTimeIT {
 ListString parentIds = new ArrayListString();
 for (int i = 0; i  numRowsPerTenant; i++) {
 stmt.setString(1, tenantIds[j]);
-stmt.setString(2, rightPad(parentId, 15, 'p'));
+String parentId = parentId + i;
+stmt.setString(2, parentId);
 stmt.setDate(3, new Date(100));
-String historyId = rightPad(history + i, 15, 'h'); 
+String historyId = historyId + i; 
 stmt.setString(4, historyId);
 stmt.setString(5, datatype);
 stmt.setString(6, oldval);
@@ -154,6 +159,8 @@ public class QueryMoreIT extends BaseHBaseManagedTimeIT {
 private int upsertSelectRecordsInCursorTableForTenant(String 
baseTableName, boolean dataTableMultiTenant, String tenantId, String