phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject git commit: Fix comparison for min time before doing an update stats and set small min in test Set frequency for stats update to 0 for testing
Date Mon, 06 Oct 2014 16:18:17 GMT
Repository: phoenix
Updated Branches:
  refs/heads/master 166671c89 -> 9b98d0a8c


Fix comparison for min time before doing an update stats and set small min in test
Set frequency for stats update to 0 for testing


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

Branch: refs/heads/master
Commit: 9b98d0a8ccde8da79e537e58cdd8e67dc520cad5
Parents: 166671c
Author: James Taylor <jtaylor@salesforce.com>
Authored: Mon Oct 6 01:16:36 2014 -0700
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Mon Oct 6 09:22:39 2014 -0700

----------------------------------------------------------------------
 .../java/org/apache/phoenix/schema/MetaDataClient.java | 13 ++++++-------
 .../apache/phoenix/query/QueryServicesTestImpl.java    |  2 ++
 2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/9b98d0a8/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 09f77ac..469f8fe 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
@@ -49,7 +49,6 @@ import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SALT_BUCKETS;
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SORT_ORDER;
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA;
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_TABLE;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_STATS_TABLE;
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_NAME;
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SCHEM;
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SEQ_NUM;
@@ -481,7 +480,7 @@ public class MetaDataClient {
 
     public MutationState updateStatistics(UpdateStatisticsStatement updateStatisticsStmt)
throws SQLException {
         // Check before updating the stats if we have reached the configured time to reupdate
the stats once again
-        long minTimeForStatsUpdate = connection.getQueryServices().getProps()
+        long msMinBetweenUpdates = connection.getQueryServices().getProps()
                 .getLong(QueryServices.STATS_UPDATE_FREQ_MS_ATTRIB, QueryServicesOptions.DEFAULT_STATS_UPDATE_FREQ_MS);
         ColumnResolver resolver = FromCompiler.getResolver(updateStatisticsStmt, connection);
         PTable table = resolver.getTables().get(0).getTable();
@@ -493,15 +492,15 @@ public class MetaDataClient {
         connection.getQueryServices().clearCacheForTable(tenantIdBytes,
                 Bytes.toBytes(SchemaUtil.getSchemaNameFromFullName(physicalName.getString())),
                 Bytes.toBytes(SchemaUtil.getTableNameFromFullName(physicalName.getString())),
clientTS);
-        String query = "SELECT CURRENT_DATE(),"+ LAST_STATS_UPDATE_TIME + " FROM " + SYSTEM_CATALOG_SCHEMA
-                + "." + SYSTEM_STATS_TABLE + " WHERE " + PHYSICAL_NAME + "='" + physicalName.getString()
+ "' AND " + COLUMN_FAMILY
+        String query = "SELECT CURRENT_DATE(),"+ LAST_STATS_UPDATE_TIME + " FROM " + PhoenixDatabaseMetaData.SYSTEM_STATS_NAME
+                + " WHERE " + PHYSICAL_NAME + "='" + physicalName.getString() + "' AND "
+ COLUMN_FAMILY
                 + " IS NULL AND " + REGION_NAME + " IS NULL";
         ResultSet rs = connection.createStatement().executeQuery(query);
-        long lastUpdatedTime = 0;
+        long msSinceLastUpdate = Long.MAX_VALUE;
         if (rs.next() && rs.getDate(2) != null) {
-            lastUpdatedTime = rs.getDate(1).getTime() - rs.getDate(2).getTime();
+            msSinceLastUpdate = rs.getDate(1).getTime() - rs.getDate(2).getTime();
         }
-        if (minTimeForStatsUpdate  > lastUpdatedTime) {
+        if (msSinceLastUpdate >= msMinBetweenUpdates) {
             // Here create the select query.
             String countQuery = "SELECT /*+ NO_CACHE */ count(*) FROM " + table.getName().getString();
             PhoenixStatement statement = (PhoenixStatement) connection.createStatement();

http://git-wip-us.apache.org/repos/asf/phoenix/blob/9b98d0a8/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java
b/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java
index 6e29c69..5f33537 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/query/QueryServicesTestImpl.java
@@ -52,6 +52,7 @@ public final class QueryServicesTestImpl extends BaseQueryServicesImpl {
     public static final long DEFAULT_MAX_SERVER_METADATA_CACHE_SIZE =  1024L*1024L*4L; //
4 Mb
     public static final long DEFAULT_MAX_CLIENT_METADATA_CACHE_SIZE =  1024L*1024L*2L; //
2 Mb
     public static final long DEFAULT_HISTOGRAM_BYTE_DEPTH = 2000;
+    public static final int DEFAULT_STATS_UPDATE_FREQ_MS = 0;
 
     
     public QueryServicesTestImpl(ReadOnlyProps defaultProps) {
@@ -60,6 +61,7 @@ public final class QueryServicesTestImpl extends BaseQueryServicesImpl {
     
     private static QueryServicesOptions getDefaultServicesOptions() {
     	return withDefaults()
+    	        .setStatsUpdateFrequencyMs(DEFAULT_STATS_UPDATE_FREQ_MS)
     	        .setHistogramByteDepth(DEFAULT_HISTOGRAM_BYTE_DEPTH)
                 .setThreadPoolSize(DEFAULT_THREAD_POOL_SIZE)
                 .setQueueSize(DEFAULT_QUEUE_SIZE)


Mime
View raw message