phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeffr...@apache.org
Subject git commit: PHOENIX-992: Replace hTable.getRowOrBefore with ReverseScan to get maxKey in StatsManagerImpl
Date Thu, 22 May 2014 21:48:01 GMT
Repository: incubator-phoenix
Updated Branches:
  refs/heads/master 6c3b6524e -> dff13fe6c


PHOENIX-992: Replace hTable.getRowOrBefore with ReverseScan to get maxKey in StatsManagerImpl


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

Branch: refs/heads/master
Commit: dff13fe6c16da9e6f70421b292bf64a0422b4ebf
Parents: 6c3b652
Author: Jeffrey Zhong <jzhong@JZhongs-MacBook-Pro.local>
Authored: Thu May 22 14:40:58 2014 -0700
Committer: Jeffrey Zhong <jzhong@JZhongs-MacBook-Pro.local>
Committed: Thu May 22 14:53:10 2014 -0700

----------------------------------------------------------------------
 .../end2end/BaseTenantSpecificViewIndexIT.java  | 10 +++++----
 .../end2end/TenantSpecificViewIndexIT.java      |  2 +-
 .../apache/phoenix/query/StatsManagerImpl.java  | 22 ++++++++++++--------
 3 files changed, 20 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/dff13fe6/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificViewIndexIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificViewIndexIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificViewIndexIT.java
index 3b5eb1f..5878806 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificViewIndexIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificViewIndexIT.java
@@ -102,10 +102,12 @@ public class BaseTenantSpecificViewIndexIT extends BaseHBaseManagedTimeIT
{
         conn.createStatement().execute("UPSERT INTO v(k2,v1,v2) VALUES (-1, 'blah', 'superblah')");
// sanity check that we can upsert after index is there
         conn.commit();
         ResultSet rs = conn.createStatement().executeQuery("EXPLAIN SELECT k1, k2, v2 FROM
v WHERE v2='" + valuePrefix + "v2-1'");
-        assertEquals(saltBuckets == null ? 
-                "CLIENT PARALLEL 1-WAY RANGE SCAN OVER _IDX_T ['" + tenantId + "',-32768,'"
+ valuePrefix + "v2-1']" :
-                "CLIENT PARALLEL 4-WAY SKIP SCAN ON 3 KEYS OVER _IDX_T [0,'" + tenantId +
"',-32768,'" + valuePrefix + "v2-1'] - [2,'" + tenantId + "',-32768,'" + valuePrefix + "v2-1']\n"
+ 
-                "CLIENT MERGE SORT", QueryUtil.getExplainPlan(rs));
+        
+        String expected = saltBuckets == null ? 
+                "RANGE SCAN OVER _IDX_T ['" + tenantId + "',-32768,'" + valuePrefix + "v2-1']"
:
+                "SKIP SCAN ON 3 KEYS OVER _IDX_T [0,'" + tenantId + "',-32768,'" + valuePrefix
+ "v2-1'] - [2,'" + tenantId + "',-32768,'" + valuePrefix + "v2-1']\n" + 
+                "CLIENT MERGE SORT";
+        assertTrue(QueryUtil.getExplainPlan(rs).contains(expected));
     }
     
     private Connection createTenantConnection(String tenantId) throws SQLException {

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/dff13fe6/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificViewIndexIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificViewIndexIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificViewIndexIT.java
index 1f8eb55..cec7fed 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificViewIndexIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificViewIndexIT.java
@@ -96,7 +96,7 @@ public class TenantSpecificViewIndexIT extends BaseTenantSpecificViewIndexIT
{
         assertEquals("f",rs.getString(2));
         assertFalse(rs.next());
         rs = conn.createStatement().executeQuery("explain select pk2,col1 from acme where
col1='f'");
-        assertEquals("CLIENT PARALLEL 1-WAY RANGE SCAN OVER _IDX_MT_BASE ['a',-32768,'f']",QueryUtil.getExplainPlan(rs));
+        assertEquals("CLIENT PARALLEL 4-WAY RANGE SCAN OVER _IDX_MT_BASE ['a',-32768,'f']",QueryUtil.getExplainPlan(rs));
         
         try {
             // Cannot reference tenant_id column in tenant specific connection

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/dff13fe6/phoenix-core/src/main/java/org/apache/phoenix/query/StatsManagerImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/StatsManagerImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/StatsManagerImpl.java
index 1ab7df5..905802b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/StatsManagerImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/StatsManagerImpl.java
@@ -93,15 +93,19 @@ public class StatsManagerImpl implements StatsManager {
             } finally {
                 scanner.close();
             }
-            int maxPossibleKeyLength = SchemaUtil.estimateKeyLength(tableRef.getTable());
-            byte[] maxPossibleKey = new byte[maxPossibleKeyLength];
-            Arrays.fill(maxPossibleKey, (byte)255);
-            // Use this deprecated method to get the key "before" the max possible key value,
-            // which is the max key for a table.
-            @SuppressWarnings("deprecation")
-            Result r = hTable.getRowOrBefore(maxPossibleKey, tableRef.getTable().getColumnFamilies().iterator().next().getName().getBytes());
-            if (r != null) {
-                maxKey = r.getRow();
+            
+            // Get max possible key value
+            scan = new Scan();
+            scan.setFilter(new KeyOnlyFilter());
+            scan.setReversed(true);
+            scanner = hTable.getScanner(scan);
+            try {
+                Result r = scanner.next(); 
+                if (r != null) {
+                    maxKey = r.getRow();
+                }
+            } finally {
+                scanner.close();
             }
             tableStatsMap.put(tableRef.getTable().getName().getString(), new PTableStats(timeKeeper.getCurrentTime(),minKey,maxKey));
         } catch (IOException e) {


Mime
View raw message