phoenix git commit: PHOENIX-2781 Support multi-tenant secondary index in Calcite-Phoenix

2016-03-31 Thread maryannxue
Repository: phoenix
Updated Branches:
  refs/heads/calcite caf1c6ed9 -> 4e32e29a5


PHOENIX-2781 Support multi-tenant secondary index in Calcite-Phoenix


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

Branch: refs/heads/calcite
Commit: 4e32e29a562ee83856e36480b17335f5f9a16ea3
Parents: caf1c6e
Author: maryannxue 
Authored: Thu Mar 31 09:31:11 2016 -0400
Committer: maryannxue 
Committed: Thu Mar 31 09:31:11 2016 -0400

--
 .../phoenix/calcite/CalciteLocalIndexIT.java | 19 ++-
 .../phoenix/calcite/rel/PhoenixTableScan.java|  6 +++---
 2 files changed, 13 insertions(+), 12 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/4e32e29a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteLocalIndexIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteLocalIndexIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteLocalIndexIT.java
index 30ec0bc..90bfc3b 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteLocalIndexIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteLocalIndexIT.java
@@ -195,11 +195,11 @@ public class CalciteLocalIndexIT extends 
BaseCalciteIndexIT {
 .explainIs("PhoenixToEnumerableConverter\n" +
"  PhoenixServerProject(ID=[$1], COL0=[$2], 
COL1=[CAST($0):INTEGER], COL2=[$3])\n" +
"PhoenixTableScan(table=[[phoenix, 
IDX_MULTITENANT_TEST_TABLE]], filter=[>(CAST($0):INTEGER, 1000)])\n")
-//.resultIs(0, new Object[][] {
-//{"0999", 1000, 1001, 1002},
-//{"1000", 1001, 1002, 1003},
-//{"1001", 1002, 1003, 1004},
-//{"1002", 1003, 1004, 1005}})
+.resultIs(0, new Object[][] {
+{"0999", 1000, 1001, 1002},
+{"1000", 1001, 1002, 1003},
+{"1001", 1002, 1003, 1004},
+{"1002", 1003, 1004, 1005}})
 .close();
 
 try {
@@ -222,10 +222,11 @@ public class CalciteLocalIndexIT extends 
BaseCalciteIndexIT {
 .explainIs("PhoenixToEnumerableConverter\n" +
"  PhoenixServerProject(ID=[$1], COL0=[$2], 
COL1=[CAST($0):INTEGER], COL2=[$3])\n" +
"PhoenixTableScan(table=[[phoenix, 
IDX_MULTITENANT_TEST_TABLE]], filter=[<=(CAST($0):INTEGER, 6)])\n")
-//.resultIs(0, new Object[][] {
-//{"0002", 3, 4, 5},
-//{"0003", 4, 5, 6},
-//{"0004", 5, 6, 7}})
+.sameResultAsPhoenixStandalone(0)
+/*.resultIs(0, new Object[][] {
+{"0002", 3, 4, 5},
+{"0003", 4, 5, 6},
+{"0004", 5, 6, 7}})*/
 .close();
 
 start(props).sql("select id, col0 from " + MULTI_TENANT_VIEW1 + " 
where col0 >= 1000")

http://git-wip-us.apache.org/repos/asf/phoenix/blob/4e32e29a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixTableScan.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixTableScan.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixTableScan.java
index c510e3b..32c7a90 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixTableScan.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixTableScan.java
@@ -255,7 +255,7 @@ public class PhoenixTableScan extends TableScan implements 
PhoenixRel {
 if (filter != null && 
!context.getScanRanges().equals(this.scanRanges)) {
 dynamicFilter = filterExpr;
 }
-projectColumnFamilies(context.getScan(), phoenixTable.getTable(), 
columnRefList);
+projectColumnFamilies(context.getScan(), 
phoenixTable.mappedColumns, columnRefList);
 if (implementor.getCurrentContext().forceProject) {
 TupleProjector tupleProjector = 
implementor.createTupleProjector();
 TupleProjector.serializeProjectorIntoScan(context.getScan(), 
tupleProjector);
@@ -275,10 +275,10 @@ public class PhoenixTableScan extends TableScan 
implements PhoenixRel {
 }
 }
 
-private void projectColumnFamilies(Scan scan, PTable table, 
ImmutableIntList columnRefList) {
+private

phoenix git commit: PHOENIX-2781 Support multi-tenant secondary index in Calcite-Phoenix; Fix some resource leak in PhoenixCalciteConnection; Fix PhoenixTableScan costing to cope with CALCITE-1165; Re

2016-03-30 Thread maryannxue
Repository: phoenix
Updated Branches:
  refs/heads/calcite 6ec421c12 -> caf1c6ed9


PHOENIX-2781 Support multi-tenant secondary index in Calcite-Phoenix; Fix some 
resource leak in PhoenixCalciteConnection; Fix PhoenixTableScan costing to cope 
with CALCITE-1165; Refine test framework and fix local index testing.


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

Branch: refs/heads/calcite
Commit: caf1c6ed94e4a26e60bbe1ddbaadaae3adebca66
Parents: 6ec421c
Author: maryannxue 
Authored: Wed Mar 30 22:37:02 2016 -0400
Committer: maryannxue 
Committed: Wed Mar 30 22:37:02 2016 -0400

--
 .../apache/phoenix/calcite/BaseCalciteIT.java   |  66 +++-
 .../phoenix/calcite/BaseCalciteIndexIT.java |  63 
 .../phoenix/calcite/CalciteGlobalIndexIT.java   | 259 
 .../apache/phoenix/calcite/CalciteIndexIT.java  | 306 ---
 .../phoenix/calcite/CalciteLocalIndexIT.java| 277 +
 .../calcite/jdbc/PhoenixCalciteFactory.java |  12 +
 .../apache/phoenix/calcite/PhoenixTable.java|   9 +-
 .../calcite/rel/PhoenixAbstractAggregate.java   |  10 +-
 .../phoenix/calcite/rel/PhoenixTableScan.java   |   3 +-
 .../rel/PhoenixToEnumerableConverter.java   |   5 +-
 10 files changed, 681 insertions(+), 329 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/caf1c6ed/phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIT.java
index 65a9c6e..607a93f 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIT.java
@@ -46,6 +46,7 @@ import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.schema.TableAlreadyExistsException;
 import org.apache.phoenix.util.PhoenixRuntime;
 import org.apache.phoenix.util.PropertiesUtil;
+import org.apache.phoenix.util.QueryUtil;
 import org.apache.phoenix.util.ReadOnlyProps;
 import org.junit.BeforeClass;
 
@@ -58,6 +59,7 @@ public class BaseCalciteIT extends BaseClientManagedTimeIT {
 Map props = getDefaultProps();
 props.put(QueryServices.RUN_UPDATE_STATS_ASYNC, 
Boolean.FALSE.toString());
 props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, 
Long.toString(1000));
+props.put(QueryServices.THREAD_POOL_SIZE_ATTRIB, 
Integer.toString(200));
 setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
 }
 
@@ -68,6 +70,20 @@ public class BaseCalciteIT extends BaseClientManagedTimeIT {
 public static Start start(Properties props) {
 return new Start(props);
 }
+
+public static Start startPhoenixStandalone(Properties props) {
+return new Start(props) {
+Connection createConnection() throws Exception {
+return DriverManager.getConnection(
+getUrl(), 
+props);
+}
+
+String getExplainPlanString() {
+return "explain";
+}
+};
+}
 
 public static class Start {
 protected final Properties props;
@@ -83,6 +99,10 @@ public class BaseCalciteIT extends BaseClientManagedTimeIT {
 + 
getUrl().substring(PhoenixRuntime.JDBC_PROTOCOL.length() + 1), 
 props);
 }
+
+String getExplainPlanString() {
+return "explain plan for";
+}
 
 public Sql sql(String sql) {
 return new Sql(this, sql);
@@ -120,12 +140,6 @@ public class BaseCalciteIT extends BaseClientManagedTimeIT 
{
 this.sql = sql;
 }
 
-public static List getResult(ResultSet resultSet) throws 
SQLException {
-final List list = Lists.newArrayList();
-populateResult(resultSet, list);
-return list;
-}
-
 private static void populateResult(ResultSet resultSet, List 
list) throws SQLException {
 final int columnCount = resultSet.getMetaData().getColumnCount();
 while (resultSet.next()) {
@@ -138,11 +152,11 @@ public class BaseCalciteIT extends 
BaseClientManagedTimeIT {
 }
 
 public Sql explainIs(String expected) throws SQLException {
-final List list = getResult("explain plan for " + sql);
-if (list.size() != 1) {
-fail("explain should return 1 row, got " + list.size());
-}