phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject phoenix git commit: PHOENIX-2763 rowcount stats not correct after major compaction
Date Mon, 14 Mar 2016 15:27:51 GMT
Repository: phoenix
Updated Branches:
  refs/heads/master 5d33fba63 -> cc98e469d


PHOENIX-2763 rowcount stats not correct after major compaction


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

Branch: refs/heads/master
Commit: cc98e469d7bdb41c822fbf4f395d0c796f12be74
Parents: 5d33fba
Author: Ankit Singhal <ankitsinghal59@gmail.com>
Authored: Mon Mar 14 20:57:16 2016 +0530
Committer: Ankit Singhal <ankitsinghal59@gmail.com>
Committed: Mon Mar 14 20:57:16 2016 +0530

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/StatsCollectorIT.java   | 13 ++++++++++---
 .../schema/stats/DefaultStatisticsCollector.java       |  6 +++++-
 2 files changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/cc98e469/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java
index bc575fd..2284ee2 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsCollectorIT.java
@@ -39,6 +39,7 @@ import java.util.Properties;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
 import org.apache.phoenix.query.ConnectionQueryServices;
 import org.apache.phoenix.query.KeyRange;
 import org.apache.phoenix.query.QueryServices;
@@ -366,11 +367,13 @@ public class StatsCollectorIT extends StatsCollectorAbstractIT {
             props.setProperty(QueryServices.MIN_STATS_UPDATE_FREQ_MS_ATTRIB, minStatsUpdateFreq.toString());
         }
         conn = DriverManager.getConnection(getUrl(), props);
-        conn.createStatement().execute("CREATE TABLE " + tableName + "(k CHAR(1) PRIMARY
KEY, v INTEGER) " + HColumnDescriptor.KEEP_DELETED_CELLS + "=" + Boolean.FALSE);
-        stmt = conn.prepareStatement("UPSERT INTO " + tableName + " VALUES(?,?)");
+        conn.createStatement().execute("CREATE TABLE " + tableName + "(k CHAR(1) PRIMARY
KEY, v INTEGER, w INTEGER) "
+                + HColumnDescriptor.KEEP_DELETED_CELLS + "=" + Boolean.FALSE);
+        stmt = conn.prepareStatement("UPSERT INTO " + tableName + " VALUES(?,?,?)");
         for (int i = 0; i < nRows; i++) {
             stmt.setString(1, Character.toString((char) ('a' + i)));
             stmt.setInt(2, i);
+            stmt.setInt(3, i);
             stmt.executeUpdate();
         }
         conn.commit();
@@ -392,7 +395,7 @@ public class StatsCollectorIT extends StatsCollectorAbstractIT {
         List<KeyRange>keyRanges = getAllSplits(conn, tableName);
         assertEquals(nRows+1, keyRanges.size());
         
-        int nDeletedRows = conn.createStatement().executeUpdate("DELETE FROM " + tableName
+ " WHERE V < 5");
+        int nDeletedRows = conn.createStatement().executeUpdate("DELETE FROM " + tableName
+ " WHERE V < " + nRows / 2);
         conn.commit();
         assertEquals(5, nDeletedRows);
         
@@ -411,6 +414,10 @@ public class StatsCollectorIT extends StatsCollectorAbstractIT {
             keyRanges = getAllSplits(conn, tableName);
         }
         assertEquals(nRows/2+1, keyRanges.size());
+        ResultSet rs = conn.createStatement().executeQuery("SELECT SUM(GUIDE_POSTS_ROW_COUNT)
FROM "
+                + PhoenixDatabaseMetaData.SYSTEM_STATS_NAME + " WHERE PHYSICAL_NAME='" +
tableName + "'");
+        rs.next();
+        assertEquals(nRows - nDeletedRows, rs.getLong(1));
         
     }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cc98e469/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/DefaultStatisticsCollector.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/DefaultStatisticsCollector.java
b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/DefaultStatisticsCollector.java
index b81d206..0db204d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/DefaultStatisticsCollector.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/DefaultStatisticsCollector.java
@@ -166,6 +166,7 @@ class DefaultStatisticsCollector implements StatisticsCollector {
     @Override
     public void collectStatistics(final List<Cell> results) {
         Map<ImmutableBytesPtr, Boolean> famMap = Maps.newHashMap();
+        boolean incrementRow = true;
         for (Cell cell : results) {
             KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
             maxTimeStamp = Math.max(maxTimeStamp, kv.getTimestamp());
@@ -185,7 +186,10 @@ class DefaultStatisticsCollector implements StatisticsCollector {
                 }
             } else {
                 gps = cachedGps;
-                cachedGps.getSecond().incrementRowCount();
+                if (incrementRow) {
+                    cachedGps.getSecond().incrementRowCount();
+                    incrementRow = false;
+                }
             }
             int kvLength = kv.getLength();
             long byteCount = gps.getFirst() + kvLength;


Mime
View raw message