phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject phoenix git commit: PHOENIX-3434 Avoid creating new Configuration in ClientAggregatePlan to improve performance
Date Wed, 02 Nov 2016 20:17:18 GMT
Repository: phoenix
Updated Branches:
  refs/heads/master b477f370c -> cb59b2e5a


PHOENIX-3434 Avoid creating new Configuration in ClientAggregatePlan to improve performance


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

Branch: refs/heads/master
Commit: cb59b2e5a144bc8075f897e6a91bfd388fb8cc44
Parents: b477f37
Author: James Taylor <jamestaylor@apache.org>
Authored: Wed Nov 2 13:16:55 2016 -0700
Committer: James Taylor <jamestaylor@apache.org>
Committed: Wed Nov 2 13:17:09 2016 -0700

----------------------------------------------------------------------
 .../apache/phoenix/execute/ClientAggregatePlan.java   |  8 +++++++-
 .../expression/aggregator/ServerAggregators.java      | 14 --------------
 .../expression/function/SingleAggregateFunction.java  |  6 +++---
 .../apache/phoenix/query/ConnectionQueryServices.java |  3 +++
 .../phoenix/query/ConnectionQueryServicesImpl.java    |  5 +++++
 .../query/ConnectionlessQueryServicesImpl.java        |  8 +++++++-
 .../query/DelegateConnectionQueryServices.java        |  6 ++++++
 7 files changed, 31 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/cb59b2e5/phoenix-core/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
b/phoenix-core/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
index efe617e..8ef1f8d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
@@ -34,6 +34,7 @@ import org.apache.phoenix.compile.OrderByCompiler.OrderBy;
 import org.apache.phoenix.compile.QueryPlan;
 import org.apache.phoenix.compile.RowProjector;
 import org.apache.phoenix.compile.StatementContext;
+import org.apache.phoenix.coprocessor.BaseScannerRegionObserver;
 import org.apache.phoenix.expression.Expression;
 import org.apache.phoenix.expression.OrderByExpression;
 import org.apache.phoenix.expression.aggregator.Aggregators;
