You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2016/02/17 02:22:43 UTC

[1/2] phoenix git commit: PHOENIX-2666 Performance regression: Aggregate query with filter on table with multiple column families

Repository: phoenix
Updated Branches:
  refs/heads/master 4ccce0ed1 -> d8e5a73be


PHOENIX-2666 Performance regression: Aggregate query with filter on table with multiple column families


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

Branch: refs/heads/master
Commit: 6544573832324789f8cbd4531aa6614145c9eb7d
Parents: 4ccce0e
Author: James Taylor <ja...@apache.org>
Authored: Tue Feb 16 17:15:57 2016 -0800
Committer: James Taylor <ja...@apache.org>
Committed: Tue Feb 16 17:15:57 2016 -0800

----------------------------------------------------------------------
 .../phoenix/iterate/BaseResultIterators.java    | 34 ++++++++++----------
 1 file changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/65445738/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
index 2352e94..d8256d7 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
@@ -18,10 +18,10 @@
 package org.apache.phoenix.iterate;
 
 import static org.apache.phoenix.coprocessor.BaseScannerRegionObserver.EXPECTED_UPPER_REGION_KEY;
+import static org.apache.phoenix.coprocessor.BaseScannerRegionObserver.SCAN_ACTUAL_START_ROW;
 import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_FAILED_QUERY_COUNTER;
 import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_QUERY_TIMEOUT_COUNTER;
 import static org.apache.phoenix.util.ByteUtil.EMPTY_BYTE_ARRAY;
-import static org.apache.phoenix.coprocessor.BaseScannerRegionObserver.SCAN_ACTUAL_START_ROW;
 
 import java.io.ByteArrayInputStream;
 import java.io.DataInput;
@@ -179,8 +179,15 @@ public abstract class BaseResultIterators extends ExplainTable implements Result
                     // Project the one column family. We must project a column family since it's possible
                     // that there are other non declared column families that we need to ignore.
                     scan.addFamily(table.getColumnFamilies().get(0).getName().getBytes());
-                } else {
-                    if (projector.projectEveryRow()) {
+                } else if (projector.projectEveryRow()) {
+                    if (table.getViewType() == ViewType.MAPPED) {
+                        // Since we don't have the empty key value in MAPPED tables, 
+                        // we must select all CFs in HRS. However, only the
+                        // selected column values are returned back to client.
+                        for (PColumnFamily family : table.getColumnFamilies()) {
+                            scan.addFamily(family.getName().getBytes());
+                        }
+                    } else {
                         byte[] ecf = SchemaUtil.getEmptyColumnFamily(table);
                         // Project empty key value unless the column family containing it has
                         // been projected in its entirety.
@@ -188,32 +195,25 @@ public abstract class BaseResultIterators extends ExplainTable implements Result
                             scan.addColumn(ecf, QueryConstants.EMPTY_COLUMN_BYTES);
                         }
                     }
-                }
-                if (table.getViewType() == ViewType.MAPPED) {
-                    if (projector.projectEveryRow()) {
-                        // Since we don't have the empty key value in MAPPED tables, 
-                        // we must select all CFs in HRS. However, only the
-                        // selected column values are returned back to client.
-                        for (PColumnFamily family : table.getColumnFamilies()) {
-                            scan.addFamily(family.getName().getBytes());
-                        }
+                } else {
+                    for (Pair<byte[], byte[]> whereColumn : context.getWhereConditionColumns()) {
+                        scan.addColumn(whereColumn.getFirst(), whereColumn.getSecond());
                     }
-            } 
+                }
             }
             // Add FirstKeyOnlyFilter if there are no references to key value columns
             if (keyOnlyFilter) {
                 ScanUtil.andFilterAtBeginning(scan, new FirstKeyOnlyFilter());
             }
-            
-            // TODO adding all CFs here is not correct. It should be done only after ColumnProjectionOptimization.
+
             if (perScanLimit != null) {
                 ScanUtil.andFilterAtEnd(scan, new PageFilter(perScanLimit));
             }
-    
+
             doColumnProjectionOptimization(context, scan, table, statement);
         }
     }
