Repository: phoenix Updated Branches: refs/heads/4.0 607a11b44 -> 6e9d02c86
PHOENIX-1034 Move validate/reserve of sequences into query compile Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/6e9d02c8 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/6e9d02c8 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/6e9d02c8 Branch: refs/heads/4.0 Commit: 6e9d02c861d94c4e85474119ee89f6e4bb05fa5f Parents: 607a11b Author: James Taylor <jtay...@salesforce.com> Authored: Sun Jun 8 13:01:55 2014 -0700 Committer: James Taylor <jtay...@salesforce.com> Committed: Sun Jun 8 13:01:55 2014 -0700 ---------------------------------------------------------------------- .../phoenix/coprocessor/SequenceRegionObserver.java | 2 +- .../apache/phoenix/jdbc/PhoenixPreparedStatement.java | 4 ++-- .../java/org/apache/phoenix/jdbc/PhoenixStatement.java | 12 ++++++------ .../phoenix/query/ConnectionQueryServicesImpl.java | 2 +- .../main/java/org/apache/phoenix/schema/Sequence.java | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/6e9d02c8/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java index a21a61a..97a9a47 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java @@ -129,7 +129,7 @@ public class SequenceRegionObserver extends BaseRegionObserver { long value = PDataType.LONG.getCodec().decodeLong(cq.getValueArray(), cq.getValueOffset(), SortOrder.getDefault()); get.addColumn(cf, CellUtil.cloneQualifier(cq)); - validateOnly &= (Sequence.ValueOp.VALIDATE_SEQUENCES.ordinal() == value); + validateOnly &= (Sequence.ValueOp.VALIDATE_SEQUENCE.ordinal() == value); } } Result result = region.get(get); http://git-wip-us.apache.org/repos/asf/phoenix/blob/6e9d02c8/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java index d75eb28..7eea568 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java @@ -189,7 +189,7 @@ public class PhoenixPreparedStatement extends PhoenixStatement implements Prepar } try { // Just compile top level query without optimizing to get ResultSetMetaData - QueryPlan plan = statement.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCES); + QueryPlan plan = statement.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCE); return new PhoenixResultSetMetaData(this.getConnection(), plan.getProjector()); } finally { int lastSetBit = 0; @@ -212,7 +212,7 @@ public class PhoenixPreparedStatement extends PhoenixStatement implements Prepar } } try { - StatementPlan plan = statement.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCES); + StatementPlan plan = statement.compilePlan(this, Sequence.ValueOp.VALIDATE_SEQUENCE); return plan.getParameterMetaData(); } finally { int lastSetBit = 0; http://git-wip-us.apache.org/repos/asf/phoenix/blob/6e9d02c8/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java index 529a40a..d4c677b 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java @@ -195,7 +195,7 @@ public class PhoenixStatement implements Statement, SQLCloseable, org.apache.pho } protected QueryPlan optimizeQuery(CompilableStatement stmt) throws SQLException { - QueryPlan plan = stmt.compilePlan(this, Sequence.ValueOp.RESERVE_SEQUENCES); + QueryPlan plan = stmt.compilePlan(this, Sequence.ValueOp.RESERVE_SEQUENCE); return connection.getQueryServices().getOptimizer().optimize(this, plan); } @@ -205,7 +205,7 @@ public class PhoenixStatement implements Statement, SQLCloseable, org.apache.pho @Override public PhoenixResultSet call() throws Exception { try { - QueryPlan plan = stmt.compilePlan(PhoenixStatement.this, Sequence.ValueOp.RESERVE_SEQUENCES); + QueryPlan plan = stmt.compilePlan(PhoenixStatement.this, Sequence.ValueOp.RESERVE_SEQUENCE); plan = connection.getQueryServices().getOptimizer().optimize( PhoenixStatement.this, plan); PhoenixResultSet rs = newResultSet(plan.iterator(), plan.getProjector()); @@ -242,7 +242,7 @@ public class PhoenixStatement implements Statement, SQLCloseable, org.apache.pho // since they'd update data directly from coprocessors, and should thus operate on // the latest state try { - MutationPlan plan = stmt.compilePlan(PhoenixStatement.this, Sequence.ValueOp.RESERVE_SEQUENCES); + MutationPlan plan = stmt.compilePlan(PhoenixStatement.this, Sequence.ValueOp.RESERVE_SEQUENCE); MutationState state = plan.execute(); connection.getMutationState().join(state); if (connection.getAutoCommit()) { @@ -346,7 +346,7 @@ public class PhoenixStatement implements Statement, SQLCloseable, org.apache.pho @Override public QueryPlan compilePlan(PhoenixStatement stmt, Sequence.ValueOp seqAction) throws SQLException { CompilableStatement compilableStmt = getStatement(); - final StatementPlan plan = compilableStmt.compilePlan(stmt, Sequence.ValueOp.VALIDATE_SEQUENCES); + final StatementPlan plan = compilableStmt.compilePlan(stmt, Sequence.ValueOp.VALIDATE_SEQUENCE); List<String> planSteps = plan.getExplainPlan().getPlanSteps(); List<Tuple> tuples = Lists.newArrayListWithExpectedSize(planSteps.size()); for (String planStep : planSteps) { @@ -904,14 +904,14 @@ public class PhoenixStatement implements Statement, SQLCloseable, org.apache.pho if (stmt.getOperation().isMutation()) { throw new ExecuteQueryNotApplicableException(query); } - return stmt.compilePlan(this, Sequence.ValueOp.RESERVE_SEQUENCES); + return stmt.compilePlan(this, Sequence.ValueOp.RESERVE_SEQUENCE); } public MutationPlan compileMutation(CompilableStatement stmt, String query) throws SQLException { if (!stmt.getOperation().isMutation()) { throw new ExecuteUpdateNotApplicableException(query); } - return stmt.compilePlan(this, Sequence.ValueOp.RESERVE_SEQUENCES); + return stmt.compilePlan(this, Sequence.ValueOp.RESERVE_SEQUENCE); } public MutationPlan compileMutation(String sql) throws SQLException { http://git-wip-us.apache.org/repos/asf/phoenix/blob/6e9d02c8/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java index 2e6a919..a83a0c9 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java @@ -1719,7 +1719,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement */ @Override public void incrementSequences(List<SequenceKey> sequenceKeys, long timestamp, long[] values, SQLException[] exceptions) throws SQLException { - incrementSequenceValues(sequenceKeys, timestamp, values, exceptions, 1, Sequence.ValueOp.RESERVE_SEQUENCES); + incrementSequenceValues(sequenceKeys, timestamp, values, exceptions, 1, Sequence.ValueOp.RESERVE_SEQUENCE); } @SuppressWarnings("deprecation") http://git-wip-us.apache.org/repos/asf/phoenix/blob/6e9d02c8/phoenix-core/src/main/java/org/apache/phoenix/schema/Sequence.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/Sequence.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/Sequence.java index 41f62fe..da5d034 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/schema/Sequence.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/Sequence.java @@ -53,7 +53,7 @@ import com.google.common.collect.Lists; public class Sequence { public static final int SUCCESS = 0; - public enum ValueOp {VALIDATE_SEQUENCES, RESERVE_SEQUENCES}; + public enum ValueOp {VALIDATE_SEQUENCE, RESERVE_SEQUENCE}; public enum MetaOp {CREATE_SEQUENCE, DROP_SEQUENCE, RETURN_SEQUENCE}; // Pre-compute index of sequence key values to prevent binary search @@ -127,7 +127,7 @@ public class Sequence { throw EMPTY_SEQUENCE_CACHE_EXCEPTION; } if (value.currentValue == value.nextValue) { - if (action == ValueOp.VALIDATE_SEQUENCES) { + if (action == ValueOp.VALIDATE_SEQUENCE) { return value.currentValue; } throw EMPTY_SEQUENCE_CACHE_EXCEPTION;