Repository: phoenix Updated Branches: refs/heads/calcite 57e1b485b -> 3f8185855
Remove PhoenixPostJoinProject Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/f7516b5f Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/f7516b5f Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/f7516b5f Branch: refs/heads/calcite Commit: f7516b5faf66339fa209713b58fdb6ef977d3600 Parents: 57e1b48 Author: maryannxue <wei....@intel.com> Authored: Sat Jul 11 13:41:38 2015 -0400 Committer: maryannxue <wei....@intel.com> Committed: Sat Jul 11 13:41:38 2015 -0400 ---------------------------------------------------------------------- .../org/apache/phoenix/calcite/CalciteTest.java | 68 +++++++++---------- .../calcite/rel/PhoenixPostJoinProject.java | 71 -------------------- .../calcite/rel/PhoenixServerProject.java | 5 +- .../calcite/rules/PhoenixConverterRules.java | 33 --------- .../GroupedAggregateRegionObserver.java | 3 +- .../coprocessor/HashJoinRegionScanner.java | 10 +-- .../phoenix/coprocessor/ScanRegionObserver.java | 3 +- .../UngroupedAggregateRegionObserver.java | 3 +- .../apache/phoenix/execute/TupleProjector.java | 17 +---- 9 files changed, 43 insertions(+), 170 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/f7516b5f/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java index 7a0324c..32d0558 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java @@ -327,8 +327,8 @@ public class CalciteTest extends BaseClientManagedTimeIT { @Test public void testJoin() throws Exception { start().sql("select t1.entity_id, t2.a_string, t1.organization_id from aTable t1 join aTable t2 on t1.entity_id = t2.entity_id and t1.organization_id = t2.organization_id where t1.a_string = 'a'") .explainIs("PhoenixToEnumerableConverter\n" + - " PhoenixToClientConverter\n" + - " PhoenixPostJoinProject(ENTITY_ID=[$4], A_STRING=[$2], ORGANIZATION_ID=[$3])\n" + + " PhoenixClientProject(ENTITY_ID=[$4], A_STRING=[$2], ORGANIZATION_ID=[$3])\n" + + " PhoenixToClientConverter\n" + " PhoenixServerJoin(condition=[AND(=($4, $1), =($3, $0))], joinType=[inner])\n" + " PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" + " PhoenixTableScan(table=[[phoenix, ATABLE]])\n" + @@ -344,8 +344,8 @@ public class CalciteTest extends BaseClientManagedTimeIT { start().sql("SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM " + JOIN_ITEM_TABLE_FULL_NAME + " item JOIN " + JOIN_SUPPLIER_TABLE_FULL_NAME + " supp ON item.\"supplier_id\" = supp.\"supplier_id\"") .explainIs("PhoenixToEnumerableConverter\n" + - " PhoenixToClientConverter\n" + - " PhoenixPostJoinProject(item_id=[$0], NAME=[$1], supplier_id=[$3], NAME0=[$4])\n" + + " PhoenixClientProject(item_id=[$0], NAME=[$1], supplier_id=[$3], NAME0=[$4])\n" + + " PhoenixToClientConverter\n" + " PhoenixServerJoin(condition=[=($2, $3)], joinType=[inner])\n" + " PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" + " PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" + @@ -363,8 +363,8 @@ public class CalciteTest extends BaseClientManagedTimeIT { start().sql("SELECT * FROM " + JOIN_ITEM_TABLE_FULL_NAME + " item JOIN " + JOIN_SUPPLIER_TABLE_FULL_NAME + " supp ON item.\"supplier_id\" = supp.\"supplier_id\" AND supp.name = 'S5'") .explainIs("PhoenixToEnumerableConverter\n" + - " PhoenixToClientConverter\n" + - " PhoenixPostJoinProject(item_id=[$0], NAME=[$1], PRICE=[$2], DISCOUNT1=[$3], DISCOUNT2=[$4], supplier_id=[$5], DESCRIPTION=[$6], supplier_id0=[$7], NAME0=[$8], PHONE=[$9], ADDRESS=[$10], LOC_ID=[$11])\n" + + " PhoenixClientProject(item_id=[$0], NAME=[$1], PRICE=[$2], DISCOUNT1=[$3], DISCOUNT2=[$4], supplier_id=[$5], DESCRIPTION=[$6], supplier_id0=[$7], NAME0=[$8], PHONE=[$9], ADDRESS=[$10], LOC_ID=[$11])\n" + + " PhoenixToClientConverter\n" + " PhoenixServerJoin(condition=[=($5, $7)], joinType=[inner])\n" + " PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" + " PhoenixToClientConverter\n" + @@ -377,8 +377,8 @@ public class CalciteTest extends BaseClientManagedTimeIT { start().sql("SELECT \"order_id\", i.name, i.price, discount2, quantity FROM " + JOIN_ORDER_TABLE_FULL_NAME + " o INNER JOIN " + JOIN_ITEM_TABLE_FULL_NAME + " i ON o.\"item_id\" = i.\"item_id\" AND o.price = (i.price * (100 - discount2)) / 100.0 WHERE quantity < 5000") .explainIs("PhoenixToEnumerableConverter\n" + - " PhoenixToClientConverter\n" + - " PhoenixPostJoinProject(order_id=[$5], NAME=[$1], PRICE=[$2], DISCOUNT2=[$3], QUANTITY=[$7])\n" + + " PhoenixClientProject(order_id=[$5], NAME=[$1], PRICE=[$2], DISCOUNT2=[$3], QUANTITY=[$7])\n" + + " PhoenixToClientConverter\n" + " PhoenixServerJoin(condition=[AND(=($6, $0), =($8, $4))], joinType=[inner])\n" + " PhoenixServerProject(item_id=[$0], NAME=[$1], PRICE=[$2], DISCOUNT2=[$4], $f7=[/(*($2, -(100, $4)), 100.0)])\n" + " PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" + @@ -393,8 +393,8 @@ public class CalciteTest extends BaseClientManagedTimeIT { @Test public void testRightOuterJoin() throws Exception { start().sql("SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM " + JOIN_ITEM_TABLE_FULL_NAME + " item RIGHT OUTER JOIN " + JOIN_SUPPLIER_TABLE_FULL_NAME + " supp ON item.\"supplier_id\" = supp.\"supplier_id\"") .explainIs("PhoenixToEnumerableConverter\n" + - " PhoenixToClientConverter\n" + - " PhoenixPostJoinProject(item_id=[$2], NAME=[$3], supplier_id=[$0], NAME0=[$1])\n" + + " PhoenixClientProject(item_id=[$2], NAME=[$3], supplier_id=[$0], NAME0=[$1])\n" + + " PhoenixToClientConverter\n" + " PhoenixServerJoin(condition=[=($4, $0)], joinType=[left])\n" + " PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" + " PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n" + @@ -464,8 +464,8 @@ public class CalciteTest extends BaseClientManagedTimeIT { // Server-join with LHS sorted on order-by fields start().sql("SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM " + JOIN_ITEM_TABLE_FULL_NAME + " item JOIN " + JOIN_SUPPLIER_TABLE_FULL_NAME + " supp ON item.\"supplier_id\" = supp.\"supplier_id\" order by supp.\"supplier_id\"") .explainIs("PhoenixToEnumerableConverter\n" + - " PhoenixToClientConverter\n" + - " PhoenixPostJoinProject(item_id=[$2], NAME=[$3], supplier_id=[$0], NAME0=[$1])\n" + + " PhoenixClientProject(item_id=[$2], NAME=[$3], supplier_id=[$0], NAME0=[$1])\n" + + " PhoenixToClientConverter\n" + " PhoenixServerJoin(condition=[=($4, $0)], joinType=[inner])\n" + " PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" + " PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n" + @@ -491,12 +491,12 @@ public class CalciteTest extends BaseClientManagedTimeIT { @Test public void testMultiJoin() throws Exception { start().sql("select t1.entity_id, t2.a_string, t3.organization_id from aTable t1 join aTable t2 on t1.entity_id = t2.entity_id and t1.organization_id = t2.organization_id join atable t3 on t1.entity_id = t3.entity_id and t1.organization_id = t3.organization_id where t1.a_string = 'a'") .explainIs("PhoenixToEnumerableConverter\n" + - " PhoenixToClientConverter\n" + - " PhoenixPostJoinProject(ENTITY_ID=[$19], A_STRING=[$38], ORGANIZATION_ID=[$0])\n" + + " PhoenixClientProject(ENTITY_ID=[$19], A_STRING=[$38], ORGANIZATION_ID=[$0])\n" + + " PhoenixToClientConverter\n" + " PhoenixServerJoin(condition=[AND(=($19, $1), =($18, $0))], joinType=[inner])\n" + " PhoenixTableScan(table=[[phoenix, ATABLE]])\n" + - " PhoenixToClientConverter\n" + - " PhoenixPostJoinProject(ORGANIZATION_ID=[$18], ENTITY_ID=[$19], A_STRING=[$20], B_STRING=[$21], A_INTEGER=[$22], A_DATE=[$23], A_TIME=[$24], A_TIMESTAMP=[$25], X_DECIMAL=[$26], X_LONG=[$27], X_INTEGER=[$28], Y_INTEGER=[$29], A_BYTE=[$30], A_SHORT=[$31], A_FLOAT=[$32], A_DOUBLE=[$33], A_UNSIGNED_FLOAT=[$34], A_UNSIGNED_DOUBLE=[$35], ORGANIZATION_ID0=[$0], ENTITY_ID0=[$1], A_STRING0=[$2], B_STRING0=[$3], A_INTEGER0=[$4], A_DATE0=[$5], A_TIME0=[$6], A_TIMESTAMP0=[$7], X_DECIMAL0=[$8], X_LONG0=[$9], X_INTEGER0=[$10], Y_INTEGER0=[$11], A_BYTE0=[$12], A_SHORT0=[$13], A_FLOAT0=[$14], A_DOUBLE0=[$15], A_UNSIGNED_FLOAT0=[$16], A_UNSIGNED_DOUBLE0=[$17])\n" + + " PhoenixClientProject(ORGANIZATION_ID=[$18], ENTITY_ID=[$19], A_STRING=[$20], B_STRING=[$21], A_INTEGER=[$22], A_DATE=[$23], A_TIME=[$24], A_TIMESTAMP=[$25], X_DECIMAL=[$26], X_LONG=[$27], X_INTEGER=[$28], Y_INTEGER=[$29], A_BYTE=[$30], A_SHORT=[$31], A_FLOAT=[$32], A_DOUBLE=[$33], A_UNSIGNED_FLOAT=[$34], A_UNSIGNED_DOUBLE=[$35], ORGANIZATION_ID0=[$0], ENTITY_ID0=[$1], A_STRING0=[$2], B_STRING0=[$3], A_INTEGER0=[$4], A_DATE0=[$5], A_TIME0=[$6], A_TIMESTAMP0=[$7], X_DECIMAL0=[$8], X_LONG0=[$9], X_INTEGER0=[$10], Y_INTEGER0=[$11], A_BYTE0=[$12], A_SHORT0=[$13], A_FLOAT0=[$14], A_DOUBLE0=[$15], A_UNSIGNED_FLOAT0=[$16], A_UNSIGNED_DOUBLE0=[$17])\n" + + " PhoenixToClientConverter\n" + " PhoenixServerJoin(condition=[AND(=($19, $1), =($18, $0))], joinType=[inner])\n" + " PhoenixTableScan(table=[[phoenix, ATABLE]])\n" + " PhoenixToClientConverter\n" + @@ -510,8 +510,8 @@ public class CalciteTest extends BaseClientManagedTimeIT { start().sql("select t1.entity_id, t2.a_string, t3.organization_id from aTable t1 join aTable t2 on t1.entity_id = t2.entity_id and t1.organization_id = t2.organization_id join atable t3 on t1.entity_id = t3.entity_id and t1.organization_id = t3.organization_id") .explainIs("PhoenixToEnumerableConverter\n" + - " PhoenixToClientConverter\n" + - " PhoenixPostJoinProject(ENTITY_ID=[$19], A_STRING=[$2], ORGANIZATION_ID=[$36])\n" + + " PhoenixClientProject(ENTITY_ID=[$19], A_STRING=[$2], ORGANIZATION_ID=[$36])\n" + + " PhoenixToClientConverter\n" + " PhoenixServerJoin(condition=[AND(=($19, $1), =($18, $0))], joinType=[inner])\n" + " PhoenixTableScan(table=[[phoenix, ATABLE]])\n" + " PhoenixToClientConverter\n" + @@ -649,8 +649,8 @@ public class CalciteTest extends BaseClientManagedTimeIT { start().sql("SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM " + JOIN_ITEM_TABLE_FULL_NAME + " item JOIN " + JOIN_SUPPLIER_TABLE_FULL_NAME + " supp ON item.\"supplier_id\" = supp.\"supplier_id\" order by item.name desc") .explainIs("PhoenixToEnumerableConverter\n" + - " PhoenixServerSort(sort0=[$1], dir0=[DESC])\n" + - " PhoenixPostJoinProject(item_id=[$0], NAME=[$1], supplier_id=[$3], NAME0=[$4])\n" + + " PhoenixClientProject(item_id=[$0], NAME=[$1], supplier_id=[$3], NAME0=[$4])\n" + + " PhoenixServerSort(sort0=[$1], dir0=[DESC])\n" + " PhoenixServerJoin(condition=[=($2, $3)], joinType=[inner])\n" + " PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" + " PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" + @@ -727,9 +727,9 @@ public class CalciteTest extends BaseClientManagedTimeIT { start().sql("SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM " + JOIN_ITEM_TABLE_FULL_NAME + " item JOIN " + JOIN_SUPPLIER_TABLE_FULL_NAME + " supp ON item.\"supplier_id\" = supp.\"supplier_id\" order by item.name desc limit 3") .explainIs("PhoenixToEnumerableConverter\n" + - " PhoenixLimit(fetch=[3])\n" + - " PhoenixServerSort(sort0=[$1], dir0=[DESC])\n" + - " PhoenixPostJoinProject(item_id=[$0], NAME=[$1], supplier_id=[$3], NAME0=[$4])\n" + + " PhoenixClientProject(item_id=[$0], NAME=[$1], supplier_id=[$3], NAME0=[$4])\n" + + " PhoenixLimit(fetch=[3])\n" + + " PhoenixServerSort(sort0=[$1], dir0=[DESC])\n" + " PhoenixServerJoin(condition=[=($2, $3)], joinType=[inner])\n" + " PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" + " PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" + @@ -787,9 +787,9 @@ public class CalciteTest extends BaseClientManagedTimeIT { start().sql("SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM " + JOIN_ITEM_TABLE_FULL_NAME + " item JOIN " + JOIN_SUPPLIER_TABLE_FULL_NAME + " supp ON item.\"supplier_id\" = supp.\"supplier_id\" limit 3") .explainIs("PhoenixToEnumerableConverter\n" + - " PhoenixLimit(fetch=[3])\n" + - " PhoenixToClientConverter\n" + - " PhoenixPostJoinProject(item_id=[$0], NAME=[$1], supplier_id=[$3], NAME0=[$4])\n" + + " PhoenixClientProject(item_id=[$0], NAME=[$1], supplier_id=[$3], NAME0=[$4])\n" + + " PhoenixLimit(fetch=[3])\n" + + " PhoenixToClientConverter\n" + " PhoenixServerJoin(condition=[=($2, $3)], joinType=[inner])\n" + " PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" + " PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" + @@ -806,8 +806,8 @@ public class CalciteTest extends BaseClientManagedTimeIT { @Test public void testSubquery() { start().sql("SELECT \"order_id\", quantity FROM " + JOIN_ORDER_TABLE_FULL_NAME + " o WHERE quantity = (SELECT max(quantity) FROM " + JOIN_ORDER_TABLE_FULL_NAME + " q WHERE o.\"item_id\" = q.\"item_id\")") .explainIs("PhoenixToEnumerableConverter\n" + - " PhoenixToClientConverter\n" + - " PhoenixPostJoinProject(order_id=[$0], QUANTITY=[$4])\n" + + " PhoenixClientProject(order_id=[$0], QUANTITY=[$4])\n" + + " PhoenixToClientConverter\n" + " PhoenixServerJoin(condition=[AND(=($2, $7), =($4, $8))], joinType=[inner])\n" + " PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" + " PhoenixServerAggregate(group=[{7}], EXPR$0=[MAX($4)])\n" + @@ -828,8 +828,8 @@ public class CalciteTest extends BaseClientManagedTimeIT { + "from " + JOIN_ORDER_TABLE_FULL_NAME + " o where o.\"item_id\" = i.\"item_id\")\n" + "from " + JOIN_ITEM_TABLE_FULL_NAME + " i") .explainIs("PhoenixToEnumerableConverter\n" + - " PhoenixToClientConverter\n" + - " PhoenixPostJoinProject(item_id=[$0], NAME=[$1], EXPR$2=[$8])\n" + + " PhoenixClientProject(item_id=[$0], NAME=[$1], EXPR$2=[$8])\n" + + " PhoenixToClientConverter\n" + " PhoenixServerJoin(condition=[=($0, $7)], joinType=[left], isSingleValueRhs=[true])\n" + " PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" + " PhoenixServerAggregate(group=[{7}], SQ=[MAX($4)])\n" + @@ -852,12 +852,12 @@ public class CalciteTest extends BaseClientManagedTimeIT { + "from " + JOIN_ORDER_TABLE_FULL_NAME + " o where o.\"item_id\" = i.\"item_id\")\n" + "from " + JOIN_ITEM_TABLE_FULL_NAME + " i where \"item_id\" < '0000000006'") .explainIs("PhoenixToEnumerableConverter\n" + - " PhoenixToClientConverter\n" + - " PhoenixPostJoinProject(item_id=[$0], NAME=[$1], EXPR$2=[$8])\n" + + " PhoenixClientProject(item_id=[$0], NAME=[$1], EXPR$2=[$8])\n" + + " PhoenixToClientConverter\n" + " PhoenixServerJoin(condition=[=($0, $7)], joinType=[left], isSingleValueRhs=[true])\n" + " PhoenixTableScan(table=[[phoenix, Join, ItemTable]], filter=[<($0, '0000000006')])\n" + - " PhoenixToClientConverter\n" + - " PhoenixPostJoinProject(item_id0=[$7], SQ=[$4])\n" + + " PhoenixClientProject(item_id0=[$7], SQ=[$4])\n" + + " PhoenixToClientConverter\n" + " PhoenixServerJoin(condition=[=($2, $7)], joinType=[inner])\n" + " PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" + " PhoenixServerAggregate(group=[{0}])\n" + http://git-wip-us.apache.org/repos/asf/phoenix/blob/f7516b5f/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixPostJoinProject.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixPostJoinProject.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixPostJoinProject.java deleted file mode 100644 index a1ae22b..0000000 --- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixPostJoinProject.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.apache.phoenix.calcite.rel; - -import java.util.List; - -import org.apache.calcite.plan.RelOptCluster; -import org.apache.calcite.plan.RelOptCost; -import org.apache.calcite.plan.RelOptPlanner; -import org.apache.calcite.plan.RelTraitSet; -import org.apache.calcite.rel.RelCollation; -import org.apache.calcite.rel.RelCollationTraitDef; -import org.apache.calcite.rel.RelNode; -import org.apache.calcite.rel.metadata.RelMdCollation; -import org.apache.calcite.rel.type.RelDataType; -import org.apache.calcite.rex.RexNode; -import org.apache.phoenix.compile.QueryPlan; -import org.apache.phoenix.execute.HashJoinPlan; -import org.apache.phoenix.execute.TupleProjector; - -import com.google.common.base.Supplier; - -public class PhoenixPostJoinProject extends PhoenixAbstractProject { - - public static PhoenixPostJoinProject create(final RelNode input, - final List<? extends RexNode> projects, RelDataType rowType) { - RelOptCluster cluster = input.getCluster(); - final RelTraitSet traits = - cluster.traitSet().replace(PhoenixRel.PROJECTABLE_CONVENTION) - .replaceIfs(RelCollationTraitDef.INSTANCE, - new Supplier<List<RelCollation>>() { - public List<RelCollation> get() { - return RelMdCollation.project(input, projects); - } - }); - return new PhoenixPostJoinProject(cluster, traits, input, projects, rowType); - } - - private PhoenixPostJoinProject(RelOptCluster cluster, RelTraitSet traits, - RelNode input, List<? extends RexNode> projects, RelDataType rowType) { - super(cluster, traits, input, projects, rowType); - } - - @Override - public PhoenixPostJoinProject copy(RelTraitSet traits, RelNode input, - List<RexNode> projects, RelDataType rowType) { - return create(input, projects, rowType); - } - - @Override - public RelOptCost computeSelfCost(RelOptPlanner planner) { - if (getInput().getConvention() != PhoenixRel.PROJECTABLE_CONVENTION) - return planner.getCostFactory().makeInfiniteCost(); - - return super.computeSelfCost(planner) - .multiplyBy(SERVER_FACTOR) - .multiplyBy(PHOENIX_FACTOR); - } - - @Override - public QueryPlan implement(Implementor implementor) { - implementor.pushContext(new ImplementorContext(implementor.getCurrentContext().isRetainPKColumns(), false)); - QueryPlan plan = implementor.visitInput(0, (PhoenixRel) getInput()); - implementor.popContext(); - assert (plan instanceof HashJoinPlan - && !TupleProjector.hasProjector(plan.getContext().getScan(), false)); - - TupleProjector tupleProjector = super.project(implementor); - TupleProjector.serializeProjectorIntoScan(plan.getContext().getScan(), tupleProjector, false); - return plan; - } - -} http://git-wip-us.apache.org/repos/asf/phoenix/blob/f7516b5f/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixServerProject.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixServerProject.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixServerProject.java index da9f250..bafd78c 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixServerProject.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixServerProject.java @@ -60,11 +60,10 @@ public class PhoenixServerProject extends PhoenixAbstractProject { implementor.pushContext(new ImplementorContext(implementor.getCurrentContext().isRetainPKColumns(), false)); QueryPlan plan = implementor.visitInput(0, (PhoenixRel) getInput()); implementor.popContext(); - assert (plan instanceof ScanPlan - && !TupleProjector.hasProjector(plan.getContext().getScan(), true)); + assert (plan instanceof ScanPlan); TupleProjector tupleProjector = super.project(implementor); - TupleProjector.serializeProjectorIntoScan(plan.getContext().getScan(), tupleProjector, true); + TupleProjector.serializeProjectorIntoScan(plan.getContext().getScan(), tupleProjector); return plan; } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/f7516b5f/phoenix-core/src/main/java/org/apache/phoenix/calcite/rules/PhoenixConverterRules.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rules/PhoenixConverterRules.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/rules/PhoenixConverterRules.java index dee433c..df6a213 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rules/PhoenixConverterRules.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/rules/PhoenixConverterRules.java @@ -41,7 +41,6 @@ import org.apache.phoenix.calcite.rel.PhoenixClientProject; import org.apache.phoenix.calcite.rel.PhoenixClientSort; import org.apache.phoenix.calcite.rel.PhoenixFilter; import org.apache.phoenix.calcite.rel.PhoenixLimit; -import org.apache.phoenix.calcite.rel.PhoenixPostJoinProject; import org.apache.phoenix.calcite.rel.PhoenixRel; import org.apache.phoenix.calcite.rel.PhoenixServerAggregate; import org.apache.phoenix.calcite.rel.PhoenixServerJoin; @@ -76,7 +75,6 @@ public class PhoenixConverterRules { PhoenixFilterRule.INSTANCE, PhoenixClientProjectRule.INSTANCE, PhoenixServerProjectRule.INSTANCE, - PhoenixPostJoinProjectRule.INSTANCE, PhoenixClientAggregateRule.INSTANCE, PhoenixServerAggregateRule.SERVER, PhoenixServerAggregateRule.PROJECTABLE, @@ -331,37 +329,6 @@ public class PhoenixConverterRules { } /** - * Rule to convert a {@link org.apache.calcite.rel.logical.LogicalProject} - * to a {@link PhoenixPostJoinProject}. - */ - private static class PhoenixPostJoinProjectRule extends PhoenixConverterRule { - - private static Predicate<LogicalProject> IS_CONVERTIBLE = new Predicate<LogicalProject>() { - @Override - public boolean apply(LogicalProject input) { - return isConvertible(input); - } - }; - - private static final PhoenixPostJoinProjectRule INSTANCE = new PhoenixPostJoinProjectRule(); - - private PhoenixPostJoinProjectRule() { - super(LogicalProject.class, IS_CONVERTIBLE, Convention.NONE, - PhoenixRel.PROJECTABLE_CONVENTION, "PhoenixPostJoinProjectRule"); - } - - public RelNode convert(RelNode rel) { - final LogicalProject project = (LogicalProject) rel; - return PhoenixPostJoinProject.create( - convert( - project.getInput(), - project.getInput().getTraitSet().replace(PhoenixRel.PROJECTABLE_CONVENTION)), - project.getProjects(), - project.getRowType()); - } - } - - /** * Rule to convert a {@link org.apache.calcite.rel.logical.LogicalAggregate} * to an {@link PhoenixClientAggregate}. */ http://git-wip-us.apache.org/repos/asf/phoenix/blob/f7516b5f/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java index 989426c..d613688 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java @@ -148,9 +148,8 @@ public class GroupedAggregateRegionObserver extends BaseScannerRegionObserver { } if (j != null) { - TupleProjector postJoinProjector = TupleProjector.deserializeProjectorFromScan(scan, false); innerScanner = - new HashJoinRegionScanner(innerScanner, p, postJoinProjector, j, ScanUtil.getTenantId(scan), + new HashJoinRegionScanner(innerScanner, p, j, ScanUtil.getTenantId(scan), c.getEnvironment()); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/f7516b5f/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java index 6fdc865..1e34d96 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/HashJoinRegionScanner.java @@ -61,13 +61,11 @@ public class HashJoinRegionScanner implements RegionScanner { private List<Tuple>[] tempTuples; private ValueBitSet tempDestBitSet; private ValueBitSet[] tempSrcBitSet; - private final TupleProjector postJoinProjector; - + @SuppressWarnings("unchecked") - public HashJoinRegionScanner(RegionScanner scanner, TupleProjector projector, TupleProjector postJoinProjector, HashJoinInfo joinInfo, ImmutableBytesWritable tenantId, RegionCoprocessorEnvironment env) throws IOException { + public HashJoinRegionScanner(RegionScanner scanner, TupleProjector projector, HashJoinInfo joinInfo, ImmutableBytesWritable tenantId, RegionCoprocessorEnvironment env) throws IOException { this.scanner = scanner; this.projector = projector; - this.postJoinProjector = postJoinProjector; this.joinInfo = joinInfo; this.resultQueue = new LinkedList<Tuple>(); this.hasMore = true; @@ -229,10 +227,6 @@ public class HashJoinRegionScanner implements RegionScanner { } Tuple tuple = resultQueue.poll(); - // post-join projection - if (postJoinProjector != null) { - tuple = postJoinProjector.projectResults(tuple); - } for (int i = 0; i < tuple.size(); i++) { results.add(tuple.getValue(i)); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/f7516b5f/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ScanRegionObserver.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ScanRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ScanRegionObserver.java index 55e58f0..54c688a 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ScanRegionObserver.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ScanRegionObserver.java @@ -210,8 +210,7 @@ public class ScanRegionObserver extends BaseScannerRegionObserver { final ImmutableBytesWritable tenantId = ScanUtil.getTenantId(scan); if (j != null) { - TupleProjector postJoinProjector = TupleProjector.deserializeProjectorFromScan(scan, false); - innerScanner = new HashJoinRegionScanner(innerScanner, p, postJoinProjector, j, tenantId, c.getEnvironment()); + innerScanner = new HashJoinRegionScanner(innerScanner, p, j, tenantId, c.getEnvironment()); } final OrderedResultIterator iterator = deserializeFromScan(scan,innerScanner); http://git-wip-us.apache.org/repos/asf/phoenix/blob/f7516b5f/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java index fa78709..d5cc486 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java @@ -232,8 +232,7 @@ public class UngroupedAggregateRegionObserver extends BaseScannerRegionObserver{ } if (j != null) { - TupleProjector postJoinProjector = TupleProjector.deserializeProjectorFromScan(scan, false); - theScanner = new HashJoinRegionScanner(theScanner, p, postJoinProjector, j, ScanUtil.getTenantId(scan), c.getEnvironment()); + theScanner = new HashJoinRegionScanner(theScanner, p, j, ScanUtil.getTenantId(scan), c.getEnvironment()); } int batchSize = 0; http://git-wip-us.apache.org/repos/asf/phoenix/blob/f7516b5f/phoenix-core/src/main/java/org/apache/phoenix/execute/TupleProjector.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/TupleProjector.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/TupleProjector.java index 7ec147f..a4728e9 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/execute/TupleProjector.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/TupleProjector.java @@ -54,7 +54,6 @@ public class TupleProjector { public static final byte[] VALUE_COLUMN_QUALIFIER = new byte[0]; private static final String SCAN_PROJECTOR = "scanProjector"; - private static final String POST_JOIN_PROJECTOR = "postJoinProjector"; private final KeyValueSchema schema; private final Expression[] expressions; @@ -101,15 +100,7 @@ public class TupleProjector { this.valueSet = bitSet; } - public static boolean hasProjector(Scan scan, boolean scanProjector) { - return scan.getAttribute(scanProjector ? SCAN_PROJECTOR : POST_JOIN_PROJECTOR) != null; - } - public static void serializeProjectorIntoScan(Scan scan, TupleProjector projector) { - serializeProjectorIntoScan(scan, projector, true); - } - - public static void serializeProjectorIntoScan(Scan scan, TupleProjector projector, boolean scanProjector) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { DataOutputStream output = new DataOutputStream(stream); @@ -120,7 +111,7 @@ public class TupleProjector { WritableUtils.writeVInt(output, ExpressionType.valueOf(projector.expressions[i]).ordinal()); projector.expressions[i].write(output); } - scan.setAttribute(scanProjector ? SCAN_PROJECTOR : POST_JOIN_PROJECTOR, stream.toByteArray()); + scan.setAttribute(SCAN_PROJECTOR, stream.toByteArray()); } catch (IOException e) { throw new RuntimeException(e); } finally { @@ -134,11 +125,7 @@ public class TupleProjector { } public static TupleProjector deserializeProjectorFromScan(Scan scan) { - return deserializeProjectorFromScan(scan, true); - } - - public static TupleProjector deserializeProjectorFromScan(Scan scan, boolean scanProjector) { - byte[] proj = scan.getAttribute(scanProjector ? SCAN_PROJECTOR : POST_JOIN_PROJECTOR); + byte[] proj = scan.getAttribute(SCAN_PROJECTOR); if (proj == null) { return null; }