asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject asterixdb git commit: ASTERIXDB-1711: remove more Aql-prefixes
Date Thu, 22 Dec 2016 18:22:39 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master eb199d3a9 -> 0294b3119


ASTERIXDB-1711: remove more Aql-prefixes

AqlMissingWriterFactory -> MissingWriterFactory
AqlPositionWriter -> PositionWriter
AqlMergeAggregationExpressionFactory -> MergeAggregationExpressionFactory
AqlMissableTypeComputer -> MissableTypeComputer
AqlPartialAggregationTypeComputer -> PartialAggregationTypeComputer
AqlOptimizationContextFactory -> OptimizationContextFactory

Change-Id: I72f3051ff5c76ccde54e8b3b33941eb936870194
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1386
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>


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

Branch: refs/heads/master
Commit: 0294b3119a9e7e33cc92ec0a2b7e2adaf0e2ce27
Parents: eb199d3
Author: Till Westmann <tillw@apache.org>
Authored: Wed Dec 21 17:49:20 2016 -0800
Committer: Yingyi Bu <buyingyi@gmail.com>
Committed: Thu Dec 22 10:22:07 2016 -0800

----------------------------------------------------------------------
 .../optimizer/rules/ConstantFoldingRule.java    |  4 +-
 .../AqlExpressionToPlanTranslator.java          |  2 +-
 .../AqlPlusExpressionToPlanTranslator.java      |  2 +-
 .../asterix/translator/AqlPositionWriter.java   | 37 ------------
 .../asterix/translator/PositionWriter.java      | 37 ++++++++++++
 .../SqlppExpressionToPlanTranslator.java        |  6 +-
 .../apache/asterix/api/common/APIFramework.java | 20 +++----
 .../AqlMergeAggregationExpressionFactory.java   | 62 --------------------
 .../data/common/AqlMissableTypeComputer.java    | 52 ----------------
 .../AqlPartialAggregationTypeComputer.java      | 51 ----------------
 .../MergeAggregationExpressionFactory.java      | 61 +++++++++++++++++++
 .../data/common/MissableTypeComputer.java       | 52 ++++++++++++++++
 .../common/PartialAggregationTypeComputer.java  | 51 ++++++++++++++++
 .../data/nontagged/AqlMissingWriterFactory.java | 50 ----------------
 .../data/nontagged/MissingWriterFactory.java    | 50 ++++++++++++++++
 .../runtime/formats/NonTaggedDataFormat.java    |  4 +-
 16 files changed, 270 insertions(+), 271 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0294b311/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
index d2982e8..3ef5f2b 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
@@ -25,7 +25,7 @@ import java.util.List;
 
 import org.apache.asterix.common.config.GlobalConfig;
 import org.apache.asterix.dataflow.data.common.ExpressionTypeComputer;
-import org.apache.asterix.dataflow.data.nontagged.AqlMissingWriterFactory;
+import org.apache.asterix.dataflow.data.nontagged.MissingWriterFactory;
 import org.apache.asterix.formats.nontagged.ADMPrinterFactoryProvider;
 import org.apache.asterix.formats.nontagged.BinaryBooleanInspector;
 import org.apache.asterix.formats.nontagged.BinaryComparatorFactoryProvider;
