phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maryann...@apache.org
Subject phoenix git commit: First UPSERT test case passed (PHOENIX-2197 Support DML in Phoenix/Calcite integration)
Date Wed, 04 May 2016 01:15:37 GMT
Repository: phoenix
Updated Branches:
  refs/heads/calcite 49c53e07f -> c65d23b4a


First UPSERT test case passed (PHOENIX-2197 Support DML in Phoenix/Calcite integration)


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

Branch: refs/heads/calcite
Commit: c65d23b4a714a7b655aebdd02cff60b7c6e95ea0
Parents: 49c53e0
Author: maryannxue <maryann.xue@gmail.com>
Authored: Tue May 3 21:15:26 2016 -0400
Committer: maryannxue <maryann.xue@gmail.com>
Committed: Tue May 3 21:15:26 2016 -0400

----------------------------------------------------------------------
 .../org/apache/phoenix/calcite/CalciteDMLIT.java   |  6 +++---
 .../org/apache/phoenix/calcite/CalciteRuntime.java |  5 ++++-
 .../phoenix/calcite/rel/PhoenixTableModify.java    | 17 +++++++----------
 3 files changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/c65d23b4/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteDMLIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteDMLIT.java b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteDMLIT.java
index 72e6ca3..5588188 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteDMLIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteDMLIT.java
@@ -25,8 +25,8 @@ public class CalciteDMLIT extends BaseCalciteIT {
                        "      PhoenixValues(tuples=[[{ '1              ', '1            
 ' }]])\n")
             .executeUpdate()
             .close();
-//        start(false, 1L).sql("select organization_id, entity_id from aTable")
-//            .resultIs(new Object[][] {{"1              ", "1              "}})
-//            .close();
+        start(false, 1L).sql("select organization_id, entity_id from aTable")
+            .resultIs(new Object[][] {{"1              ", "1              "}})
+            .close();
     }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/c65d23b4/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteRuntime.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteRuntime.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteRuntime.java
index 159df6e..a3feffa 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteRuntime.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteRuntime.java
@@ -9,6 +9,7 @@ import org.apache.phoenix.compile.MutationPlan;
 import org.apache.phoenix.compile.QueryPlan;
 import org.apache.phoenix.compile.RowProjector;
 import org.apache.phoenix.compile.StatementPlan;
+import org.apache.phoenix.execute.MutationState;
 import org.apache.phoenix.iterate.ResultIterator;
 import org.apache.phoenix.schema.tuple.Tuple;
 import org.apache.phoenix.schema.types.PDataType;
@@ -178,7 +179,9 @@ public class CalciteRuntime {
                 }
 
                 try {
-                    updateCount = plan.execute().getUpdateCount();
+                    MutationState state = plan.execute();
+                    updateCount = state.getUpdateCount();
+                    state.commit();
                 } catch (SQLException e) {
                     throw new RuntimeException(e);
                 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/c65d23b4/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixTableModify.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixTableModify.java
b/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixTableModify.java
index 23262cf..6292070 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixTableModify.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/rel/PhoenixTableModify.java
@@ -15,7 +15,6 @@ import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.core.TableModify;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.phoenix.calcite.PhoenixTable;
-import org.apache.phoenix.calcite.TableMapping;
 import org.apache.phoenix.compile.ExplainPlan;
 import org.apache.phoenix.compile.MutationPlan;
 import org.apache.phoenix.compile.QueryPlan;
@@ -31,7 +30,6 @@ import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
 import org.apache.phoenix.iterate.ResultIterator;
 import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.jdbc.PhoenixResultSet;
-import org.apache.phoenix.jdbc.PhoenixStatement;
 import org.apache.phoenix.query.ConnectionQueryServices;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.query.QueryServicesOptions;
@@ -75,9 +73,10 @@ public class PhoenixTableModify extends TableModify implements PhoenixRel
{
         
         final QueryPlan queryPlan = implementor.visitInput(0, (PhoenixQueryRel) input);
         final RowProjector projector = implementor.getTableMapping().createRowProjector();
-        final TableMapping tableMapping = getTable().unwrap(PhoenixTable.class).tableMapping;
-        final TableRef targetTableRef = tableMapping.getTableRef();
-        final List<PColumn> mappedColumns = tableMapping.getMappedColumns();
+        final PhoenixTable targetTable = getTable().unwrap(PhoenixTable.class);
+        final PhoenixConnection connection = targetTable.pc;
+        final TableRef targetTableRef = targetTable.tableMapping.getTableRef();
+        final List<PColumn> mappedColumns = targetTable.tableMapping.getMappedColumns();
         final int[] columnIndexes = new int[mappedColumns.size()];
         final int[] pkSlotIndexes = new int[mappedColumns.size()];
         for (int i = 0; i < columnIndexes.length; i++) {
@@ -122,8 +121,6 @@ public class PhoenixTableModify extends TableModify implements PhoenixRel
{
                 ResultIterator iterator = queryPlan.iterator();
                 // simplest version, no run-on-server, no pipelined update
                 StatementContext childContext = queryPlan.getContext();
-                PhoenixStatement statement = childContext.getStatement();
-                PhoenixConnection connection = statement.getConnection();
                 ConnectionQueryServices services = connection.getQueryServices();
                 int maxSize = services.getProps().getInt(QueryServices.MAX_MUTATION_SIZE_ATTRIB,
                         QueryServicesOptions.DEFAULT_MAX_MUTATION_SIZE);
@@ -158,7 +155,7 @@ public class PhoenixTableModify extends TableModify implements PhoenixRel
{
                                     table.rowKeyOrderOptimizable());
                             values[i] = ByteUtil.copyKeyBytesIfNecessary(ptr);
                         }
-                        setValues(values, pkSlotIndexes, columnIndexes, table, mutation,
statement, useServerTimestamp);
+                        setValues(values, pkSlotIndexes, columnIndexes, table, mutation,
connection, useServerTimestamp);
                         rowCount++;
                         // Commit a batch if auto commit is true and we're at our batch size
                         if (isAutoCommit && rowCount % batchSize == 0) {
@@ -185,7 +182,7 @@ public class PhoenixTableModify extends TableModify implements PhoenixRel
{
         };
     }
     
-    private static void setValues(byte[][] values, int[] pkSlotIndex, int[] columnIndexes,
PTable table, Map<ImmutableBytesPtr,RowMutationState> mutation, PhoenixStatement statement,
boolean useServerTimestamp) {
+    private static void setValues(byte[][] values, int[] pkSlotIndex, int[] columnIndexes,
PTable table, Map<ImmutableBytesPtr,RowMutationState> mutation, PhoenixConnection connection,
boolean useServerTimestamp) {
         Map<PColumn,byte[]> columnValues = Maps.newHashMapWithExpectedSize(columnIndexes.length);
         byte[][] pkValues = new byte[table.getPKColumns().size()][];
         // If the table uses salting, the first byte is the salting byte, set to an empty
array
@@ -216,7 +213,7 @@ public class PhoenixTableModify extends TableModify implements PhoenixRel
{
         }
         ImmutableBytesPtr ptr = new ImmutableBytesPtr();
         table.newKey(ptr, pkValues);
-        mutation.put(ptr, new RowMutationState(columnValues, statement.getConnection().getStatementExecutionCounter(),
rowTsColInfo));
+        mutation.put(ptr, new RowMutationState(columnValues, connection.getStatementExecutionCounter(),
rowTsColInfo));
     }
 
 }


Mime
View raw message