Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 d04c15a05 -> 16cde5018


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/16cde501
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/16cde501
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/16cde501

Branch: refs/heads/4.x-HBase-1.1
Commit: 16cde5018c9d1981932301cc12d4b236cde5650c
Parents: d04c15a
Author: Thomas <[email protected]>
Authored: Tue Jun 6 16:06:36 2017 -0700
Committer: Thomas <[email protected]>
Committed: Wed Jun 7 13:08:37 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/16cde501/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/16cde501/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/16cde501/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 3f6d98a..537d31b 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
@@ -1054,7 +1054,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/16cde501/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;
+    }
 
 }

Reply via email to