You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by dl...@apache.org on 2018/10/25 21:32:07 UTC
[03/11] asterixdb git commit: [ASTERIXDB-2459][FUN] Add var() and
var_pop() aggregate function
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
index 4813be9..3fb03a1 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java
@@ -490,6 +490,21 @@ public class BuiltinFunctions {
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-intermediate-stddev_pop", 1);
public static final FunctionIdentifier LOCAL_STDDEV_POP =
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-local-stddev_pop", 1);
+ public static final FunctionIdentifier VAR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-var", 1);
+ public static final FunctionIdentifier GLOBAL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-global-var", 1);
+ public static final FunctionIdentifier INTERMEDIATE_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-intermediate-var", 1);
+ public static final FunctionIdentifier LOCAL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-local-var", 1);
+ public static final FunctionIdentifier VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-var_pop", 1);
+ public static final FunctionIdentifier GLOBAL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-global-var_pop", 1);
+ public static final FunctionIdentifier INTERMEDIATE_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-intermediate-var_pop", 1);
+ public static final FunctionIdentifier LOCAL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-local-var_pop", 1);
public static final FunctionIdentifier SCALAR_AVG = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "avg", 1);
public static final FunctionIdentifier SCALAR_COUNT =
@@ -515,6 +530,17 @@ public class BuiltinFunctions {
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-stddev_pop", 1);
public static final FunctionIdentifier SCALAR_LOCAL_STDDEV_POP =
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-stddev_pop", 1);
+ public static final FunctionIdentifier SCALAR_VAR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "var", 1);
+ public static final FunctionIdentifier SCALAR_GLOBAL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-var", 1);
+ public static final FunctionIdentifier SCALAR_LOCAL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-var", 1);
+ public static final FunctionIdentifier SCALAR_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "var_pop", 1);
+ public static final FunctionIdentifier SCALAR_GLOBAL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-var_pop", 1);
+ public static final FunctionIdentifier SCALAR_LOCAL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-var_pop", 1);
// serializable aggregate functions
public static final FunctionIdentifier SERIAL_AVG =
@@ -547,6 +573,22 @@ public class BuiltinFunctions {
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-stddev_pop-serial", 1);
public static final FunctionIdentifier SERIAL_INTERMEDIATE_STDDEV_POP =
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "intermediate-stddev_pop-serial", 1);
+ public static final FunctionIdentifier SERIAL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "var-serial", 1);
+ public static final FunctionIdentifier SERIAL_GLOBAL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-var-serial", 1);
+ public static final FunctionIdentifier SERIAL_LOCAL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-var-serial", 1);
+ public static final FunctionIdentifier SERIAL_INTERMEDIATE_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "intermediate-var-serial", 1);
+ public static final FunctionIdentifier SERIAL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "var_pop-serial", 1);
+ public static final FunctionIdentifier SERIAL_GLOBAL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-var_pop-serial", 1);
+ public static final FunctionIdentifier SERIAL_LOCAL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-var_pop-serial", 1);
+ public static final FunctionIdentifier SERIAL_INTERMEDIATE_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "intermediate-var_pop-serial", 1);
// distinct aggregate functions
public static final FunctionIdentifier COUNT_DISTINCT =
@@ -577,6 +619,14 @@ public class BuiltinFunctions {
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-stddev_pop-distinct", 1);
public static final FunctionIdentifier SCALAR_STDDEV_POP_DISTINCT =
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "stddev_pop-distinct", 1);
+ public static final FunctionIdentifier VAR_DISTINCT =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-var-distinct", 1);
+ public static final FunctionIdentifier SCALAR_VAR_DISTINCT =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "var-distinct", 1);
+ public static final FunctionIdentifier VAR_POP_DISTINCT =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-var_pop-distinct", 1);
+ public static final FunctionIdentifier SCALAR_VAR_POP_DISTINCT =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "var_pop-distinct", 1);
// sql aggregate functions
public static final FunctionIdentifier SQL_AVG =
@@ -617,6 +667,22 @@ public class BuiltinFunctions {
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-global-sql-stddev_pop", 1);
public static final FunctionIdentifier LOCAL_SQL_STDDEV_POP =
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-local-sql-stddev_pop", 1);
+ public static final FunctionIdentifier SQL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-sql-var", 1);
+ public static final FunctionIdentifier INTERMEDIATE_SQL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "intermediate-agg-sql-var", 1);
+ public static final FunctionIdentifier GLOBAL_SQL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-global-sql-var", 1);
+ public static final FunctionIdentifier LOCAL_SQL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-local-sql-var", 1);
+ public static final FunctionIdentifier SQL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-sql-var_pop", 1);
+ public static final FunctionIdentifier INTERMEDIATE_SQL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "intermediate-agg-sql-var_pop", 1);
+ public static final FunctionIdentifier GLOBAL_SQL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-global-sql-var_pop", 1);
+ public static final FunctionIdentifier LOCAL_SQL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-local-sql-var_pop", 1);
public static final FunctionIdentifier SCALAR_SQL_AVG =
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sql-avg", 1);
@@ -644,6 +710,18 @@ public class BuiltinFunctions {
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-sql-stddev_pop", 1);
public static final FunctionIdentifier SCALAR_LOCAL_SQL_STDDEV_POP =
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-sql-stddev_pop", 1);
+ public static final FunctionIdentifier SCALAR_SQL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sql-var", 1);
+ public static final FunctionIdentifier SCALAR_GLOBAL_SQL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-sql-var", 1);
+ public static final FunctionIdentifier SCALAR_LOCAL_SQL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-sql-var", 1);
+ public static final FunctionIdentifier SCALAR_SQL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sql-var_pop", 1);
+ public static final FunctionIdentifier SCALAR_GLOBAL_SQL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-sql-var_pop", 1);
+ public static final FunctionIdentifier SCALAR_LOCAL_SQL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-sql-var_pop", 1);
// serializable sql aggregate functions
public static final FunctionIdentifier SERIAL_SQL_AVG =
@@ -676,6 +754,22 @@ public class BuiltinFunctions {
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "intermediate-sql-stddev_pop-serial", 1);
public static final FunctionIdentifier SERIAL_LOCAL_SQL_STDDEV_POP =
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-sql-stddev_pop-serial", 1);
+ public static final FunctionIdentifier SERIAL_SQL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sql-var-serial", 1);
+ public static final FunctionIdentifier SERIAL_GLOBAL_SQL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-sql-var-serial", 1);
+ public static final FunctionIdentifier SERIAL_INTERMEDIATE_SQL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "intermediate-sql-var-serial", 1);
+ public static final FunctionIdentifier SERIAL_LOCAL_SQL_VAR =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-sql-var-serial", 1);
+ public static final FunctionIdentifier SERIAL_SQL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sql-var_pop-serial", 1);
+ public static final FunctionIdentifier SERIAL_GLOBAL_SQL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "global-sql-var_pop-serial", 1);
+ public static final FunctionIdentifier SERIAL_INTERMEDIATE_SQL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "intermediate-sql-var_pop-serial", 1);
+ public static final FunctionIdentifier SERIAL_LOCAL_SQL_VAR_POP =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "local-sql-var_pop-serial", 1);
// distinct sql aggregate functions
public static final FunctionIdentifier SQL_COUNT_DISTINCT =
@@ -706,6 +800,14 @@ public class BuiltinFunctions {
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-sql-stddev_pop-distinct", 1);
public static final FunctionIdentifier SCALAR_SQL_STDDEV_POP_DISTINCT =
new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sql-stddev_pop-distinct", 1);
+ public static final FunctionIdentifier SQL_VAR_DISTINCT =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-sql-var-distinct", 1);
+ public static final FunctionIdentifier SCALAR_SQL_VAR_DISTINCT =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sql-var-distinct", 1);
+ public static final FunctionIdentifier SQL_VAR_POP_DISTINCT =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "agg-sql-var_pop-distinct", 1);
+ public static final FunctionIdentifier SCALAR_SQL_VAR_POP_DISTINCT =
+ new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "sql-var_pop-distinct", 1);
// unnesting functions
public static final FunctionIdentifier SCAN_COLLECTION =
@@ -1451,6 +1553,12 @@ public class BuiltinFunctions {
addPrivateFunction(LOCAL_STDDEV_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
addFunction(STDDEV_POP, NullableDoubleTypeComputer.INSTANCE, true);
addPrivateFunction(GLOBAL_STDDEV_POP, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(LOCAL_VAR, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+ addFunction(VAR, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(GLOBAL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(LOCAL_VAR_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+ addFunction(VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(GLOBAL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
addPrivateFunction(SERIAL_SQL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
addPrivateFunction(SERIAL_SQL_COUNT, AInt64TypeComputer.INSTANCE, true);
@@ -1483,6 +1591,22 @@ public class BuiltinFunctions {
addPrivateFunction(SERIAL_GLOBAL_SQL_STDDEV_POP, NullableDoubleTypeComputer.INSTANCE, true);
addPrivateFunction(SERIAL_LOCAL_SQL_STDDEV_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
addPrivateFunction(SERIAL_INTERMEDIATE_SQL_STDDEV_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+ addFunction(SCALAR_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SCALAR_GLOBAL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SCALAR_LOCAL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(INTERMEDIATE_VAR, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_SQL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_GLOBAL_SQL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_LOCAL_SQL_VAR, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_INTERMEDIATE_SQL_VAR, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+ addFunction(SCALAR_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SCALAR_GLOBAL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SCALAR_LOCAL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(INTERMEDIATE_VAR_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_SQL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_GLOBAL_SQL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_LOCAL_SQL_VAR_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_INTERMEDIATE_SQL_VAR_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
addFunction(SQL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
addPrivateFunction(GLOBAL_SQL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
@@ -1517,6 +1641,20 @@ public class BuiltinFunctions {
addFunction(SCALAR_SQL_STDDEV_POP, NullableDoubleTypeComputer.INSTANCE, true);
addPrivateFunction(SCALAR_GLOBAL_SQL_STDDEV_POP, NullableDoubleTypeComputer.INSTANCE, true);
addPrivateFunction(SCALAR_LOCAL_SQL_STDDEV_POP, NullableDoubleTypeComputer.INSTANCE, true);
+ addFunction(SQL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(GLOBAL_SQL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(LOCAL_SQL_VAR, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+ addPrivateFunction(INTERMEDIATE_SQL_VAR, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+ addFunction(SCALAR_SQL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SCALAR_GLOBAL_SQL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SCALAR_LOCAL_SQL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+ addFunction(SQL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(GLOBAL_SQL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(LOCAL_SQL_VAR_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+ addPrivateFunction(INTERMEDIATE_SQL_VAR_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+ addFunction(SCALAR_SQL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SCALAR_GLOBAL_SQL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SCALAR_LOCAL_SQL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
addPrivateFunction(SERIAL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
addPrivateFunction(SERIAL_COUNT, AInt64TypeComputer.INSTANCE, true);
@@ -1533,6 +1671,14 @@ public class BuiltinFunctions {
addPrivateFunction(SERIAL_GLOBAL_STDDEV_POP, NullableDoubleTypeComputer.INSTANCE, true);
addPrivateFunction(SERIAL_LOCAL_STDDEV_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
addPrivateFunction(SERIAL_INTERMEDIATE_STDDEV_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_GLOBAL_VAR, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_LOCAL_VAR, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_INTERMEDIATE_VAR, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_GLOBAL_VAR_POP, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_LOCAL_VAR_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_INTERMEDIATE_VAR_POP, LocalSingleVarStatisticsTypeComputer.INSTANCE, true);
// Distinct aggregate functions
@@ -1571,6 +1717,16 @@ public class BuiltinFunctions {
addFunction(SQL_STDDEV_POP_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
addFunction(SCALAR_SQL_STDDEV_POP_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+ addFunction(VAR_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+ addFunction(SCALAR_VAR_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+ addFunction(SQL_VAR_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+ addFunction(SCALAR_SQL_VAR_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+
+ addFunction(VAR_POP_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+ addFunction(SCALAR_VAR_POP_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+ addFunction(SQL_VAR_POP_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+ addFunction(SCALAR_SQL_VAR_POP_DISTINCT, NullableDoubleTypeComputer.INSTANCE, true);
+
// Similarity functions
addFunction(EDIT_DISTANCE_CONTAINS, OrderedListOfAnyTypeComputer.INSTANCE, true);
addFunction(SIMILARITY_JACCARD, AFloatTypeComputer.INSTANCE, true);
@@ -1957,6 +2113,70 @@ public class BuiltinFunctions {
addDistinctAgg(STDDEV_POP_DISTINCT, SCALAR_STDDEV_POP);
addScalarAgg(STDDEV_POP_DISTINCT, SCALAR_STDDEV_POP_DISTINCT);
+ // VAR
+
+ addAgg(VAR);
+ addAgg(LOCAL_VAR);
+ addAgg(GLOBAL_VAR);
+ addLocalAgg(VAR, LOCAL_VAR);
+ addIntermediateAgg(VAR, INTERMEDIATE_VAR);
+ addIntermediateAgg(LOCAL_VAR, INTERMEDIATE_VAR);
+ addIntermediateAgg(GLOBAL_VAR, INTERMEDIATE_VAR);
+ addGlobalAgg(VAR, GLOBAL_VAR);
+
+ addScalarAgg(VAR, SCALAR_VAR);
+ addScalarAgg(GLOBAL_VAR, SCALAR_GLOBAL_VAR);
+ addScalarAgg(LOCAL_VAR, SCALAR_LOCAL_VAR);
+
+ addSerialAgg(VAR, SERIAL_VAR);
+ addSerialAgg(LOCAL_VAR, SERIAL_LOCAL_VAR);
+ addSerialAgg(GLOBAL_VAR, SERIAL_GLOBAL_VAR);
+ addAgg(SERIAL_VAR);
+ addAgg(SERIAL_LOCAL_VAR);
+ addAgg(SERIAL_GLOBAL_VAR);
+ addLocalAgg(SERIAL_VAR, SERIAL_LOCAL_VAR);
+ addIntermediateAgg(SERIAL_VAR, SERIAL_INTERMEDIATE_VAR);
+ addIntermediateAgg(SERIAL_LOCAL_VAR, SERIAL_INTERMEDIATE_VAR);
+ addIntermediateAgg(SERIAL_GLOBAL_VAR, SERIAL_INTERMEDIATE_VAR);
+ addGlobalAgg(SERIAL_VAR, SERIAL_GLOBAL_VAR);
+
+ // VAR DISTINCT
+
+ addDistinctAgg(VAR_DISTINCT, SCALAR_VAR);
+ addScalarAgg(VAR_DISTINCT, SCALAR_VAR_DISTINCT);
+
+ // VAR_POP
+
+ addAgg(VAR_POP);
+ addAgg(LOCAL_VAR_POP);
+ addAgg(GLOBAL_VAR_POP);
+ addLocalAgg(VAR_POP, LOCAL_VAR_POP);
+ addIntermediateAgg(VAR_POP, INTERMEDIATE_VAR_POP);
+ addIntermediateAgg(LOCAL_VAR_POP, INTERMEDIATE_VAR_POP);
+ addIntermediateAgg(GLOBAL_VAR_POP, INTERMEDIATE_VAR_POP);
+ addGlobalAgg(VAR_POP, GLOBAL_VAR_POP);
+
+ addScalarAgg(VAR_POP, SCALAR_VAR_POP);
+ addScalarAgg(GLOBAL_VAR_POP, SCALAR_GLOBAL_VAR_POP);
+ addScalarAgg(LOCAL_VAR_POP, SCALAR_LOCAL_VAR_POP);
+
+ addSerialAgg(VAR_POP, SERIAL_VAR_POP);
+ addSerialAgg(LOCAL_VAR_POP, SERIAL_LOCAL_VAR_POP);
+ addSerialAgg(GLOBAL_VAR_POP, SERIAL_GLOBAL_VAR_POP);
+ addAgg(SERIAL_VAR_POP);
+ addAgg(SERIAL_LOCAL_VAR_POP);
+ addAgg(SERIAL_GLOBAL_VAR_POP);
+ addLocalAgg(SERIAL_VAR_POP, SERIAL_LOCAL_VAR_POP);
+ addIntermediateAgg(SERIAL_VAR_POP, SERIAL_INTERMEDIATE_VAR_POP);
+ addIntermediateAgg(SERIAL_LOCAL_VAR_POP, SERIAL_INTERMEDIATE_VAR_POP);
+ addIntermediateAgg(SERIAL_GLOBAL_VAR_POP, SERIAL_INTERMEDIATE_VAR_POP);
+ addGlobalAgg(SERIAL_VAR_POP, SERIAL_GLOBAL_VAR_POP);
+
+ // VAR_POP DISTINCT
+
+ addDistinctAgg(VAR_POP_DISTINCT, SCALAR_VAR_POP);
+ addScalarAgg(VAR_POP_DISTINCT, SCALAR_VAR_POP_DISTINCT);
+
// FIRST_ELEMENT
addAgg(SCALAR_FIRST_ELEMENT);
@@ -2103,6 +2323,60 @@ public class BuiltinFunctions {
addIntermediateAgg(SERIAL_GLOBAL_SQL_STDDEV_POP, SERIAL_INTERMEDIATE_SQL_STDDEV_POP);
addGlobalAgg(SERIAL_SQL_STDDEV_POP, SERIAL_GLOBAL_SQL_STDDEV_POP);
+ // SQL VAR
+
+ addAgg(SQL_VAR);
+ addAgg(LOCAL_SQL_VAR);
+ addAgg(GLOBAL_SQL_VAR);
+ addLocalAgg(SQL_VAR, LOCAL_SQL_VAR);
+ addIntermediateAgg(SQL_VAR, INTERMEDIATE_SQL_VAR);
+ addIntermediateAgg(LOCAL_SQL_VAR, INTERMEDIATE_SQL_VAR);
+ addIntermediateAgg(GLOBAL_SQL_VAR, INTERMEDIATE_SQL_VAR);
+ addGlobalAgg(SQL_VAR, GLOBAL_SQL_VAR);
+
+ addScalarAgg(SQL_VAR, SCALAR_SQL_VAR);
+ addScalarAgg(GLOBAL_SQL_VAR, SCALAR_GLOBAL_SQL_VAR);
+ addScalarAgg(LOCAL_SQL_VAR, SCALAR_LOCAL_SQL_VAR);
+
+ addSerialAgg(SQL_VAR, SERIAL_SQL_VAR);
+ addSerialAgg(LOCAL_SQL_VAR, SERIAL_LOCAL_SQL_VAR);
+ addSerialAgg(GLOBAL_SQL_VAR, SERIAL_GLOBAL_SQL_VAR);
+ addAgg(SERIAL_SQL_VAR);
+ addAgg(SERIAL_LOCAL_SQL_VAR);
+ addAgg(SERIAL_GLOBAL_SQL_VAR);
+ addLocalAgg(SERIAL_SQL_VAR, SERIAL_LOCAL_SQL_VAR);
+ addIntermediateAgg(SERIAL_SQL_VAR, SERIAL_INTERMEDIATE_SQL_VAR);
+ addIntermediateAgg(SERIAL_LOCAL_SQL_VAR, SERIAL_INTERMEDIATE_SQL_VAR);
+ addIntermediateAgg(SERIAL_GLOBAL_SQL_VAR, SERIAL_INTERMEDIATE_SQL_VAR);
+ addGlobalAgg(SERIAL_SQL_VAR, SERIAL_GLOBAL_SQL_VAR);
+
+ // SQL VAR_POP
+
+ addAgg(SQL_VAR_POP);
+ addAgg(LOCAL_SQL_VAR_POP);
+ addAgg(GLOBAL_SQL_VAR_POP);
+ addLocalAgg(SQL_VAR_POP, LOCAL_SQL_VAR_POP);
+ addIntermediateAgg(SQL_VAR_POP, INTERMEDIATE_SQL_VAR_POP);
+ addIntermediateAgg(LOCAL_SQL_VAR_POP, INTERMEDIATE_SQL_VAR_POP);
+ addIntermediateAgg(GLOBAL_SQL_VAR_POP, INTERMEDIATE_SQL_VAR_POP);
+ addGlobalAgg(SQL_VAR_POP, GLOBAL_SQL_VAR_POP);
+
+ addScalarAgg(SQL_VAR_POP, SCALAR_SQL_VAR_POP);
+ addScalarAgg(GLOBAL_SQL_VAR_POP, SCALAR_GLOBAL_SQL_VAR_POP);
+ addScalarAgg(LOCAL_SQL_VAR_POP, SCALAR_LOCAL_SQL_VAR_POP);
+
+ addSerialAgg(SQL_VAR_POP, SERIAL_SQL_VAR_POP);
+ addSerialAgg(LOCAL_SQL_VAR_POP, SERIAL_LOCAL_SQL_VAR_POP);
+ addSerialAgg(GLOBAL_SQL_VAR_POP, SERIAL_GLOBAL_SQL_VAR_POP);
+ addAgg(SERIAL_SQL_VAR_POP);
+ addAgg(SERIAL_LOCAL_SQL_VAR_POP);
+ addAgg(SERIAL_GLOBAL_SQL_VAR_POP);
+ addLocalAgg(SERIAL_SQL_VAR_POP, SERIAL_LOCAL_SQL_VAR_POP);
+ addIntermediateAgg(SERIAL_SQL_VAR_POP, SERIAL_INTERMEDIATE_SQL_VAR_POP);
+ addIntermediateAgg(SERIAL_LOCAL_SQL_VAR_POP, SERIAL_INTERMEDIATE_SQL_VAR_POP);
+ addIntermediateAgg(SERIAL_GLOBAL_SQL_VAR_POP, SERIAL_INTERMEDIATE_SQL_VAR_POP);
+ addGlobalAgg(SERIAL_SQL_VAR_POP, SERIAL_GLOBAL_SQL_VAR_POP);
+
// SQL AVG DISTINCT
addDistinctAgg(SQL_AVG_DISTINCT, SCALAR_SQL_AVG);
@@ -2118,6 +2392,16 @@ public class BuiltinFunctions {
addDistinctAgg(SQL_STDDEV_POP_DISTINCT, SCALAR_SQL_STDDEV_POP);
addScalarAgg(SQL_STDDEV_POP_DISTINCT, SCALAR_SQL_STDDEV_POP_DISTINCT);
+ // SQL VAR DISTINCT
+
+ addDistinctAgg(SQL_VAR_DISTINCT, SCALAR_SQL_VAR);
+ addScalarAgg(SQL_VAR_DISTINCT, SCALAR_SQL_VAR_DISTINCT);
+
+ // SQL VAR_POP DISTINCT
+
+ addDistinctAgg(SQL_VAR_POP_DISTINCT, SCALAR_SQL_VAR_POP);
+ addScalarAgg(SQL_VAR_POP_DISTINCT, SCALAR_SQL_VAR_POP_DISTINCT);
+
// SQL COUNT
addAgg(SQL_COUNT);
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarAggregateDescriptor.java
new file mode 100644
index 0000000..853aec3
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarAggregateDescriptor.java
@@ -0,0 +1,48 @@
+/*
+ * 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.runtime.aggregates.scalar;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.std.SqlVarAggregateDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+
+public class ScalarSqlVarAggregateDescriptor extends AbstractScalarAggregateDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ public final static FunctionIdentifier FID = BuiltinFunctions.SCALAR_SQL_VAR;
+
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new ScalarSqlVarAggregateDescriptor(SqlVarAggregateDescriptor.FACTORY.createFunctionDescriptor());
+ }
+ };
+
+ private ScalarSqlVarAggregateDescriptor(IFunctionDescriptor aggFuncDesc) {
+ super(aggFuncDesc);
+ }
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return FID;
+ }
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..072a9bd
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarSqlVarPopAggregateDescriptor.java
@@ -0,0 +1,49 @@
+/*
+ * 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.runtime.aggregates.scalar;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.std.SqlVarPopAggregateDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+
+public class ScalarSqlVarPopAggregateDescriptor extends AbstractScalarAggregateDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ public final static FunctionIdentifier FID = BuiltinFunctions.SCALAR_SQL_VAR_POP;
+
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new ScalarSqlVarPopAggregateDescriptor(
+ SqlVarPopAggregateDescriptor.FACTORY.createFunctionDescriptor());
+ }
+ };
+
+ private ScalarSqlVarPopAggregateDescriptor(IFunctionDescriptor aggFuncDesc) {
+ super(aggFuncDesc);
+ }
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return FID;
+ }
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarAggregateDescriptor.java
new file mode 100644
index 0000000..73a5dda
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarAggregateDescriptor.java
@@ -0,0 +1,48 @@
+/*
+ * 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.runtime.aggregates.scalar;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.std.VarAggregateDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+
+public class ScalarVarAggregateDescriptor extends AbstractScalarAggregateDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ public final static FunctionIdentifier FID = BuiltinFunctions.SCALAR_VAR;
+
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new ScalarVarAggregateDescriptor(VarAggregateDescriptor.FACTORY.createFunctionDescriptor());
+ }
+ };
+
+ private ScalarVarAggregateDescriptor(IFunctionDescriptor aggFuncDesc) {
+ super(aggFuncDesc);
+ }
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return FID;
+ }
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..d843a70
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/scalar/ScalarVarPopAggregateDescriptor.java
@@ -0,0 +1,48 @@
+/*
+ * 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.runtime.aggregates.scalar;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.std.VarPopAggregateDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+
+public class ScalarVarPopAggregateDescriptor extends AbstractScalarAggregateDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ public final static FunctionIdentifier FID = BuiltinFunctions.SCALAR_VAR_POP;
+
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new ScalarVarPopAggregateDescriptor(VarPopAggregateDescriptor.FACTORY.createFunctionDescriptor());
+ }
+ };
+
+ private ScalarVarPopAggregateDescriptor(IFunctionDescriptor aggFuncDesc) {
+ super(aggFuncDesc);
+ }
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return FID;
+ }
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableSingleVariableStatisticsAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableSingleVariableStatisticsAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableSingleVariableStatisticsAggregateFunction.java
index d537043..ec03472 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableSingleVariableStatisticsAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableSingleVariableStatisticsAggregateFunction.java
@@ -289,6 +289,23 @@ public abstract class AbstractSerializableSingleVariableStatisticsAggregateFunct
}
}
+ protected void finishVarFinalResults(byte[] state, int start, int len, DataOutput result, int delta)
+ throws HyracksDataException {
+ double m2 = BufferSerDeUtil.getDouble(state, start + M2_OFFSET);
+ long count = BufferSerDeUtil.getLong(state, start + COUNT_OFFSET);
+ ATypeTag aggType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(state[start + AGG_TYPE_OFFSET]);
+ try {
+ if (count <= 1 || aggType == ATypeTag.NULL) {
+ nullSerde.serialize(ANull.NULL, result);
+ } else {
+ aDouble.setValue(m2 / (count - delta));
+ doubleSerde.serialize(aDouble, result);
+ }
+ } catch (IOException e) {
+ throw HyracksDataException.create(e);
+ }
+ }
+
protected boolean skipStep(byte[] state, int start) {
return false;
}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarAggregateDescriptor.java
new file mode 100644
index 0000000..878b8ce
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarAggregateDescriptor.java
@@ -0,0 +1,63 @@
+/*
+ * 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.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableGlobalSqlVarAggregateDescriptor
+ extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new SerializableGlobalSqlVarAggregateDescriptor();
+ }
+ };
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return BuiltinFunctions.SERIAL_GLOBAL_SQL_VAR;
+ }
+
+ @Override
+ public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+ final IScalarEvaluatorFactory[] args) {
+ return new ISerializedAggregateEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+ throws HyracksDataException {
+ return new SerializableGlobalSqlVarAggregateFunction(args, ctx, false, sourceLoc);
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarAggregateFunction.java
new file mode 100644
index 0000000..c00fee3
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarAggregateFunction.java
@@ -0,0 +1,77 @@
+/*
+ * 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.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+import java.io.DataOutput;
+
+public class SerializableGlobalSqlVarAggregateFunction
+ extends AbstractSerializableSingleVariableStatisticsAggregateFunction {
+
+ private final boolean isPop;
+ private final int delta;
+
+ public SerializableGlobalSqlVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context,
+ boolean isPop, SourceLocation sourceLoc) throws HyracksDataException {
+ super(args, context, sourceLoc);
+ this.isPop = isPop;
+ if (isPop) {
+ delta = 0;
+ } else {
+ delta = 1;
+ }
+ }
+
+ @Override
+ public void step(IFrameTupleReference tuple, byte[] state, int start, int len) throws HyracksDataException {
+ processPartialResults(tuple, state, start, len);
+ }
+
+ @Override
+ public void finish(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+ finishVarFinalResults(state, start, len, result, delta);
+ }
+
+ @Override
+ public void finishPartial(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+ finishPartialResults(state, start, len, result);
+ }
+
+ @Override
+ protected void processNull(byte[] state, int start) {
+ }
+
+ @Override
+ protected FunctionIdentifier getFunctionIdentifier() {
+ if (isPop) {
+ return BuiltinFunctions.VAR_POP;
+ } else {
+ return BuiltinFunctions.VAR;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..f3f1c8c
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalSqlVarPopAggregateDescriptor.java
@@ -0,0 +1,63 @@
+/*
+ * 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.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableGlobalSqlVarPopAggregateDescriptor
+ extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new SerializableGlobalSqlVarPopAggregateDescriptor();
+ }
+ };
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return BuiltinFunctions.SERIAL_GLOBAL_SQL_VAR_POP;
+ }
+
+ @Override
+ public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+ final IScalarEvaluatorFactory[] args) {
+ return new ISerializedAggregateEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+ throws HyracksDataException {
+ return new SerializableGlobalSqlVarAggregateFunction(args, ctx, true, sourceLoc);
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarAggregateDescriptor.java
new file mode 100644
index 0000000..f0130ec
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarAggregateDescriptor.java
@@ -0,0 +1,62 @@
+/*
+ * 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.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableGlobalVarAggregateDescriptor extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new SerializableGlobalVarAggregateDescriptor();
+ }
+ };
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return BuiltinFunctions.SERIAL_GLOBAL_VAR;
+ }
+
+ @Override
+ public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+ final IScalarEvaluatorFactory[] args) {
+ return new ISerializedAggregateEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+ throws HyracksDataException {
+ return new SerializableGlobalVarAggregateFunction(args, ctx, false, sourceLoc);
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarAggregateFunction.java
new file mode 100644
index 0000000..4f33735
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarAggregateFunction.java
@@ -0,0 +1,86 @@
+/*
+ * 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.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+import java.io.DataOutput;
+
+public class SerializableGlobalVarAggregateFunction
+ extends AbstractSerializableSingleVariableStatisticsAggregateFunction {
+
+ private final boolean isPop;
+ private final int delta;
+
+ public SerializableGlobalVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context,
+ boolean isPop, SourceLocation sourceLoc) throws HyracksDataException {
+ super(args, context, sourceLoc);
+ this.isPop = isPop;
+ if (isPop) {
+ delta = 0;
+ } else {
+ delta = 1;
+ }
+ }
+
+ @Override
+ public void step(IFrameTupleReference tuple, byte[] state, int start, int len) throws HyracksDataException {
+ processPartialResults(tuple, state, start, len);
+ }
+
+ @Override
+ public void finish(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+ finishVarFinalResults(state, start, len, result, delta);
+ }
+
+ @Override
+ public void finishPartial(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+ finishPartialResults(state, start, len, result);
+ }
+
+ @Override
+ protected void processNull(byte[] state, int start) {
+ state[start + AGG_TYPE_OFFSET] = ATypeTag.SERIALIZED_NULL_TYPE_TAG;
+ }
+
+ @Override
+ protected boolean skipStep(byte[] state, int start) {
+ ATypeTag aggType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(state[start + AGG_TYPE_OFFSET]);
+ return aggType == ATypeTag.NULL;
+ }
+
+ @Override
+ protected FunctionIdentifier getFunctionIdentifier() {
+ if (isPop) {
+ return BuiltinFunctions.VAR_POP;
+ } else {
+ return BuiltinFunctions.VAR;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..6a42614
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalVarPopAggregateDescriptor.java
@@ -0,0 +1,63 @@
+/*
+ * 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.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableGlobalVarPopAggregateDescriptor
+ extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new SerializableGlobalVarPopAggregateDescriptor();
+ }
+ };
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return BuiltinFunctions.SERIAL_GLOBAL_VAR_POP;
+ }
+
+ @Override
+ public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+ final IScalarEvaluatorFactory[] args) {
+ return new ISerializedAggregateEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+ throws HyracksDataException {
+ return new SerializableGlobalVarAggregateFunction(args, ctx, true, sourceLoc);
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarAggregateDescriptor.java
new file mode 100644
index 0000000..b158e1a
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarAggregateDescriptor.java
@@ -0,0 +1,63 @@
+/*
+ * 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.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableIntermediateSqlVarAggregateDescriptor
+ extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new SerializableIntermediateSqlVarAggregateDescriptor();
+ }
+ };
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return BuiltinFunctions.SERIAL_INTERMEDIATE_SQL_VAR;
+ }
+
+ @Override
+ public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+ final IScalarEvaluatorFactory[] args) {
+ return new ISerializedAggregateEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+ throws HyracksDataException {
+ return new SerializableIntermediateSqlVarAggregateFunction(args, ctx, false, sourceLoc);
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarAggregateFunction.java
new file mode 100644
index 0000000..c14dd54
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarAggregateFunction.java
@@ -0,0 +1,70 @@
+/*
+ * 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.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+import java.io.DataOutput;
+
+public class SerializableIntermediateSqlVarAggregateFunction
+ extends AbstractSerializableSingleVariableStatisticsAggregateFunction {
+
+ private final boolean isPop;
+
+ public SerializableIntermediateSqlVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context,
+ boolean isPop, SourceLocation sourceLoc) throws HyracksDataException {
+ super(args, context, sourceLoc);
+ this.isPop = isPop;
+ }
+
+ @Override
+ public void step(IFrameTupleReference tuple, byte[] state, int start, int len) throws HyracksDataException {
+ processPartialResults(tuple, state, start, len);
+ }
+
+ @Override
+ public void finish(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+ finishPartialResults(state, start, len, result);
+ }
+
+ @Override
+ public void finishPartial(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+ finishPartialResults(state, start, len, result);
+ }
+
+ @Override
+ protected void processNull(byte[] state, int start) {
+ }
+
+ @Override
+ protected FunctionIdentifier getFunctionIdentifier() {
+ if (isPop) {
+ return BuiltinFunctions.VAR_POP;
+ } else {
+ return BuiltinFunctions.VAR;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..f34f604
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateSqlVarPopAggregateDescriptor.java
@@ -0,0 +1,63 @@
+/*
+ * 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.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableIntermediateSqlVarPopAggregateDescriptor
+ extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new SerializableIntermediateSqlVarPopAggregateDescriptor();
+ }
+ };
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return BuiltinFunctions.SERIAL_INTERMEDIATE_SQL_VAR_POP;
+ }
+
+ @Override
+ public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+ final IScalarEvaluatorFactory[] args) {
+ return new ISerializedAggregateEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+ throws HyracksDataException {
+ return new SerializableIntermediateSqlVarAggregateFunction(args, ctx, true, sourceLoc);
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarAggregateDescriptor.java
new file mode 100644
index 0000000..377c6d2
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarAggregateDescriptor.java
@@ -0,0 +1,63 @@
+/*
+ * 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.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableIntermediateVarAggregateDescriptor
+ extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new SerializableIntermediateVarAggregateDescriptor();
+ }
+ };
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return BuiltinFunctions.SERIAL_INTERMEDIATE_VAR;
+ }
+
+ @Override
+ public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+ final IScalarEvaluatorFactory[] args) {
+ return new ISerializedAggregateEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+ throws HyracksDataException {
+ return new SerializableIntermediateVarAggregateFunction(args, ctx, false, sourceLoc);
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarAggregateFunction.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarAggregateFunction.java
new file mode 100644
index 0000000..dab221e
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarAggregateFunction.java
@@ -0,0 +1,80 @@
+/*
+ * 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.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.SourceLocation;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+import java.io.DataOutput;
+
+public class SerializableIntermediateVarAggregateFunction
+ extends AbstractSerializableSingleVariableStatisticsAggregateFunction {
+
+ private final boolean isPop;
+
+ public SerializableIntermediateVarAggregateFunction(IScalarEvaluatorFactory[] args, IHyracksTaskContext context,
+ boolean isPop, SourceLocation sourceLoc) throws HyracksDataException {
+ super(args, context, sourceLoc);
+ this.isPop = isPop;
+ }
+
+ @Override
+ public void step(IFrameTupleReference tuple, byte[] state, int start, int len) throws HyracksDataException {
+ processPartialResults(tuple, state, start, len);
+ }
+
+ @Override
+ public void finish(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+ finishPartialResults(state, start, len, result);
+ }
+
+ @Override
+ public void finishPartial(byte[] state, int start, int len, DataOutput result) throws HyracksDataException {
+ finishPartialResults(state, start, len, result);
+ }
+
+ @Override
+ protected void processNull(byte[] state, int start) {
+ state[start + AGG_TYPE_OFFSET] = ATypeTag.SERIALIZED_NULL_TYPE_TAG;
+ }
+
+ @Override
+ protected boolean skipStep(byte[] state, int start) {
+ ATypeTag aggType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(state[start + AGG_TYPE_OFFSET]);
+ return aggType == ATypeTag.NULL;
+ }
+
+ @Override
+ protected FunctionIdentifier getFunctionIdentifier() {
+ if (isPop) {
+ return BuiltinFunctions.VAR_POP;
+ } else {
+ return BuiltinFunctions.VAR;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarPopAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarPopAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarPopAggregateDescriptor.java
new file mode 100644
index 0000000..787d54a
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateVarPopAggregateDescriptor.java
@@ -0,0 +1,63 @@
+/*
+ * 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.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableIntermediateVarPopAggregateDescriptor
+ extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new SerializableIntermediateVarPopAggregateDescriptor();
+ }
+ };
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return BuiltinFunctions.SERIAL_INTERMEDIATE_VAR_POP;
+ }
+
+ @Override
+ public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+ final IScalarEvaluatorFactory[] args) {
+ return new ISerializedAggregateEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+ throws HyracksDataException {
+ return new SerializableIntermediateVarAggregateFunction(args, ctx, true, sourceLoc);
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/2a42da45/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalSqlVarAggregateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalSqlVarAggregateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalSqlVarAggregateDescriptor.java
new file mode 100644
index 0000000..2b0c565
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalSqlVarAggregateDescriptor.java
@@ -0,0 +1,62 @@
+/*
+ * 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.runtime.aggregates.serializable.std;
+
+import org.apache.asterix.om.functions.BuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.aggregates.base.AbstractSerializableAggregateFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class SerializableLocalSqlVarAggregateDescriptor extends AbstractSerializableAggregateFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new SerializableLocalSqlVarAggregateDescriptor();
+ }
+ };
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return BuiltinFunctions.SERIAL_LOCAL_SQL_VAR;
+ }
+
+ @Override
+ public ISerializedAggregateEvaluatorFactory createSerializableAggregateEvaluatorFactory(
+ final IScalarEvaluatorFactory[] args) {
+ return new ISerializedAggregateEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ISerializedAggregateEvaluator createAggregateEvaluator(IHyracksTaskContext ctx)
+ throws HyracksDataException {
+ return new SerializableLocalSqlVarAggregateFunction(args, ctx, false, sourceLoc);
+ }
+ };
+ }
+
+}