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

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

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/calcite
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;