@@ -77,7 +78,12 @@ public class ClientAggregatePlan extends ClientProcessingPlan {
         this.groupBy = groupBy;
         this.having = having;
         this.clientAggregators = context.getAggregationManager().getAggregators();
-        this.serverAggregators = ServerAggregators.newServerAggregators(this.clientAggregators);
+        // We must deserialize rather than clone based off of client aggregators because
+        // upon deserialization we create the server-side aggregators instead of the client-side
+        // aggregators. We use the Configuration directly here to avoid the expense of creating
+        // another one.
+        this.serverAggregators = ServerAggregators.deserialize(context.getScan()
+                        .getAttribute(BaseScannerRegionObserver.AGGREGATORS), context.getConnection().getQueryServices().getConfiguration());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cb59b2e5/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/ServerAggregators.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/ServerAggregators.java
b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/ServerAggregators.java
index 56ffba8..366bbc6 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/ServerAggregators.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/ServerAggregators.java
@@ -102,20 +102,6 @@ public class ServerAggregators extends Aggregators {
         return aggregators;
     }
 
-    public static ServerAggregators newServerAggregators(ClientAggregators clientAggregators)
{
-        int minNullableIndex = clientAggregators.getMinNullableIndex();
-        SingleAggregateFunction[] functions = clientAggregators.getFunctions();
-        int len = functions.length;
-        Aggregator[] aggregators = new Aggregator[len];
-        Expression[] expressions = new Expression[len];
-        for (int i = 0; i < len; i++) {
-            SingleAggregateFunction aggFunc = functions[i];
-            aggregators[i] = aggFunc.getAggregator();
-            expressions[i] = aggFunc.getAggregatorExpression();
-        }
-        return new ServerAggregators(functions, aggregators,expressions, minNullableIndex);
-    }
-    
     /**
      * Deserialize aggregators from the serialized byte array representation
      * @param b byte array representation of a list of Aggregators

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cb59b2e5/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SingleAggregateFunction.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SingleAggregateFunction.java
b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SingleAggregateFunction.java
index 6155e1d..458ef87 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SingleAggregateFunction.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/SingleAggregateFunction.java
@@ -30,8 +30,8 @@ import org.apache.phoenix.expression.Expression;
 import org.apache.phoenix.expression.LiteralExpression;
 import org.apache.phoenix.expression.aggregator.Aggregator;
 import org.apache.phoenix.expression.visitor.ExpressionVisitor;
-import org.apache.phoenix.schema.types.PDataType;
 import org.apache.phoenix.schema.tuple.Tuple;
+import org.apache.phoenix.schema.types.PDataType;
 
 
 /**
@@ -92,7 +92,7 @@ abstract public class SingleAggregateFunction extends AggregateFunction
{
     
     private SingleAggregateFunction(List<Expression> children, boolean isConstant)
{
         super(children);
-        this.isConstant = children.get(0) instanceof LiteralExpression;
+        this.isConstant = isConstant;
         this.aggregator = newClientAggregator();
     }
 
@@ -143,7 +143,7 @@ abstract public class SingleAggregateFunction extends AggregateFunction
{
         return agg;
     }
     
-    public void readFields(DataInput input, Configuration conf) throws IOException {
+    public final void readFields(DataInput input, Configuration conf) throws IOException
{
         super.readFields(input);
         aggregator = newServerAggregator(conf);
     }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cb59b2e5/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java
index 0478e07..51716d0 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java
@@ -23,6 +23,7 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
+import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
@@ -142,4 +143,6 @@ public interface ConnectionQueryServices extends QueryServices, MetaDataMutated
 
     boolean isUpgradeRequired();
     void upgradeSystemTables(String url, Properties props) throws SQLException;
+    
+    public Configuration getConfiguration();
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cb59b2e5/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index a1172c2..2d1f2cd 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -4120,4 +4120,9 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
     public boolean isUpgradeRequired() {
         return upgradeRequired.get();
     }
+
+    @Override
+    public Configuration getConfiguration() {
+        return config;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cb59b2e5/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java
index 1b1e429..b61b6f0 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java
@@ -114,6 +114,7 @@ public class ConnectionlessQueryServicesImpl extends DelegateQueryServices
imple
     private volatile SQLException initializationException;
     private final Map<String, List<HRegionLocation>> tableSplits = Maps.newHashMap();
     private final GuidePostsCache guidePostsCache;
+    private final Configuration config;
     
     public ConnectionlessQueryServicesImpl(QueryServices services, ConnectionInfo connInfo,
Properties info) {
         super(services);
@@ -137,7 +138,7 @@ public class ConnectionlessQueryServicesImpl extends DelegateQueryServices
imple
 
         // Without making a copy of the configuration we cons up, we lose some of our properties
         // on the server side during testing.
-        config = HBaseFactoryProvider.getConfigurationFactory().getConfiguration(config);
+        this.config = HBaseFactoryProvider.getConfigurationFactory().getConfiguration(config);
         TransactionManager txnManager = new TransactionManager(config);
         this.txSystemClient = new InMemoryTxSystemClient(txnManager);
         this.guidePostsCache = new GuidePostsCache(this, config);
@@ -662,4 +663,9 @@ public class ConnectionlessQueryServicesImpl extends DelegateQueryServices
imple
     public boolean isUpgradeRequired() {
         return false;
     }
+
+    @Override
+    public Configuration getConfiguration() {
+        return config;
+    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/cb59b2e5/phoenix-core/src/main/java/org/apache/phoenix/query/DelegateConnectionQueryServices.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/DelegateConnectionQueryServices.java
b/phoenix-core/src/main/java/org/apache/phoenix/query/DelegateConnectionQueryServices.java
index 7466e9c..725af2b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/DelegateConnectionQueryServices.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/DelegateConnectionQueryServices.java
@@ -23,6 +23,7 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
+import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
@@ -355,4 +356,9 @@ public class DelegateConnectionQueryServices extends DelegateQueryServices
imple
     public boolean isUpgradeRequired() {
         return getDelegate().isUpgradeRequired();
     }
+
+    @Override
+    public Configuration getConfiguration() {
+        return getDelegate().getConfiguration();
+    }
 }
\ No newline at end of file


Mime
View raw message