You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by la...@apache.org on 2014/12/02 06:54:57 UTC

[1/3] phoenix git commit: Revert "PHOENIX-1496 Further reduce work in StatsCollector."

Repository: phoenix
Updated Branches:
  refs/heads/3.0 c1da4c9f2 -> 4f9a71d79
  refs/heads/4.0 198d749df -> db06f21df
  refs/heads/master 3fa1ddccf -> a18086025


Revert "PHOENIX-1496 Further reduce work in StatsCollector."

This reverts commit c1da4c9f2f3a3838554723cdb3eb91d23962b42f.


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

Branch: refs/heads/3.0
Commit: 4f9a71d792475b4f01acd19e68c761cb1d2ee770
Parents: c1da4c9
Author: Lars Hofhansl <la...@apache.org>
Authored: Mon Dec 1 21:53:55 2014 -0800
Committer: Lars Hofhansl <la...@apache.org>
Committed: Mon Dec 1 21:53:55 2014 -0800

----------------------------------------------------------------------
 .../UngroupedAggregateRegionObserver.java       |  4 +--
 .../schema/stats/StatisticsCollector.java       | 38 ++++++--------------
 2 files changed, 11 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/4f9a71d7/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
index d561f30..4cf816a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
@@ -438,9 +438,7 @@ public class UngroupedAggregateRegionObserver extends BaseScannerRegionObserver
                 // when background tasks are updating stats. Instead we track the max timestamp of
                 // the cells and use that.
                 long clientTimeStamp = useCurrentTime ? TimeKeeper.SYSTEM.getCurrentTime() : StatisticsCollector.NO_TIMESTAMP;
