Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 c0a7b186b -> c7134afac
PHOENIX-3907 Use LATEST_TIMESTAMP when UPDATE_CACHE_FREQUENCY is not zero Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/c7134afa Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/c7134afa Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/c7134afa Branch: refs/heads/4.x-HBase-0.98 Commit: c7134afac7f9f2ab7319b4ee4b61d6341ac52173 Parents: c0a7b18 Author: Thomas <[email protected]> Authored: Tue Jun 6 16:06:36 2017 -0700 Committer: Thomas <[email protected]> Committed: Wed Jun 7 13:08:24 2017 -0700 ---------------------------------------------------------------------- .../org/apache/phoenix/compile/CreateTableCompiler.java | 2 +- .../java/org/apache/phoenix/compile/StatementContext.java | 2 +- .../main/java/org/apache/phoenix/schema/MetaDataClient.java | 2 +- .../src/main/java/org/apache/phoenix/schema/TableRef.java | 9 ++++++++- 4 files changed, 11 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/c7134afa/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateTableCompiler.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateTableCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateTableCompiler.java index b482998..6448edc 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateTableCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/CreateTableCompiler.java @@ -165,7 +165,7 @@ public class CreateTableCompiler { connection.addTable(table, resolvedTime); } }, - connection, tableRef.getTimeStamp()+1); + connection, tableRef.getCurrentTime()+1); viewColumnConstantsToBe = new byte[nColumns][]; ViewWhereExpressionVisitor visitor = new ViewWhereExpressionVisitor(parentToBe, viewColumnConstantsToBe); where.accept(visitor); http://git-wip-us.apache.org/repos/asf/phoenix/blob/c7134afa/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java index 9754313..39d8525 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java @@ -252,7 +252,7 @@ public class StatementContext { } public long getCurrentTime() throws SQLException { - long ts = this.getCurrentTable().getTimeStamp(); + long ts = this.getCurrentTable().getCurrentTime(); // if the table is transactional then it is only resolved once per query, so we can't use the table timestamp if (this.getCurrentTable().getTable().getType() != PTableType.PROJECTED && !this .getCurrentTable().getTable().isTransactional() && ts != QueryConstants http://git-wip-us.apache.org/repos/asf/phoenix/blob/c7134afa/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java index d76f2c8..cea38f0 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java @@ -1055,7 +1055,7 @@ public class MetaDataClient { // Since the table won't be added to the current connection. TableRef tableRef = new TableRef(null, table, ts, false); byte[] emptyCF = SchemaUtil.getEmptyColumnFamily(table); - MutationPlan plan = compiler.compile(Collections.singletonList(tableRef), emptyCF, null, null, tableRef.getTimeStamp()); + MutationPlan plan = compiler.compile(Collections.singletonList(tableRef), emptyCF, null, null, ts); return connection.getQueryServices().updateData(plan); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/c7134afa/phoenix-core/src/main/java/org/apache/phoenix/schema/TableRef.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/TableRef.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/TableRef.java index 2ce5160..37cae22 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/schema/TableRef.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/TableRef.java @@ -35,6 +35,7 @@ public class TableRef { private final String alias; private final long lowerBoundTimeStamp; private final boolean hasDynamicCols; + private final long currentTime; public TableRef(TableRef tableRef) { this(tableRef.alias, tableRef.table, tableRef.upperBoundTimeStamp, tableRef.lowerBoundTimeStamp, tableRef.hasDynamicCols); @@ -64,7 +65,9 @@ public class TableRef { boolean hasDynamicCols) { this.alias = alias; this.table = table; - this.upperBoundTimeStamp = upperBoundTimeStamp; + this.currentTime = upperBoundTimeStamp; + // if UPDATE_CACHE_FREQUENCY is set, always let the server set timestamps + this.upperBoundTimeStamp = table.getUpdateCacheFrequency()!=0 ? QueryConstants.UNSET_TIMESTAMP : upperBoundTimeStamp; this.lowerBoundTimeStamp = lowerBoundTimeStamp; this.hasDynamicCols = hasDynamicCols; } @@ -141,5 +144,9 @@ public class TableRef { public boolean hasDynamicCols() { return hasDynamicCols; } + + public long getCurrentTime() { + return this.currentTime; + } }