@@ -125,7 +125,7 @@ public class ConstantFoldingRule implements IAlgebraicRewriteRule {
             SerializerDeserializerProvider.INSTANCE, BinaryHashFunctionFactoryProvider.INSTANCE,
             BinaryHashFunctionFamilyProvider.INSTANCE, BinaryComparatorFactoryProvider.INSTANCE,
             TypeTraitProvider.INSTANCE, BinaryBooleanInspector.FACTORY, BinaryIntegerInspector.FACTORY,
-            ADMPrinterFactoryProvider.INSTANCE, AqlMissingWriterFactory.INSTANCE, null,
+            ADMPrinterFactoryProvider.INSTANCE, MissingWriterFactory.INSTANCE, null,
             new LogicalExpressionJobGenToExpressionRuntimeProviderAdapter(QueryLogicalExpressionJobGen.INSTANCE),
             ExpressionTypeComputer.INSTANCE, null, null, null, null, GlobalConfig.DEFAULT_FRAME_SIZE,
null);
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0294b311/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlExpressionToPlanTranslator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlExpressionToPlanTranslator.java
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlExpressionToPlanTranslator.java
index 175ff96..de17448 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlExpressionToPlanTranslator.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlExpressionToPlanTranslator.java
@@ -83,7 +83,7 @@ class AqlExpressionToPlanTranslator extends LangExpressionToPlanTranslator
imple
             LogicalVariable pVar = context.newVar(fc.getPosVarExpr());
             // We set the positional variable type as INT64 type.
             returnedOp = new UnnestOperator(v, new MutableObject<ILogicalExpression>(makeUnnestExpression(eo.first)),
-                    pVar, BuiltinType.AINT64, new AqlPositionWriter());
+                    pVar, BuiltinType.AINT64, new PositionWriter());
         }
         returnedOp.getInputs().add(eo.second);
         return new Pair<>(returnedOp, v);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0294b311/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlPlusExpressionToPlanTranslator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlPlusExpressionToPlanTranslator.java
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlPlusExpressionToPlanTranslator.java
index bec5caf..d9136ac 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlPlusExpressionToPlanTranslator.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlPlusExpressionToPlanTranslator.java
@@ -330,7 +330,7 @@ public class AqlPlusExpressionToPlanTranslator extends AbstractLangTranslator
         } else {
             LogicalVariable pVar = context.newVar(fc.getPosVarExpr());
             returnedOp = new UnnestOperator(v, new MutableObject<ILogicalExpression>(makeUnnestExpression(eo.first)),
-                    pVar, BuiltinType.AINT32, new AqlPositionWriter());
+                    pVar, BuiltinType.AINT32, new PositionWriter());
         }
         returnedOp.getInputs().add(eo.second);
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0294b311/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlPositionWriter.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlPositionWriter.java
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlPositionWriter.java
deleted file mode 100644
index a0ce15b..0000000
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AqlPositionWriter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.translator;
-
-import java.io.DataOutput;
-import java.io.IOException;
-import java.io.Serializable;
-
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.hyracks.algebricks.runtime.base.IUnnestingPositionWriter;
-
-public class AqlPositionWriter implements IUnnestingPositionWriter, Serializable {
-    private static final long serialVersionUID = 1L;
-
-    @Override
-    public void write(DataOutput dataOutput, long position) throws IOException {
-        dataOutput.writeByte(BuiltinType.AINT64.getTypeTag().serialize());
-        dataOutput.writeLong(position);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0294b311/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/PositionWriter.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/PositionWriter.java
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/PositionWriter.java
new file mode 100644
index 0000000..6f8b64f
--- /dev/null
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/PositionWriter.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.translator;
+
+import java.io.DataOutput;
+import java.io.IOException;
+import java.io.Serializable;
+
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.hyracks.algebricks.runtime.base.IUnnestingPositionWriter;
+
+public class PositionWriter implements IUnnestingPositionWriter, Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public void write(DataOutput dataOutput, long position) throws IOException {
+        dataOutput.writeByte(BuiltinType.AINT64.getTypeTag().serialize());
+        dataOutput.writeLong(position);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0294b311/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/SqlppExpressionToPlanTranslator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/SqlppExpressionToPlanTranslator.java
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/SqlppExpressionToPlanTranslator.java
index c3403ee..5778369 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/SqlppExpressionToPlanTranslator.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/SqlppExpressionToPlanTranslator.java
@@ -257,7 +257,7 @@ class SqlppExpressionToPlanTranslator extends LangExpressionToPlanTranslator
imp
             // We set the positional variable type as INT64 type.
             unnestOp =
                     new UnnestOperator(fromVar, new MutableObject<ILogicalExpression>(makeUnnestExpression(eo.first)),
-                            pVar, BuiltinType.AINT64, new AqlPositionWriter());
+                            pVar, BuiltinType.AINT64, new PositionWriter());
         } else {
             unnestOp =
                     new UnnestOperator(fromVar, new MutableObject<ILogicalExpression>(makeUnnestExpression(eo.first)));
@@ -457,9 +457,9 @@ class SqlppExpressionToPlanTranslator extends LangExpressionToPlanTranslator
imp
             // We set the positional variable type as INT64 type.
             unnestOp = innerUnnest
                     ? new UnnestOperator(rightVar, new MutableObject<>(makeUnnestExpression(eo.first)),
pVar,
-                            BuiltinType.AINT64, new AqlPositionWriter())
+                            BuiltinType.AINT64, new PositionWriter())
                     : new LeftOuterUnnestOperator(rightVar, new MutableObject<>(makeUnnestExpression(eo.first)),
pVar,
-                            BuiltinType.AINT64, new AqlPositionWriter());
+                            BuiltinType.AINT64, new PositionWriter());
         } else {
             unnestOp = innerUnnest ? new UnnestOperator(rightVar, new MutableObject<>(makeUnnestExpression(eo.first)))
                     : new LeftOuterUnnestOperator(rightVar, new MutableObject<>(makeUnnestExpression(eo.first)));

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0294b311/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
index 16646d2..643ba71 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
@@ -42,11 +42,11 @@ import org.apache.asterix.common.exceptions.ACIDException;
 import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.compiler.provider.ILangCompilationProvider;
 import org.apache.asterix.compiler.provider.IRuleSetFactory;
-import org.apache.asterix.dataflow.data.common.AqlMergeAggregationExpressionFactory;
-import org.apache.asterix.dataflow.data.common.AqlMissableTypeComputer;
-import org.apache.asterix.dataflow.data.common.AqlPartialAggregationTypeComputer;
 import org.apache.asterix.dataflow.data.common.ConflictingTypeResolver;
 import org.apache.asterix.dataflow.data.common.ExpressionTypeComputer;
+import org.apache.asterix.dataflow.data.common.MergeAggregationExpressionFactory;
+import org.apache.asterix.dataflow.data.common.MissableTypeComputer;
+import org.apache.asterix.dataflow.data.common.PartialAggregationTypeComputer;
 import org.apache.asterix.formats.base.IDataFormat;
 import org.apache.asterix.jobgen.QueryLogicalExpressionJobGen;
 import org.apache.asterix.lang.common.base.IAstPrintVisitorFactory;
@@ -110,11 +110,11 @@ public class APIFramework {
         this.ruleSetFactory = compilationProvider.getRuleSetFactory();
     }
 
-    private static class AqlOptimizationContextFactory implements IOptimizationContextFactory
{
+    private static class OptimizationContextFactory implements IOptimizationContextFactory
{
 
-        public static final AqlOptimizationContextFactory INSTANCE = new AqlOptimizationContextFactory();
+        public static final OptimizationContextFactory INSTANCE = new OptimizationContextFactory();
 
-        private AqlOptimizationContextFactory() {
+        private OptimizationContextFactory() {
         }
 
         @Override
@@ -218,17 +218,17 @@ public class APIFramework {
         OptimizationConfUtil.getPhysicalOptimizationConfig().setMaxFramesForJoin(joinFrameLimit);
 
         HeuristicCompilerFactoryBuilder builder =
-                new HeuristicCompilerFactoryBuilder(AqlOptimizationContextFactory.INSTANCE);
+                new HeuristicCompilerFactoryBuilder(OptimizationContextFactory.INSTANCE);
         builder.setPhysicalOptimizationConfig(OptimizationConfUtil.getPhysicalOptimizationConfig());
         builder.setLogicalRewrites(ruleSetFactory.getLogicalRewrites());
         builder.setPhysicalRewrites(ruleSetFactory.getPhysicalRewrites());
         IDataFormat format = metadataProvider.getFormat();
         ICompilerFactory compilerFactory = builder.create();
         builder.setExpressionEvalSizeComputer(format.getExpressionEvalSizeComputer());
-        builder.setIMergeAggregationExpressionFactory(new AqlMergeAggregationExpressionFactory());
-        builder.setPartialAggregationTypeComputer(new AqlPartialAggregationTypeComputer());
+        builder.setIMergeAggregationExpressionFactory(new MergeAggregationExpressionFactory());
+        builder.setPartialAggregationTypeComputer(new PartialAggregationTypeComputer());
         builder.setExpressionTypeComputer(ExpressionTypeComputer.INSTANCE);
-        builder.setMissableTypeComputer(AqlMissableTypeComputer.INSTANCE);
+        builder.setMissableTypeComputer(MissableTypeComputer.INSTANCE);
         builder.setConflictingTypeResolver(ConflictingTypeResolver.INSTANCE);
 
         int parallelism = compilerProperties.getParallelism();

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0294b311/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlMergeAggregationExpressionFactory.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlMergeAggregationExpressionFactory.java
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlMergeAggregationExpressionFactory.java
deleted file mode 100644
index bd42fe1..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlMergeAggregationExpressionFactory.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.dataflow.data.common;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.lang3.mutable.Mutable;
-import org.apache.commons.lang3.mutable.MutableObject;
-
-import org.apache.asterix.om.functions.BuiltinFunctions;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.base.IOptimizationContext;
-import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IMergeAggregationExpressionFactory;
-import org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression;
-import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-
-public class AqlMergeAggregationExpressionFactory implements IMergeAggregationExpressionFactory
{
-
-    @Override
-    public ILogicalExpression createMergeAggregation(LogicalVariable originalProducedVar,
ILogicalExpression expr,
-            IOptimizationContext env) throws AlgebricksException {
-        AggregateFunctionCallExpression agg = (AggregateFunctionCallExpression) expr;
-        FunctionIdentifier fid = agg.getFunctionIdentifier();
-        VariableReferenceExpression tempVarExpr = new VariableReferenceExpression(originalProducedVar);
-        List<Mutable<ILogicalExpression>> arguments = new ArrayList<Mutable<ILogicalExpression>>();
-        Mutable<ILogicalExpression> mutableExpression = new MutableObject<ILogicalExpression>(tempVarExpr);
-        arguments.add(mutableExpression);
-        /**
-         * For global aggregate, the merge function is ALWAYS the same as the original aggregate
function.
-         */
-        FunctionIdentifier mergeFid = BuiltinFunctions.isGlobalAggregateFunction(fid) ? fid
-                : BuiltinFunctions.getIntermediateAggregateFunction(fid);
-        if (mergeFid == null) {
-            /**
-             * In this case, no merge function (unimplemented) for the local-side aggregate
function
-             */
-            return null;
-        }
-        ILogicalExpression aggExpr = BuiltinFunctions.makeAggregateFunctionExpression(mergeFid,
arguments);
-        return aggExpr;
-    }
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0294b311/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlMissableTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlMissableTypeComputer.java
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlMissableTypeComputer.java
deleted file mode 100644
index aa88ec9..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlMissableTypeComputer.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.dataflow.data.common;
-
-import org.apache.asterix.om.typecomputer.impl.TypeComputeUtils;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.types.TypeHelper;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IMissableTypeComputer;
-
-public class AqlMissableTypeComputer implements IMissableTypeComputer {
-
-    public static final AqlMissableTypeComputer INSTANCE = new AqlMissableTypeComputer();
-
-    private AqlMissableTypeComputer() {
-    }
-
-    @Override
-    public IAType makeMissableType(Object type) throws AlgebricksException {
-        IAType t = (IAType) type;
-        return AUnionType.createMissableType(t);
-    }
-
-    @Override
-    public boolean canBeMissing(Object type) {
-        IAType t = (IAType) type;
-        return TypeHelper.canBeMissing(t);
-    }
-
-    @Override
-    public Object getNonOptionalType(Object type) {
-        IAType t = (IAType) type;
-        return TypeComputeUtils.getActualType(t);
-    }
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0294b311/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlPartialAggregationTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlPartialAggregationTypeComputer.java
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlPartialAggregationTypeComputer.java
deleted file mode 100644
index ae2ea87..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlPartialAggregationTypeComputer.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.dataflow.data.common;
-
-import org.apache.asterix.om.functions.BuiltinFunctions;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IPartialAggregationTypeComputer;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class AqlPartialAggregationTypeComputer implements IPartialAggregationTypeComputer
{
-
-    @Override
-    public Object getType(ILogicalExpression expr, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        AggregateFunctionCallExpression agg = (AggregateFunctionCallExpression) expr;
-        FunctionIdentifier partialFid = agg.getFunctionIdentifier();
-        if (partialFid.equals(BuiltinFunctions.SERIAL_GLOBAL_AVG)) {
-            partialFid = BuiltinFunctions.SERIAL_LOCAL_AVG;
-        }
-        AggregateFunctionCallExpression partialAgg = BuiltinFunctions.makeAggregateFunctionExpression(partialFid,
-                agg.getArguments());
-        return getTypeForFunction(partialAgg, env, metadataProvider);
-    }
-
-    private Object getTypeForFunction(AbstractFunctionCallExpression expr, IVariableTypeEnvironment
env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        return BuiltinFunctions.getResultTypeComputer(expr.getFunctionIdentifier()).computeType(expr,
env,
-                metadataProvider);
-    }
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0294b311/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/MergeAggregationExpressionFactory.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/MergeAggregationExpressionFactory.java
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/MergeAggregationExpressionFactory.java
new file mode 100644
index 0000000..dfb1251
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/MergeAggregationExpressionFactory.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.common;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang3.mutable.Mutable;
+import org.apache.commons.lang3.mutable.MutableObject;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.base.IOptimizationContext;
+import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable;
+import org.apache.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IMergeAggregationExpressionFactory;
+import org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+
+public class MergeAggregationExpressionFactory implements IMergeAggregationExpressionFactory
{
+
+    @Override
+    public ILogicalExpression createMergeAggregation(LogicalVariable originalProducedVar,
ILogicalExpression expr,
+            IOptimizationContext env) throws AlgebricksException {
+        AggregateFunctionCallExpression agg = (AggregateFunctionCallExpression) expr;
+        FunctionIdentifier fid = agg.getFunctionIdentifier();
+        VariableReferenceExpression tempVarExpr = new VariableReferenceExpression(originalProducedVar);
+        List<Mutable<ILogicalExpression>> arguments = new ArrayList<Mutable<ILogicalExpression>>();
+        Mutable<ILogicalExpression> mutableExpression = new MutableObject<ILogicalExpression>(tempVarExpr);
+        arguments.add(mutableExpression);
+        /**
+         * For global aggregate, the merge function is ALWAYS the same as the original aggregate
function.
+         */
+        FunctionIdentifier mergeFid = BuiltinFunctions.isGlobalAggregateFunction(fid) ? fid
+                : BuiltinFunctions.getIntermediateAggregateFunction(fid);
+        if (mergeFid == null) {
+            /**
+             * In this case, no merge function (unimplemented) for the local-side aggregate
function
+             */
+            return null;
+        }
+        return BuiltinFunctions.makeAggregateFunctionExpression(mergeFid, arguments);
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0294b311/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/MissableTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/MissableTypeComputer.java
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/MissableTypeComputer.java
new file mode 100644
index 0000000..91b5d19
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/MissableTypeComputer.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.common;
+
+import org.apache.asterix.om.typecomputer.impl.TypeComputeUtils;
+import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.asterix.om.types.TypeHelper;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IMissableTypeComputer;
+
+public class MissableTypeComputer implements IMissableTypeComputer {
+
+    public static final MissableTypeComputer INSTANCE = new MissableTypeComputer();
+
+    private MissableTypeComputer() {
+    }
+
+    @Override
+    public IAType makeMissableType(Object type) throws AlgebricksException {
+        IAType t = (IAType) type;
+        return AUnionType.createMissableType(t);
+    }
+
+    @Override
+    public boolean canBeMissing(Object type) {
+        IAType t = (IAType) type;
+        return TypeHelper.canBeMissing(t);
+    }
+
+    @Override
+    public Object getNonOptionalType(Object type) {
+        IAType t = (IAType) type;
+        return TypeComputeUtils.getActualType(t);
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0294b311/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/PartialAggregationTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/PartialAggregationTypeComputer.java
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/PartialAggregationTypeComputer.java
new file mode 100644
index 0000000..1a73af3
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/PartialAggregationTypeComputer.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.common;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IPartialAggregationTypeComputer;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
+
+public class PartialAggregationTypeComputer implements IPartialAggregationTypeComputer {
+
+    @Override
+    public Object getType(ILogicalExpression expr, IVariableTypeEnvironment env,
+            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+        AggregateFunctionCallExpression agg = (AggregateFunctionCallExpression) expr;
+        FunctionIdentifier partialFid = agg.getFunctionIdentifier();
+        if (partialFid.equals(BuiltinFunctions.SERIAL_GLOBAL_AVG)) {
+            partialFid = BuiltinFunctions.SERIAL_LOCAL_AVG;
+        }
+        AggregateFunctionCallExpression partialAgg = BuiltinFunctions.makeAggregateFunctionExpression(partialFid,
+                agg.getArguments());
+        return getTypeForFunction(partialAgg, env, metadataProvider);
+    }
+
+    private Object getTypeForFunction(AbstractFunctionCallExpression expr, IVariableTypeEnvironment
env,
+            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+        return BuiltinFunctions.getResultTypeComputer(expr.getFunctionIdentifier()).computeType(expr,
env,
+                metadataProvider);
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0294b311/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/AqlMissingWriterFactory.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/AqlMissingWriterFactory.java
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/AqlMissingWriterFactory.java
deleted file mode 100644
index 38af613..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/AqlMissingWriterFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.dataflow.data.nontagged;
-
-import java.io.DataOutput;
-import java.io.IOException;
-
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.hyracks.api.dataflow.value.IMissingWriter;
-import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class AqlMissingWriterFactory implements IMissingWriterFactory {
-
-    private static final long serialVersionUID = 1L;
-    public static final AqlMissingWriterFactory INSTANCE = new AqlMissingWriterFactory();
-
-    private AqlMissingWriterFactory() {
-    }
-
-    @Override
-    public IMissingWriter createMissingWriter() {
-        return AqlMissingWriterFactory::writeMissing;
-    }
-
-    private static void writeMissing(DataOutput out) throws HyracksDataException {
-        try {
-            out.writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
-        } catch (IOException e) {
-            throw new HyracksDataException(e);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0294b311/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/MissingWriterFactory.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/MissingWriterFactory.java
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/MissingWriterFactory.java
new file mode 100644
index 0000000..db1cb95
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/MissingWriterFactory.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class MissingWriterFactory implements IMissingWriterFactory {
+
+    private static final long serialVersionUID = 1L;
+    public static final MissingWriterFactory INSTANCE = new MissingWriterFactory();
+
+    private MissingWriterFactory() {
+    }
+
+    @Override
+    public IMissingWriter createMissingWriter() {
+        return MissingWriterFactory::writeMissing;
+    }
+
+    private static void writeMissing(DataOutput out) throws HyracksDataException {
+        try {
+            out.writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
+        } catch (IOException e) {
+            throw new HyracksDataException(e);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/0294b311/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
index e6d98f9..00a147c 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
@@ -26,7 +26,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.asterix.common.config.GlobalConfig;
-import org.apache.asterix.dataflow.data.nontagged.AqlMissingWriterFactory;
+import org.apache.asterix.dataflow.data.nontagged.MissingWriterFactory;
 import org.apache.asterix.formats.base.IDataFormat;
 import org.apache.asterix.formats.nontagged.ADMPrinterFactoryProvider;
 import org.apache.asterix.formats.nontagged.BinaryBooleanInspector;
@@ -670,7 +670,7 @@ public class NonTaggedDataFormat implements IDataFormat {
 
     @Override
     public IMissingWriterFactory getMissingWriterFactory() {
-        return AqlMissingWriterFactory.INSTANCE;
+        return MissingWriterFactory.INSTANCE;
     }
 
     @Override


Mime
View raw message