-    
+
     public BaseResultIterators(QueryPlan plan, Integer perScanLimit, ParallelScanGrouper scanGrouper) throws SQLException {
         super(plan.getContext(), plan.getTableRef(), plan.getGroupBy(), plan.getOrderBy(), plan.getStatement().getHint(), plan.getLimit());
         this.plan = plan;


[2/2] phoenix git commit: PHOENIX-2680 stats table timestamp incorrectly used as table timestamp

Posted by ja...@apache.org.
PHOENIX-2680 stats table timestamp incorrectly used as table timestamp


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

Branch: refs/heads/master
Commit: d8e5a73be52c798b525068382e0376cb2d79e372
Parents: 6544573
Author: James Taylor <ja...@apache.org>
Authored: Tue Feb 16 17:17:54 2016 -0800
Committer: James Taylor <ja...@apache.org>
Committed: Tue Feb 16 17:17:54 2016 -0800

----------------------------------------------------------------------
 .../UngroupedAggregateRegionObserver.java           | 10 +---------
 .../phoenix/schema/stats/StatisticsCollector.java   | 16 ++++++++++------
 2 files changed, 11 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/d8e5a73b/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 05cf08e..e000e25 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
@@ -80,7 +80,6 @@ import org.apache.phoenix.index.IndexMaintainer;
 import org.apache.phoenix.index.PhoenixIndexCodec;
 import org.apache.phoenix.join.HashJoinInfo;
 import org.apache.phoenix.query.QueryConstants;
-import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.query.QueryServicesOptions;
 import org.apache.phoenix.schema.ConstraintViolationException;
 import org.apache.phoenix.schema.PColumn;
@@ -610,20 +609,13 @@ public class UngroupedAggregateRegionObserver extends BaseScannerRegionObserver
         InternalScanner internalScanner = scanner;
         if (scanType.equals(ScanType.COMPACT_DROP_DELETES)) {
             try {
-                boolean useCurrentTime = c.getEnvironment().getConfiguration().getBoolean(
-                        QueryServices.STATS_USE_CURRENT_TIME_ATTRIB,
-                        QueryServicesOptions.DEFAULT_STATS_USE_CURRENT_TIME);
                 Connection conn = c.getEnvironment().getRegionServerServices().getConnection();
                 Pair<HRegionInfo, HRegionInfo> mergeRegions = null;
                 if (store.hasReferences()) {
                     mergeRegions = MetaTableAccessor.getRegionsFromMergeQualifier(conn,
                             c.getEnvironment().getRegion().getRegionInfo().getRegionName());
                 }
-                // Provides a means of clients controlling their timestamps to not use current time
-                // 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;
+                long clientTimeStamp = TimeKeeper.SYSTEM.getCurrentTime();
                 StatisticsCollector stats = new StatisticsCollector(c.getEnvironment(), table.getNameAsString(),
                         clientTimeStamp, store.getFamily().getName());
                 internalScanner = stats.createCompactionScanner(c.getEnvironment(), store, scanner, mergeRegions);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d8e5a73b/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 75e0aa0..1d0204f 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
@@ -63,11 +63,6 @@ public class StatisticsCollector {
     protected StatisticsWriter statsTable;
     private Pair<Long, GuidePostsInfoBuilder> cachedGps = null;
 
-    public StatisticsCollector(RegionCoprocessorEnvironment env, String tableName, long clientTimeStamp)
-            throws IOException {
-        this(env, tableName, clientTimeStamp, null, null, null);
-    }
-
     public StatisticsCollector(RegionCoprocessorEnvironment env, String tableName, long clientTimeStamp,
             byte[] gp_width_bytes, byte[] gp_per_region_bytes) throws IOException {
         this(env, tableName, clientTimeStamp, null, gp_width_bytes, gp_per_region_bytes);
@@ -78,7 +73,7 @@ public class StatisticsCollector {
         this(env, tableName, clientTimeStamp, family, null, null);
     }
 
-    public StatisticsCollector(RegionCoprocessorEnvironment env, String tableName, long clientTimeStamp, byte[] family,
+    private StatisticsCollector(RegionCoprocessorEnvironment env, String tableName, long clientTimeStamp, byte[] family,
             byte[] gp_width_bytes, byte[] gp_per_region_bytes) throws IOException {
         Configuration config = env.getConfiguration();
         int guidepostPerRegion = gp_per_region_bytes == null
@@ -91,6 +86,15 @@ public class StatisticsCollector {
                 : PLong.INSTANCE.getCodec().decodeInt(gp_width_bytes, 0, SortOrder.getDefault());
         this.guidepostDepth = StatisticsUtil.getGuidePostDepth(guidepostPerRegion, guidepostWidth,
                 env.getRegion().getTableDesc());
+        // Provides a means of clients controlling their timestamps to not use current time
+        // when background tasks are updating stats. Instead we track the max timestamp of
+        // the cells and use that.
+        boolean useCurrentTime = env.getConfiguration().getBoolean(
+                QueryServices.STATS_USE_CURRENT_TIME_ATTRIB,
+                QueryServicesOptions.DEFAULT_STATS_USE_CURRENT_TIME);
+        if (!useCurrentTime) {
+            clientTimeStamp = StatisticsCollector.NO_TIMESTAMP;
+        }
         // Get the stats table associated with the current table on which the CP is
         // triggered
         this.statsTable = StatisticsWriter.newWriter(env, tableName, clientTimeStamp);