-                StatisticsCollector stats = new StatisticsCollector(
-                        c.getEnvironment(), table,
-                        clientTimeStamp, store.getFamily().getName());
+                StatisticsCollector stats = new StatisticsCollector(c.getEnvironment(), table, clientTimeStamp);
                 internalScanner = stats.createCompactionScanner(c.getEnvironment().getRegion(), store, scanner);
             } catch (IOException e) {
                 // If we can't reach the stats table, don't interrupt the normal

http://git-wip-us.apache.org/repos/asf/phoenix/blob/4f9a71d7/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java
index 258ef6d..7ad1d9b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java
@@ -54,13 +54,9 @@ public class StatisticsCollector {
     // Tracks the bytecount per family if it has reached the guidePostsDepth
     private Map<ImmutableBytesPtr, Boolean> familyMap = Maps.newHashMap();
     protected StatisticsWriter statsTable;
-    private Pair<Long,GuidePostsInfo> cachedGps = null;
 
-    public StatisticsCollector(RegionCoprocessorEnvironment env, String tableName, long clientTimeStamp) throws IOException {
-        this(env, tableName, clientTimeStamp, null);
-    }
-
-    public StatisticsCollector(RegionCoprocessorEnvironment env, String tableName, long clientTimeStamp, byte[] family) throws IOException {
+    public StatisticsCollector(RegionCoprocessorEnvironment env, String tableName, long clientTimeStamp)
+            throws IOException {
         Configuration config = env.getConfiguration();
         int guidepostPerRegion = config.getInt(QueryServices.STATS_GUIDEPOST_PER_REGION_ATTRIB, 
                 QueryServicesOptions.DEFAULT_STATS_GUIDEPOST_PER_REGION);
@@ -70,14 +66,6 @@ public class StatisticsCollector {
         // Get the stats table associated with the current table on which the CP is
         // triggered
         this.statsTable = StatisticsWriter.newWriter(env, tableName, clientTimeStamp);
-        // in a compaction we know the one family ahead of time
-        // pre-populate familyMap and guidePostsMap here
-        if (family != null) {
-            ImmutableBytesPtr cfKey = new ImmutableBytesPtr(family, 0, family.length);
-            familyMap.put(cfKey, true);
-            cachedGps = new Pair<Long,GuidePostsInfo>(0L,new GuidePostsInfo(0, Collections.<byte[]>emptyList()));
-            guidePostsMap.put(cfKey, cachedGps);
-        }
     }
     
     public long getMaxTimeStamp() {
@@ -188,21 +176,15 @@ public class StatisticsCollector {
     }
     
     public void updateStatistic(KeyValue kv) {
+        ImmutableBytesPtr cfKey = new ImmutableBytesPtr(kv.getBuffer(), kv.getFamilyOffset(), kv.getFamilyLength());
+        familyMap.put(cfKey, true);
+        
         maxTimeStamp = Math.max(maxTimeStamp, kv.getTimestamp());
-
-        Pair<Long,GuidePostsInfo> gps;
-        if (cachedGps == null) {
-            ImmutableBytesPtr cfKey = new ImmutableBytesPtr(kv.getBuffer(), kv.getFamilyOffset(), kv.getFamilyLength());
-            familyMap.put(cfKey, true);
-
-            // TODO : This can be moved to an interface so that we could collect guide posts in different ways
-            gps = guidePostsMap.get(cfKey);
-            if (gps == null) {
-                gps = new Pair<Long,GuidePostsInfo>(0L,new GuidePostsInfo(0, Collections.<byte[]>emptyList()));
-                guidePostsMap.put(cfKey, gps);
-            }
-        } else {
-            gps = cachedGps;
+        // TODO : This can be moved to an interface so that we could collect guide posts in different ways
+        Pair<Long,GuidePostsInfo> gps = guidePostsMap.get(cfKey);
+        if (gps == null) {
+            gps = new Pair<Long,GuidePostsInfo>(0L,new GuidePostsInfo(0, Collections.<byte[]>emptyList()));
+            guidePostsMap.put(cfKey, gps);
         }
         int kvLength = kv.getLength();
         long byteCount = gps.getFirst() + kvLength;


[2/3] phoenix git commit: Revert "PHOENIX-1496 Further reduce work in StatsCollector."

Posted by la...@apache.org.
Revert "PHOENIX-1496 Further reduce work in StatsCollector."

This reverts commit 198d749df8de8b09227f70864b1f3be777b552d0.


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

Branch: refs/heads/4.0
Commit: db06f21dfb0c3810b63f7acc417896d3ed1ced45
Parents: 198d749
Author: Lars Hofhansl <la...@apache.org>
Authored: Mon Dec 1 21:54:31 2014 -0800
Committer: Lars Hofhansl <la...@apache.org>
Committed: Mon Dec 1 21:54:31 2014 -0800

----------------------------------------------------------------------
 .../UngroupedAggregateRegionObserver.java       |  4 +--
 .../schema/stats/StatisticsCollector.java       | 36 +++++---------------
 2 files changed, 10 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/db06f21d/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
index ff05dad..e0ff5b3 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
@@ -466,9 +466,7 @@ public class UngroupedAggregateRegionObserver extends BaseScannerRegionObserver{
                 // when background tasks are updating stats. Instead we track the max timestamp of
                 // the cells and use that.
                 long clientTimeStamp = useCurrentTime ? TimeKeeper.SYSTEM.getCurrentTime() : StatisticsCollector.NO_TIMESTAMP;
-                StatisticsCollector stats = new StatisticsCollector(
-                        c.getEnvironment(), table.getNameAsString(),
-                        clientTimeStamp, store.getFamily().getName());
+                StatisticsCollector stats = new StatisticsCollector(c.getEnvironment(), table.getNameAsString(), clientTimeStamp);
                 internalScanner = stats.createCompactionScanner(c.getEnvironment().getRegion(), store, scanner);
             } catch (IOException e) {
                 // If we can't reach the stats table, don't interrupt the normal

http://git-wip-us.apache.org/repos/asf/phoenix/blob/db06f21d/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java
index 619684a..4123ebe 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java
@@ -65,13 +65,8 @@ public class StatisticsCollector {
     // Tracks the bytecount per family if it has reached the guidePostsDepth
     private Map<ImmutableBytesPtr, Boolean> familyMap = Maps.newHashMap();
     protected StatisticsWriter statsTable;
-    private Pair<Long,GuidePostsInfo> cachedGps = null;
 
     public StatisticsCollector(RegionCoprocessorEnvironment env, String tableName, long clientTimeStamp) throws IOException {
-        this(env, tableName, clientTimeStamp, null);
-    }
-
-    public StatisticsCollector(RegionCoprocessorEnvironment env, String tableName, long clientTimeStamp, byte[] family) throws IOException {
         Configuration config = env.getConfiguration();
         int guidepostPerRegion = config.getInt(QueryServices.STATS_GUIDEPOST_PER_REGION_ATTRIB, 
                 QueryServicesOptions.DEFAULT_STATS_GUIDEPOST_PER_REGION);
@@ -81,14 +76,6 @@ public class StatisticsCollector {
         // Get the stats table associated with the current table on which the CP is
         // triggered
         this.statsTable = StatisticsWriter.newWriter(env, tableName, clientTimeStamp);
-        // in a compaction we know the one family ahead of time
-        // pre-populate familyMap and guidePostsMap here
-        if (family != null) {
-            ImmutableBytesPtr cfKey = new ImmutableBytesPtr(family, 0, family.length);
-            familyMap.put(cfKey, true);
-            cachedGps = new Pair<Long,GuidePostsInfo>(0L,new GuidePostsInfo(0, Collections.<byte[]>emptyList()));
-            guidePostsMap.put(cfKey, cachedGps);
-        }
     }
     
     public long getMaxTimeStamp() {
@@ -205,22 +192,17 @@ public class StatisticsCollector {
         maxTimeStamp = Math.max(maxTimeStamp, timestamp);
     }
     
+    @SuppressWarnings("deprecation")
     public void updateStatistic(KeyValue kv) {
+        ImmutableBytesPtr cfKey = new ImmutableBytesPtr(kv.getBuffer(), kv.getFamilyOffset(), kv.getFamilyLength());
+        familyMap.put(cfKey, true);
+        
         maxTimeStamp = Math.max(maxTimeStamp, kv.getTimestamp());
-
-        Pair<Long,GuidePostsInfo> gps;
-        if (cachedGps == null) {
-            ImmutableBytesPtr cfKey = new ImmutableBytesPtr(kv.getFamilyArray(), kv.getFamilyOffset(), kv.getFamilyLength());
-            familyMap.put(cfKey, true);
-
-            // TODO : This can be moved to an interface so that we could collect guide posts in different ways
-            gps = guidePostsMap.get(cfKey);
-            if (gps == null) {
-                gps = new Pair<Long,GuidePostsInfo>(0L,new GuidePostsInfo(0, Collections.<byte[]>emptyList()));
-                guidePostsMap.put(cfKey, gps);
-            }
-        } else {
-            gps = cachedGps;
+        // TODO : This can be moved to an interface so that we could collect guide posts in different ways
+        Pair<Long,GuidePostsInfo> gps = guidePostsMap.get(cfKey);
+        if (gps == null) {
+            gps = new Pair<Long,GuidePostsInfo>(0L,new GuidePostsInfo(0, Collections.<byte[]>emptyList()));
+            guidePostsMap.put(cfKey, gps);
         }
         int kvLength = kv.getLength();
         long byteCount = gps.getFirst() + kvLength;


[3/3] phoenix git commit: Revert "PHOENIX-1496 Further reduce work in StatsCollector."

Posted by la...@apache.org.
Revert "PHOENIX-1496 Further reduce work in StatsCollector."

This reverts commit 3fa1ddccf782e8b708c3d1f13d7046fd8b511dce.


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

Branch: refs/heads/master
Commit: a180860250058c8f0fd3afa9807530ccddaaeb32
Parents: 3fa1ddc
Author: Lars Hofhansl <la...@apache.org>
Authored: Mon Dec 1 21:54:57 2014 -0800
Committer: Lars Hofhansl <la...@apache.org>
Committed: Mon Dec 1 21:54:57 2014 -0800

----------------------------------------------------------------------
 .../UngroupedAggregateRegionObserver.java       |  4 +--
 .../schema/stats/StatisticsCollector.java       | 36 +++++---------------
 2 files changed, 10 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/a1808602/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
index ff05dad..e0ff5b3 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
@@ -466,9 +466,7 @@ public class UngroupedAggregateRegionObserver extends BaseScannerRegionObserver{
                 // when background tasks are updating stats. Instead we track the max timestamp of
                 // the cells and use that.
                 long clientTimeStamp = useCurrentTime ? TimeKeeper.SYSTEM.getCurrentTime() : StatisticsCollector.NO_TIMESTAMP;
-                StatisticsCollector stats = new StatisticsCollector(
-                        c.getEnvironment(), table.getNameAsString(),
-                        clientTimeStamp, store.getFamily().getName());
+                StatisticsCollector stats = new StatisticsCollector(c.getEnvironment(), table.getNameAsString(), clientTimeStamp);
                 internalScanner = stats.createCompactionScanner(c.getEnvironment().getRegion(), store, scanner);
             } catch (IOException e) {
                 // If we can't reach the stats table, don't interrupt the normal

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a1808602/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java
index 619684a..4123ebe 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollector.java
@@ -65,13 +65,8 @@ public class StatisticsCollector {
     // Tracks the bytecount per family if it has reached the guidePostsDepth
     private Map<ImmutableBytesPtr, Boolean> familyMap = Maps.newHashMap();
     protected StatisticsWriter statsTable;
-    private Pair<Long,GuidePostsInfo> cachedGps = null;
 
     public StatisticsCollector(RegionCoprocessorEnvironment env, String tableName, long clientTimeStamp) throws IOException {
-        this(env, tableName, clientTimeStamp, null);
-    }
-
-    public StatisticsCollector(RegionCoprocessorEnvironment env, String tableName, long clientTimeStamp, byte[] family) throws IOException {
         Configuration config = env.getConfiguration();
         int guidepostPerRegion = config.getInt(QueryServices.STATS_GUIDEPOST_PER_REGION_ATTRIB, 
                 QueryServicesOptions.DEFAULT_STATS_GUIDEPOST_PER_REGION);
@@ -81,14 +76,6 @@ public class StatisticsCollector {
         // Get the stats table associated with the current table on which the CP is
         // triggered
         this.statsTable = StatisticsWriter.newWriter(env, tableName, clientTimeStamp);
-        // in a compaction we know the one family ahead of time
-        // pre-populate familyMap and guidePostsMap here
-        if (family != null) {
-            ImmutableBytesPtr cfKey = new ImmutableBytesPtr(family, 0, family.length);
-            familyMap.put(cfKey, true);
-            cachedGps = new Pair<Long,GuidePostsInfo>(0L,new GuidePostsInfo(0, Collections.<byte[]>emptyList()));
-            guidePostsMap.put(cfKey, cachedGps);
-        }
     }
     
     public long getMaxTimeStamp() {
@@ -205,22 +192,17 @@ public class StatisticsCollector {
         maxTimeStamp = Math.max(maxTimeStamp, timestamp);
     }
     
+    @SuppressWarnings("deprecation")
     public void updateStatistic(KeyValue kv) {
+        ImmutableBytesPtr cfKey = new ImmutableBytesPtr(kv.getBuffer(), kv.getFamilyOffset(), kv.getFamilyLength());
+        familyMap.put(cfKey, true);
+        
         maxTimeStamp = Math.max(maxTimeStamp, kv.getTimestamp());
-
-        Pair<Long,GuidePostsInfo> gps;
-        if (cachedGps == null) {
-            ImmutableBytesPtr cfKey = new ImmutableBytesPtr(kv.getFamilyArray(), kv.getFamilyOffset(), kv.getFamilyLength());
-            familyMap.put(cfKey, true);
-
-            // TODO : This can be moved to an interface so that we could collect guide posts in different ways
-            gps = guidePostsMap.get(cfKey);
-            if (gps == null) {
-                gps = new Pair<Long,GuidePostsInfo>(0L,new GuidePostsInfo(0, Collections.<byte[]>emptyList()));
-                guidePostsMap.put(cfKey, gps);
-            }
-        } else {
-            gps = cachedGps;
+        // TODO : This can be moved to an interface so that we could collect guide posts in different ways
+        Pair<Long,GuidePostsInfo> gps = guidePostsMap.get(cfKey);
+        if (gps == null) {
+            gps = new Pair<Long,GuidePostsInfo>(0L,new GuidePostsInfo(0, Collections.<byte[]>emptyList()));
+            guidePostsMap.put(cfKey, gps);
         }
         int kvLength = kv.getLength();
         long byteCount = gps.getFirst() + kvLength;