merge master
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/PushAggFuncIntoStandaloneAggregateRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/PushAggFuncIntoStandaloneAggregateRule.java
index b380557..c157063 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/PushAggFuncIntoStandaloneAggregateRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/PushAggFuncIntoStandaloneAggregateRule.java
@@ -33,7 +33,6 @@
import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable;
import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.ConstantExpression;
import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression;
import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator;
@@ -43,7 +42,7 @@
import edu.uci.ics.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule;
/**
- * Pushes aggregate functions into a stand alone aggregate operator (no group by).
+ * Pushes aggregate functions into a stand alone aggregate operator (no group by).
*/
public class PushAggFuncIntoStandaloneAggregateRule implements IAlgebraicRewriteRule {
@@ -60,6 +59,7 @@
if (op.getOperatorTag() != LogicalOperatorTag.ASSIGN) {
return false;
}
+
Mutable<ILogicalOperator> opRef2 = op.getInputs().get(0);
AbstractLogicalOperator op2 = (AbstractLogicalOperator) opRef2.getValue();
if (op2.getOperatorTag() != LogicalOperatorTag.AGGREGATE) {
@@ -71,7 +71,7 @@
if (op3.getOperatorTag() == LogicalOperatorTag.GROUP) {
return false;
}
-
+
AssignOperator assignOp = (AssignOperator) op;
AggregateOperator aggOp = (AggregateOperator) op2;
if (aggOp.getVariables().size() != 1) {
@@ -87,56 +87,73 @@
if (origAggFuncExpr.getFunctionIdentifier() != AsterixBuiltinFunctions.LISTIFY) {
return false;
}
-
+
LogicalVariable aggVar = aggOp.getVariables().get(0);
List<LogicalVariable> used = new LinkedList<LogicalVariable>();
VariableUtilities.getUsedVariables(assignOp, used);
if (!used.contains(aggVar)) {
return false;
}
-
- Mutable<ILogicalExpression> srcAssignExprRef = fingAggFuncExprRef(assignOp.getExpressions(), aggVar);
- if (srcAssignExprRef == null) {
- return false;
+
+ List<Mutable<ILogicalExpression>> srcAssignExprRefs = new LinkedList<Mutable<ILogicalExpression>>();
+ fingAggFuncExprRef(assignOp.getExpressions(), aggVar, srcAssignExprRefs);
+ if (srcAssignExprRefs.isEmpty()) {
+ return false;
}
- AbstractFunctionCallExpression assignFuncExpr = (AbstractFunctionCallExpression) srcAssignExprRef.getValue();
- FunctionIdentifier aggFuncIdent = AsterixBuiltinFunctions.getAggregateFunction(assignFuncExpr.getFunctionIdentifier());
-
- // Push the agg func into the agg op.
- AbstractFunctionCallExpression aggOpExpr = (AbstractFunctionCallExpression) aggOp.getExpressions().get(0).getValue();
- List<Mutable<ILogicalExpression>> aggArgs = new ArrayList<Mutable<ILogicalExpression>>();
- aggArgs.add(aggOpExpr.getArguments().get(0));
- AggregateFunctionCallExpression aggFuncExpr = AsterixBuiltinFunctions.makeAggregateFunctionExpression(aggFuncIdent, aggArgs);
- aggOp.getExpressions().get(0).setValue(aggFuncExpr);
-
- // The assign now just "renames" the variable to make sure the upstream plan still works.
- srcAssignExprRef.setValue(new VariableReferenceExpression(aggVar));
-
+
+ AbstractFunctionCallExpression aggOpExpr = (AbstractFunctionCallExpression) aggOp.getExpressions().get(0)
+ .getValue();
+ aggOp.getExpressions().clear();
+ aggOp.getVariables().clear();
+
+ for (Mutable<ILogicalExpression> srcAssignExprRef : srcAssignExprRefs) {
+ AbstractFunctionCallExpression assignFuncExpr = (AbstractFunctionCallExpression) srcAssignExprRef
+ .getValue();
+ FunctionIdentifier aggFuncIdent = AsterixBuiltinFunctions.getAggregateFunction(assignFuncExpr
+ .getFunctionIdentifier());
+
+ // Push the agg func into the agg op.
+
+ List<Mutable<ILogicalExpression>> aggArgs = new ArrayList<Mutable<ILogicalExpression>>();
+ aggArgs.add(aggOpExpr.getArguments().get(0));
+ AggregateFunctionCallExpression aggFuncExpr = AsterixBuiltinFunctions.makeAggregateFunctionExpression(
+ aggFuncIdent, aggArgs);
+ LogicalVariable newVar = context.newVar();
+ aggOp.getVariables().add(newVar);
+ aggOp.getExpressions().add(new MutableObject<ILogicalExpression>(aggFuncExpr));
+
+ // The assign now just "renames" the variable to make sure the upstream plan still works.
+ srcAssignExprRef.setValue(new VariableReferenceExpression(newVar));
+ }
+
context.computeAndSetTypeEnvironmentForOperator(aggOp);
context.computeAndSetTypeEnvironmentForOperator(assignOp);
-
+
return true;
}
-
- private Mutable<ILogicalExpression> fingAggFuncExprRef(List<Mutable<ILogicalExpression>> exprRefs, LogicalVariable aggVar) {
- for (Mutable<ILogicalExpression> exprRef : exprRefs) {
+
+ private void fingAggFuncExprRef(List<Mutable<ILogicalExpression>> exprRefs, LogicalVariable aggVar,
+ List<Mutable<ILogicalExpression>> srcAssignExprRefs) {
+ for (Mutable<ILogicalExpression> exprRef : exprRefs) {
ILogicalExpression expr = exprRef.getValue();
if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
continue;
}
AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
- FunctionIdentifier funcIdent = AsterixBuiltinFunctions.getAggregateFunction(funcExpr.getFunctionIdentifier());
+ FunctionIdentifier funcIdent = AsterixBuiltinFunctions.getAggregateFunction(funcExpr
+ .getFunctionIdentifier());
if (funcIdent == null) {
- // Recursively look in func args.
- return fingAggFuncExprRef(funcExpr.getArguments(), aggVar);
+ // Recursively look in func args.
+ fingAggFuncExprRef(funcExpr.getArguments(), aggVar, srcAssignExprRefs);
+
+ } else {
+ // Check if this is the expr that uses aggVar.
+ Collection<LogicalVariable> usedVars = new HashSet<LogicalVariable>();
+ funcExpr.getUsedVariables(usedVars);
+ if (usedVars.contains(aggVar)) {
+ srcAssignExprRefs.add(exprRef);
+ }
}
- // Check if this is the expr that uses aggVar.
- Collection<LogicalVariable> usedVars = new HashSet<LogicalVariable>();
- funcExpr.getUsedVariables(usedVars);
- if (usedVars.contains(aggVar)) {
- return exprRef;
- }
- }
- return null;
+ }
}
}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/AsterixHyracksIntegrationUtil.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/AsterixHyracksIntegrationUtil.java
index 8223c12..ab61b49 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/AsterixHyracksIntegrationUtil.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/AsterixHyracksIntegrationUtil.java
@@ -32,8 +32,7 @@
public class AsterixHyracksIntegrationUtil {
- public static final String NC1_ID = "nc1";
- public static final String NC2_ID = "nc2";
+ public static final String[] NC_IDS = { "nc1", "nc2" };
public static final String[] ASTERIX_DATA_DIRS = new String[] { "nc1data", "nc2data" };
public static final int DEFAULT_HYRACKS_CC_CLIENT_PORT = 1098;
@@ -64,7 +63,7 @@
ncConfig1.dataIPAddress = "127.0.0.1";
ncConfig1.datasetIPAddress = "127.0.0.1";
ncConfig1.resultHistorySize = 1000;
- ncConfig1.nodeId = NC1_ID;
+ ncConfig1.nodeId = NC_IDS[0];
ncConfig1.ioDevices = System.getProperty("java.io.tmpdir") + File.separator + "nc1/iodevice0" + ","
+ System.getProperty("java.io.tmpdir") + File.separator + "nc1/iodevice1";
ncConfig1.appNCMainClass = NCApplicationEntryPoint.class.getName();
@@ -78,7 +77,7 @@
ncConfig2.dataIPAddress = "127.0.0.1";
ncConfig2.datasetIPAddress = "127.0.0.1";
ncConfig2.resultHistorySize = 1000;
- ncConfig2.nodeId = NC2_ID;
+ ncConfig2.nodeId = NC_IDS[1];
ncConfig2.ioDevices = System.getProperty("java.io.tmpdir") + File.separator + "nc2/iodevice0" + ","
+ System.getProperty("java.io.tmpdir") + File.separator + "nc2/iodevice1";
ncConfig2.appNCMainClass = NCApplicationEntryPoint.class.getName();
diff --git a/asterix-app/src/main/resources/asterix-build-configuration.xml b/asterix-app/src/main/resources/asterix-build-configuration.xml
index 71e79e2..6a6332d 100644
--- a/asterix-app/src/main/resources/asterix-build-configuration.xml
+++ b/asterix-app/src/main/resources/asterix-build-configuration.xml
@@ -22,6 +22,14 @@
<ncId>nc2</ncId>
<storeDirs>nc2data</storeDirs>
</store>
+ <transactionLogDir>
+ <ncId>nc1</ncId>
+ <txnLogDirPath>target/txnLogDir/nc1</txnLogDirPath>
+ </transactionLogDir>
+ <transactionLogDir>
+ <ncId>nc2</ncId>
+ <txnLogDirPath>target/txnLogDir/nc2</txnLogDirPath>
+ </transactionLogDir>
<property>
<name>log.level</name>
<value>WARNING</value>
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/metadata/MetadataTest.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/metadata/MetadataTest.java
index 19a55a3..91b75c5 100644
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/metadata/MetadataTest.java
+++ b/asterix-app/src/test/java/edu/uci/ics/asterix/test/metadata/MetadataTest.java
@@ -27,6 +27,8 @@
import org.junit.runners.Parameterized.Parameters;
import edu.uci.ics.asterix.api.common.AsterixHyracksIntegrationUtil;
+import edu.uci.ics.asterix.common.config.AsterixPropertiesAccessor;
+import edu.uci.ics.asterix.common.config.AsterixTransactionProperties;
import edu.uci.ics.asterix.common.config.GlobalConfig;
import edu.uci.ics.asterix.test.aql.TestsUtils;
import edu.uci.ics.asterix.testframework.context.TestCaseContext;
@@ -44,6 +46,8 @@
private static final String TEST_CONFIG_FILE_NAME = "asterix-build-configuration.xml";
private static final String WEB_SERVER_PORT = "19002";
+ private static AsterixTransactionProperties txnProperties;
+
@BeforeClass
public static void setUp() throws Exception {
System.setProperty(GlobalConfig.CONFIG_FILE_PROPERTY, TEST_CONFIG_FILE_NAME);
@@ -51,13 +55,12 @@
File outdir = new File(PATH_ACTUAL);
outdir.mkdirs();
- File log = new File("asterix_logs");
- if (log.exists()) {
- FileUtils.deleteDirectory(log);
- }
+ AsterixPropertiesAccessor apa = new AsterixPropertiesAccessor();
+ txnProperties = new AsterixTransactionProperties(apa);
+
+ deleteTransactionLogs();
AsterixHyracksIntegrationUtil.init();
-
}
@AfterClass
@@ -74,9 +77,15 @@
TestsUtils.deleteRec(new File(d));
}
- File log = new File("asterix_logs");
- if (log.exists()) {
- FileUtils.deleteDirectory(log);
+ deleteTransactionLogs();
+ }
+
+ private static void deleteTransactionLogs() throws Exception {
+ for (String ncId : AsterixHyracksIntegrationUtil.NC_IDS) {
+ File log = new File(txnProperties.getLogDirectory(ncId));
+ if (log.exists()) {
+ FileUtils.deleteDirectory(log);
+ }
}
}
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java
index ca4d135..53b7995 100644
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java
+++ b/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java
@@ -36,6 +36,8 @@
import edu.uci.ics.asterix.api.common.AsterixHyracksIntegrationUtil;
import edu.uci.ics.asterix.api.java.AsterixJavaClient;
+import edu.uci.ics.asterix.common.config.AsterixPropertiesAccessor;
+import edu.uci.ics.asterix.common.config.AsterixTransactionProperties;
import edu.uci.ics.asterix.common.config.GlobalConfig;
import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.external.dataset.adapter.FileSystemBasedAdapter;
@@ -63,6 +65,8 @@
private static final ArrayList<String> only = AsterixTestHelper.readFile(FILENAME_ONLY, PATH_BASE);
private static final String TEST_CONFIG_FILE_NAME = "asterix-build-configuration.xml";
+ private static AsterixTransactionProperties txnProperties;
+
@BeforeClass
public static void setUp() throws Exception {
// File outdir = new File(PATH_ACTUAL);
@@ -73,10 +77,10 @@
File outdir = new File(PATH_ACTUAL);
outdir.mkdirs();
- File log = new File("asterix_logs");
- if (log.exists()) {
- FileUtils.deleteDirectory(log);
- }
+ AsterixPropertiesAccessor apa = new AsterixPropertiesAccessor();
+ txnProperties = new AsterixTransactionProperties(apa);
+
+ deleteTransactionLogs();
AsterixHyracksIntegrationUtil.init();
// Set the node resolver to be the identity resolver that expects node names
@@ -85,6 +89,15 @@
IdentitiyResolverFactory.class.getName());
}
+ private static void deleteTransactionLogs() throws Exception {
+ for (String ncId : AsterixHyracksIntegrationUtil.NC_IDS) {
+ File log = new File(txnProperties.getLogDirectory(ncId));
+ if (log.exists()) {
+ FileUtils.deleteDirectory(log);
+ }
+ }
+ }
+
@AfterClass
public static void tearDown() throws Exception {
// _bootstrap.stop();
@@ -94,10 +107,7 @@
outdir.delete();
}
- File log = new File("asterix_logs");
- if (log.exists()) {
- FileUtils.deleteDirectory(log);
- }
+ deleteTransactionLogs();
}
private static void suiteBuild(File dir, Collection<Object[]> testArgs, String path) {
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java
index 2327a80..36bf23c 100644
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java
+++ b/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java
@@ -27,6 +27,8 @@
import org.junit.runners.Parameterized.Parameters;
import edu.uci.ics.asterix.api.common.AsterixHyracksIntegrationUtil;
+import edu.uci.ics.asterix.common.config.AsterixPropertiesAccessor;
+import edu.uci.ics.asterix.common.config.AsterixTransactionProperties;
import edu.uci.ics.asterix.common.config.GlobalConfig;
import edu.uci.ics.asterix.external.dataset.adapter.FileSystemBasedAdapter;
import edu.uci.ics.asterix.external.util.IdentitiyResolverFactory;
@@ -44,6 +46,8 @@
private static final String TEST_CONFIG_FILE_NAME = "asterix-build-configuration.xml";
private static final String[] ASTERIX_DATA_DIRS = new String[] { "nc1data", "nc2data" };
+ private static AsterixTransactionProperties txnProperties;
+
@BeforeClass
public static void setUp() throws Exception {
System.setProperty(GlobalConfig.CONFIG_FILE_PROPERTY, TEST_CONFIG_FILE_NAME);
@@ -51,10 +55,10 @@
File outdir = new File(PATH_ACTUAL);
outdir.mkdirs();
- File log = new File("asterix_logs");
- if (log.exists()) {
- FileUtils.deleteDirectory(log);
- }
+ AsterixPropertiesAccessor apa = new AsterixPropertiesAccessor();
+ txnProperties = new AsterixTransactionProperties(apa);
+
+ deleteTransactionLogs();
AsterixHyracksIntegrationUtil.init();
@@ -81,13 +85,19 @@
TestsUtils.deleteRec(new File(d));
}
- File log = new File("asterix_logs");
- if (log.exists()) {
- FileUtils.deleteDirectory(log);
- }
+ deleteTransactionLogs();
HDFSCluster.getInstance().cleanup();
}
+ private static void deleteTransactionLogs() throws Exception {
+ for (String ncId : AsterixHyracksIntegrationUtil.NC_IDS) {
+ File log = new File(txnProperties.getLogDirectory(ncId));
+ if (log.exists()) {
+ FileUtils.deleteDirectory(log);
+ }
+ }
+ }
+
@Parameters
public static Collection<Object[]> tests() throws Exception {
Collection<Object[]> testArgs = new ArrayList<Object[]>();
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null/agg_null.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null/agg_null.1.ddl.aql
new file mode 100644
index 0000000..84bd013
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null/agg_null.1.ddl.aql
@@ -0,0 +1,5 @@
+/*
+* Description : Run aggregates over both ordered list and unordered list with only null items.
+* Expected Res : Success
+* Date : Jun 2nd 2013
+*/
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null/agg_null.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null/agg_null.2.update.aql
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null/agg_null.2.update.aql
@@ -0,0 +1 @@
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null/agg_null.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null/agg_null.3.query.aql
new file mode 100644
index 0000000..72e70b3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null/agg_null.3.query.aql
@@ -0,0 +1,9 @@
+/*
+* Description : Run aggregates over both ordered list and unordered list with only null items.
+* Expected Res : Success
+* Date : Jun 2nd 2013
+*/
+
+let $l1 := [null]
+let $l2 := {{null, null}}
+return { "count1": count($l1), "average1": avg($l1), "sum1": sum($l1), "min1": min($l1), "max1": max($l1), "count2": count($l2), "average2": avg($l2), "sum2": sum($l2), "min2": min($l2), "max2": max($l2) }
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.1.ddl.aql
new file mode 100644
index 0000000..da8a4a2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.1.ddl.aql
@@ -0,0 +1,16 @@
+/*
+* Description : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date : Jun 2nd 2013
+*/
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as open {
+ id: int32,
+ val: double
+}
+
+create dataset Test(TestType) primary key id;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.2.update.aql
new file mode 100644
index 0000000..4e0db2b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.2.update.aql
@@ -0,0 +1,11 @@
+/*
+* Description : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date : Jun 2nd 2013
+*/
+
+use dataverse test;
+
+insert into dataset Test ({"id": 0, "val": 4.32, "valplus": 473847});
+insert into dataset Test ({"id": 1, "val": 5.32});
+insert into dataset Test ({"id": 2, "val": 6.32, "valplus": 38473827484738239});
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.3.query.aql
new file mode 100644
index 0000000..bdab44e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec/agg_null_rec.3.query.aql
@@ -0,0 +1,10 @@
+/*
+* Description : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date : Jun 2nd 2013
+*/
+
+use dataverse test;
+
+let $l := for $t in dataset Test return $t.valplus
+return { "count": count($l), "average": avg($l), "sum": sum($l), "min": min($l), "max": max($l) }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec_1/agg_null_rec_1.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec_1/agg_null_rec_1.1.ddl.aql
new file mode 100644
index 0000000..da8a4a2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec_1/agg_null_rec_1.1.ddl.aql
@@ -0,0 +1,16 @@
+/*
+* Description : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date : Jun 2nd 2013
+*/
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as open {
+ id: int32,
+ val: double
+}
+
+create dataset Test(TestType) primary key id;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec_1/agg_null_rec_1.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec_1/agg_null_rec_1.2.update.aql
new file mode 100644
index 0000000..4e0db2b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec_1/agg_null_rec_1.2.update.aql
@@ -0,0 +1,11 @@
+/*
+* Description : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date : Jun 2nd 2013
+*/
+
+use dataverse test;
+
+insert into dataset Test ({"id": 0, "val": 4.32, "valplus": 473847});
+insert into dataset Test ({"id": 1, "val": 5.32});
+insert into dataset Test ({"id": 2, "val": 6.32, "valplus": 38473827484738239});
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec_1/agg_null_rec_1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec_1/agg_null_rec_1.3.query.aql
new file mode 100644
index 0000000..ab0560a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_null_rec_1/agg_null_rec_1.3.query.aql
@@ -0,0 +1,12 @@
+/*
+* Description : Run aggregates over records, with only null items for the aggregating fields.
+* Expected Res : Success
+* Date : Jun 2nd 2013
+*/
+
+use dataverse test;
+
+let $l := for $t in dataset Test return $t
+return { "count": count($l), "average": avg(for $i in $l return $i.val), "sum":
+sum(for $i in $l return $i.val), "min": min(for $i in $l return $i.valplus),
+"max": max(for $i in $l return $i.valplus) }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number/agg_number.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number/agg_number.1.ddl.aql
new file mode 100644
index 0000000..343be89
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number/agg_number.1.ddl.aql
@@ -0,0 +1,6 @@
+/*
+* Description : Run aggregates over an ordered list with numbers of different types
+* Expected Res : Success
+* Date : Jun 2nd 2013
+*/
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number/agg_number.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number/agg_number.2.update.aql
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number/agg_number.2.update.aql
@@ -0,0 +1 @@
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number/agg_number.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number/agg_number.3.query.aql
new file mode 100644
index 0000000..3e9c1ae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number/agg_number.3.query.aql
@@ -0,0 +1,15 @@
+/*
+* Description : Run aggregates over an ordered list with numbers of different types
+* Expected Res : Success
+* Date : Jun 2nd 2013
+*/
+
+let $l1 := [float("2.0"), double("3.0"), 93847382783847382, 1]
+let $l2 := {{float("2.0"), double("3.0"), 93847382783847382, 1}}
+let $a1 := count($l2)
+let $a2 := avg($l2)
+let $a3 := sum($l2)
+let $a4 := min($l2)
+let $a5 := max($l2)
+return { "count1": count($l1), "average1": avg($l1), "sum1": sum($l1), "min1": min($l1), "max1": max($l1), "count2": $a1, "average2": $a2, "sum2": $a3, "min2": $a4, "max2": $a5 }
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number_rec/agg_number_rec.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number_rec/agg_number_rec.1.ddl.aql
new file mode 100644
index 0000000..3b6f853a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number_rec/agg_number_rec.1.ddl.aql
@@ -0,0 +1,16 @@
+/*
+* Description : Run aggregates over records, with different numeric typed items for the aggregating fields.
+* Expected Res : Success
+* Date : Jun 2nd 2013
+*/
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TestType as open {
+ id: int32,
+ val: double
+}
+
+create dataset Test(TestType) primary key id;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number_rec/agg_number_rec.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number_rec/agg_number_rec.2.update.aql
new file mode 100644
index 0000000..86aeb85
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number_rec/agg_number_rec.2.update.aql
@@ -0,0 +1,11 @@
+/*
+* Description : Run aggregates over records, with different numeric typed items for the aggregating fields.
+* Expected Res : Success
+* Date : Jun 2nd 2013
+*/
+
+use dataverse test;
+
+insert into dataset Test ({"id": 0, "val": 4.32, "valplus": 2});
+insert into dataset Test ({"id": 1, "val": 5.32, "valplus": 32.98});
+insert into dataset Test ({"id": 2, "val": 6.32, "valplus": 38473827484738239});
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number_rec/agg_number_rec.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number_rec/agg_number_rec.3.query.aql
new file mode 100644
index 0000000..256be92
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/agg_number_rec/agg_number_rec.3.query.aql
@@ -0,0 +1,10 @@
+/*
+* Description : Run aggregates over records, with different numeric typed items for the aggregating fields.
+* Expected Res : Success
+* Date : Jun 2nd 2013
+*/
+
+use dataverse test;
+
+let $l := for $t in dataset Test return $t.valplus
+return { "count": count($l), "average": avg($l), "sum": sum($l), "min": min($l), "max": max($l) }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_mixed/avg_mixed.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_mixed/avg_mixed.1.ddl.aql
new file mode 100644
index 0000000..9270281
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_mixed/avg_mixed.1.ddl.aql
@@ -0,0 +1,5 @@
+/*
+* Description : Run avg over an ordered list with mixed types
+* Expected Res : Failure
+* Date : Jun 2nd 2013
+*/
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_mixed/avg_mixed.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_mixed/avg_mixed.2.update.aql
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_mixed/avg_mixed.2.update.aql
@@ -0,0 +1 @@
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_mixed/avg_mixed.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_mixed/avg_mixed.3.query.aql
new file mode 100644
index 0000000..05d42c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/avg_mixed/avg_mixed.3.query.aql
@@ -0,0 +1,11 @@
+/*
+* Description : Run avg over an ordered list with mixed types
+* Expected Res : Failure
+* Date : Jun 2nd 2013
+*/
+
+avg(
+ for $x in [float("2.0"), "hello world", 93847382783847382, date("2013-01-01")]
+ return $x
+)
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.1.ddl.aql
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.1.ddl.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.2.update.aql
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.3.query.aql
new file mode 100644
index 0000000..6714628
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.3.query.aql
@@ -0,0 +1,2 @@
+let $l := [23, 748374857483]
+return min($l)
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.ddl.aql
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.ddl.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.2.update.aql
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.3.query.aql
new file mode 100644
index 0000000..b67542d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.3.query.aql
@@ -0,0 +1,2 @@
+let $l := [748374857483, 23, 0.5]
+return min($l)
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.1.ddl.aql
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.1.ddl.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.2.update.aql
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.3.query.aql
new file mode 100644
index 0000000..69b7057
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.3.query.aql
@@ -0,0 +1,2 @@
+let $l := [23, 748374857483]
+return sum($l)
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.ddl.aql
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.ddl.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.2.update.aql
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.3.query.aql
new file mode 100644
index 0000000..308f6f4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.3.query.aql
@@ -0,0 +1,2 @@
+let $l := [748374857483, 23, 0.5]
+return sum($l)
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/min_mixed/min_mixed.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/min_mixed/min_mixed.1.ddl.aql
new file mode 100644
index 0000000..b6ea924
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/min_mixed/min_mixed.1.ddl.aql
@@ -0,0 +1,5 @@
+/*
+* Description : Run min over an ordered list with mixed types
+* Expected Res : Failure
+* Date : Jun 2nd 2013
+*/
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/min_mixed/min_mixed.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/min_mixed/min_mixed.2.update.aql
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/min_mixed/min_mixed.2.update.aql
@@ -0,0 +1 @@
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/min_mixed/min_mixed.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/min_mixed/min_mixed.3.query.aql
new file mode 100644
index 0000000..f66d3c2
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/min_mixed/min_mixed.3.query.aql
@@ -0,0 +1,11 @@
+/*
+* Description : Run min over an ordered list with mixed types
+* Expected Res : Failure
+* Date : Jun 2nd 2013
+*/
+
+min(
+ for $x in [float("2.0"), "hello world", 93847382783847382, date("2013-01-01")]
+ return $x
+)
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_mixed/sum_mixed.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_mixed/sum_mixed.1.ddl.aql
new file mode 100644
index 0000000..8e691a3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_mixed/sum_mixed.1.ddl.aql
@@ -0,0 +1,5 @@
+/*
+* Description : Run sum over an ordered list with mixed types
+* Expected Res : Failure
+* Date : Jun 2nd 2013
+*/
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_mixed/sum_mixed.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_mixed/sum_mixed.2.update.aql
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_mixed/sum_mixed.2.update.aql
@@ -0,0 +1 @@
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_mixed/sum_mixed.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_mixed/sum_mixed.3.query.aql
new file mode 100644
index 0000000..7b4e530
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/sum_mixed/sum_mixed.3.query.aql
@@ -0,0 +1,11 @@
+/*
+* Description : Run sum over an ordered list with mixed types
+* Expected Res : Failure
+* Date : Jun 2nd 2013
+*/
+
+sum(
+ for $x in [float("2.0"), "hello world", 93847382783847382, date("2013-01-01")]
+ return $x
+)
+
diff --git a/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null/agg_null.1.adm b/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null/agg_null.1.adm
new file mode 100644
index 0000000..62ba20b
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null/agg_null.1.adm
@@ -0,0 +1 @@
+{ "count1": 1i64, "average1": null, "sum1": null, "min1": null, "max1": null, "count2": 2i64, "average2": null, "sum2": null, "min2": null, "max2": null }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null_rec/agg_null_rec.1.adm b/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null_rec/agg_null_rec.1.adm
new file mode 100644
index 0000000..96e82eb
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null_rec/agg_null_rec.1.adm
@@ -0,0 +1 @@
+{ "count": 3i64, "average": null, "sum": null, "min": null, "max": null }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null_rec_1/agg_null_rec.1.adm b/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null_rec_1/agg_null_rec.1.adm
new file mode 100644
index 0000000..76d1409
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/aggregate/agg_null_rec_1/agg_null_rec.1.adm
@@ -0,0 +1 @@
+{ "count": 3i64, "average": 5.32d, "sum": 15.96d, "min": null, "max": null }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number/agg_number.1.adm b/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number/agg_number.1.adm
new file mode 100644
index 0000000..0ceea6a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number/agg_number.1.adm
@@ -0,0 +1 @@
+{ "count1": 4i64, "count2": 4i64, "average1": 2.3461845695961844E16d, "sum1": 9.3847382783847376E16, "min1": 1.0d, "max1": 9.3847382783847376E16, "average2": 2.3461845695961844E16d, "sum2": 9.3847382783847376E16, "min2": 1.0d, "max2": 9.3847382783847376E16 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number_rec/agg_number_rec.1.adm b/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number_rec/agg_number_rec.1.adm
new file mode 100644
index 0000000..7cedaad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/aggregate/agg_number_rec/agg_number_rec.1.adm
@@ -0,0 +1 @@
+{ "count": 3i64, "average": 1.2824609161579424E16d, "sum": 3.8473827484738272E16d, "min": 2.0d, "max": 3.847382748473824E16d }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/aggregate/avg_mixed/avg_mixed.1.adm b/asterix-app/src/test/resources/runtimets/results/aggregate/avg_mixed/avg_mixed.1.adm
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/aggregate/avg_mixed/avg_mixed.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.1.adm b/asterix-app/src/test/resources/runtimets/results/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.1.adm
new file mode 100644
index 0000000..7900e71
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/aggregate/issue425_min_hetero_list/issue425_min_hetero_list.1.adm
@@ -0,0 +1 @@
+23i64
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.adm b/asterix-app/src/test/resources/runtimets/results/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.adm
new file mode 100644
index 0000000..1bf31ef
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/aggregate/issue425_min_hetero_list_1/issue425_min_hetero_list_1.1.adm
@@ -0,0 +1 @@
+0.5d
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.1.adm b/asterix-app/src/test/resources/runtimets/results/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.1.adm
new file mode 100644
index 0000000..dc572c0
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/aggregate/issue425_sum_hetero_list/issue425_sum_hetero_list.1.adm
@@ -0,0 +1 @@
+748374857506i64
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.adm b/asterix-app/src/test/resources/runtimets/results/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.adm
new file mode 100644
index 0000000..7c07cb7
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/aggregate/issue425_sum_hetero_list_1/issue425_sum_hetero_list_1.1.adm
@@ -0,0 +1 @@
+748374857506.5d
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/aggregate/min_mixed/min_mixed.1.adm b/asterix-app/src/test/resources/runtimets/results/aggregate/min_mixed/min_mixed.1.adm
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/aggregate/min_mixed/min_mixed.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/results/aggregate/sum_mixed/sum_mixed.1.adm b/asterix-app/src/test/resources/runtimets/results/aggregate/sum_mixed/sum_mixed.1.adm
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/aggregate/sum_mixed/sum_mixed.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index 3a8a58a..6a8d24f 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -15,6 +15,69 @@
<test-suite xmlns="urn:xml.testframework.asterix.ics.uci.edu" ResultOffsetPath="results" QueryOffsetPath="queries" QueryFileExtension=".aql">
<test-group name="aggregate">
<test-case FilePath="aggregate">
+ <compilation-unit name="agg_null">
+ <output-dir compare="Text">agg_null</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="aggregate">
+ <compilation-unit name="agg_null_rec">
+ <output-dir compare="Text">agg_null_rec</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="aggregate">
+ <compilation-unit name="agg_null_rec_1">
+ <output-dir compare="Text">agg_null_rec_1</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="aggregate">
+ <compilation-unit name="agg_number_rec">
+ <output-dir compare="Text">agg_number_rec</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="aggregate">
+ <compilation-unit name="avg_mixed">
+ <output-dir compare="Text">avg_mixed</output-dir>
+ <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="aggregate">
+ <compilation-unit name="sum_mixed">
+ <output-dir compare="Text">sum_mixed</output-dir>
+ <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="aggregate">
+ <compilation-unit name="min_mixed">
+ <output-dir compare="Text">min_mixed</output-dir>
+ <expected-error>edu.uci.ics.asterix.common.exceptions.AsterixException</expected-error>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="aggregate">
+ <compilation-unit name="agg_number">
+ <output-dir compare="Text">agg_number</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="aggregate">
+ <compilation-unit name="issue425_min_hetero_list_1">
+ <output-dir compare="Text">issue425_min_hetero_list_1</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="aggregate">
+ <compilation-unit name="issue425_min_hetero_list">
+ <output-dir compare="Text">issue425_min_hetero_list</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="aggregate">
+ <compilation-unit name="issue425_sum_hetero_list_1">
+ <output-dir compare="Text">issue425_sum_hetero_list_1</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="aggregate">
+ <compilation-unit name="issue425_sum_hetero_list">
+ <output-dir compare="Text">issue425_sum_hetero_list</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="aggregate">
<compilation-unit name="query-issue400">
<output-dir compare="Text">query-issue400</output-dir>
</compilation-unit>
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixExternalProperties.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixExternalProperties.java
index 8b79039..e975f60 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixExternalProperties.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixExternalProperties.java
@@ -25,7 +25,7 @@
private static Level EXTERNAL_LOGLEVEL_DEFAULT = Level.WARNING;
private static final String EXTERNAL_APISERVER_KEY = "api.port";
- private static int EXTERNAL_APISERVER_DEFAULT = 19101;
+ private static int EXTERNAL_APISERVER_DEFAULT = 19002;
public AsterixExternalProperties(AsterixPropertiesAccessor accessor) {
super(accessor);
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixPropertiesAccessor.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixPropertiesAccessor.java
index 714c32d..2bd292e 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixPropertiesAccessor.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixPropertiesAccessor.java
@@ -33,6 +33,7 @@
import edu.uci.ics.asterix.common.configuration.Coredump;
import edu.uci.ics.asterix.common.configuration.Property;
import edu.uci.ics.asterix.common.configuration.Store;
+import edu.uci.ics.asterix.common.configuration.TransactionLogDir;
import edu.uci.ics.asterix.common.exceptions.AsterixException;
public class AsterixPropertiesAccessor {
@@ -43,6 +44,7 @@
private final Map<String, String[]> stores;
private final Map<String, String> coredumpConfig;
private final Map<String, Property> asterixConfigurationParams;
+ private final Map<String, String> transactionLogDirs;
public AsterixPropertiesAccessor() throws AsterixException {
String fileName = System.getProperty(GlobalConfig.CONFIG_FILE_PROPERTY);
@@ -84,6 +86,10 @@
for (Coredump cd : asterixConfiguration.getCoredump()) {
coredumpConfig.put(cd.getNcId(), cd.getCoredumpPath());
}
+ transactionLogDirs = new HashMap<String, String>();
+ for (TransactionLogDir txnLogDir : asterixConfiguration.getTransactionLogDir()) {
+ transactionLogDirs.put(txnLogDir.getNcId(), txnLogDir.getTxnLogDirPath());
+ }
}
@@ -107,6 +113,10 @@
return coredumpConfig.get(nodeId);
}
+ public String getTransactionLogDir(String nodeId) {
+ return transactionLogDirs.get(nodeId);
+ }
+
public <T> T getProperty(String property, T defaultValue, IPropertyInterpreter<T> interpreter) {
Property p = asterixConfigurationParams.get(property);
if (p == null) {
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixTransactionProperties.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixTransactionProperties.java
index cb8bbb6..6fa5beb 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixTransactionProperties.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixTransactionProperties.java
@@ -15,9 +15,7 @@
package edu.uci.ics.asterix.common.config;
public class AsterixTransactionProperties extends AbstractAsterixProperties {
- private static final String TXN_LOG_DIRECTORY_KEY = "txn.log.directory";
- private static final String TXN_LOG_DIRECTORY_DEFAULT = "asterix_logs/";
-
+
private static final String TXN_LOG_BUFFER_NUMPAGES_KEY = "txn.log.buffer.numpages";
private static int TXN_LOG_BUFFER_NUMPAGES_DEFAULT = 8;
@@ -26,7 +24,7 @@
private static final String TXN_LOG_PARTITIONSIZE_KEY = "txn.log.partitionsize";
private static final long TXN_LOG_PARTITIONSIZE_DEFAULT = (2 << 30); // 2GB
-
+
private static final String TXN_LOG_DISKSECTORSIZE_KEY = "txn.log.disksectorsize";
private static final int TXN_LOG_DISKSECTORSIZE_DEFAULT = 4096;
@@ -38,7 +36,7 @@
private static final String TXN_LOG_CHECKPOINT_POLLFREQUENCY_KEY = "txn.log.checkpoint.pollfrequency";
private static int TXN_LOG_CHECKPOINT_POLLFREQUENCY_DEFAULT = 120; // 120s
-
+
private static final String TXN_LOG_CHECKPOINT_HISTORY_KEY = "txn.log.checkpoint.history";
private static int TXN_LOG_CHECKPOINT_HISTORY_DEFAULT = 0;
@@ -47,24 +45,19 @@
private static final String TXN_LOCK_SHRINKTIMER_KEY = "txn.lock.shrinktimer";
private static int TXN_LOCK_SHRINKTIMER_DEFAULT = 5000; // 5s
-
+
private static final String TXN_LOCK_TIMEOUT_WAITTHRESHOLD_KEY = "txn.lock.timeout.waitthreshold";
private static final int TXN_LOCK_TIMEOUT_WAITTHRESHOLD_DEFAULT = 60000; // 60s
-
+
private static final String TXN_LOCK_TIMEOUT_SWEEPTHRESHOLD_KEY = "txn.lock.timeout.sweepthreshold";
private static final int TXN_LOCK_TIMEOUT_SWEEPTHRESHOLD_DEFAULT = 10000; // 10s
public AsterixTransactionProperties(AsterixPropertiesAccessor accessor) {
super(accessor);
}
-
- public String getLogDirectory() {
- String logDirectory = accessor.getProperty(TXN_LOG_DIRECTORY_KEY, TXN_LOG_DIRECTORY_DEFAULT,
- PropertyInterpreters.getStringPropertyInterpreter());
- if (!logDirectory.endsWith("/")) {
- logDirectory += "/";
- }
- return logDirectory;
+
+ public String getLogDirectory(String nodeId) {
+ return accessor.getTransactionLogDir(nodeId);
}
public int getLogBufferNumPages() {
@@ -81,7 +74,7 @@
return accessor.getProperty(TXN_LOG_PARTITIONSIZE_KEY, TXN_LOG_PARTITIONSIZE_DEFAULT,
PropertyInterpreters.getLongPropertyInterpreter());
}
-
+
public int getLogDiskSectorSize() {
return accessor.getProperty(TXN_LOG_DISKSECTORSIZE_KEY, TXN_LOG_DISKSECTORSIZE_DEFAULT,
PropertyInterpreters.getIntegerPropertyInterpreter());
@@ -106,7 +99,7 @@
return accessor.getProperty(TXN_LOG_CHECKPOINT_HISTORY_KEY, TXN_LOG_CHECKPOINT_HISTORY_DEFAULT,
PropertyInterpreters.getIntegerPropertyInterpreter());
}
-
+
public int getEntityToDatasetLockEscalationThreshold() {
return accessor.getProperty(TXN_LOCK_ESCALATIONTHRESHOLD_KEY, TXN_LOCK_ESCALATIONTHRESHOLD_DEFAULT,
PropertyInterpreters.getIntegerPropertyInterpreter());
@@ -116,12 +109,12 @@
return accessor.getProperty(TXN_LOCK_SHRINKTIMER_KEY, TXN_LOCK_SHRINKTIMER_DEFAULT,
PropertyInterpreters.getIntegerPropertyInterpreter());
}
-
+
public int getTimeoutWaitThreshold() {
return accessor.getProperty(TXN_LOCK_TIMEOUT_WAITTHRESHOLD_KEY, TXN_LOCK_TIMEOUT_WAITTHRESHOLD_DEFAULT,
PropertyInterpreters.getIntegerPropertyInterpreter());
}
-
+
public int getTimeoutSweepThreshold() {
return accessor.getProperty(TXN_LOCK_TIMEOUT_SWEEPTHRESHOLD_KEY, TXN_LOCK_TIMEOUT_SWEEPTHRESHOLD_DEFAULT,
PropertyInterpreters.getIntegerPropertyInterpreter());
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/DatasetLifecycleManager.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/DatasetLifecycleManager.java
index 7ba0932..9cd8879 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/DatasetLifecycleManager.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/DatasetLifecycleManager.java
@@ -158,23 +158,28 @@
}
private boolean evictCandidateDataset() throws HyracksDataException {
- // Why min()? As a heuristic for eviction, we will take an open index (an index consuming memory)
+ // We will take a dataset that has no active transactions, it is open (a dataset consuming memory),
// that is not being used (refcount == 0) and has been least recently used. The sort order defined
- // for IndexInfo maintains this. See IndexInfo.compareTo().
- DatasetInfo dsInfo = Collections.min(datasetInfos.values());
- if (dsInfo.referenceCount == 0 && dsInfo.isOpen) {
- for (IndexInfo iInfo : dsInfo.indexes.values()) {
- if (iInfo.isOpen) {
- iInfo.index.deactivate(true);
- iInfo.isOpen = false;
- }
- assert iInfo.referenceCount == 0;
- }
+ // for DatasetInfo maintains this. See DatasetInfo.compareTo().
- IVirtualBufferCache vbc = getVirtualBufferCache(dsInfo.datasetID);
- used -= vbc.getNumPages() * vbc.getPageSize();
- dsInfo.isOpen = false;
- return true;
+ List<DatasetInfo> datasetInfosList = new ArrayList<DatasetInfo>(datasetInfos.values());
+ Collections.sort(datasetInfosList);
+ for (DatasetInfo dsInfo : datasetInfosList) {
+ if (((PrimaryIndexOperationTracker) datasetOpTrackers.get(dsInfo.datasetID)).getNumActiveOperations() == 0
+ && dsInfo.referenceCount == 0 && dsInfo.isOpen) {
+ for (IndexInfo iInfo : dsInfo.indexes.values()) {
+ if (iInfo.isOpen) {
+ iInfo.index.deactivate(true);
+ iInfo.isOpen = false;
+ }
+ assert iInfo.referenceCount == 0;
+ }
+
+ IVirtualBufferCache vbc = getVirtualBufferCache(dsInfo.datasetID);
+ used -= vbc.getNumPages() * vbc.getPageSize();
+ dsInfo.isOpen = false;
+ return true;
+ }
}
return false;
}
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/PrimaryIndexOperationTracker.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/PrimaryIndexOperationTracker.java
index 4e2eb97..53b9192 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/PrimaryIndexOperationTracker.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/PrimaryIndexOperationTracker.java
@@ -113,4 +113,8 @@
}
}
+ public int getNumActiveOperations() {
+ return numActiveOperations.get();
+ }
+
}
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/transactions/LogManagerProperties.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/transactions/LogManagerProperties.java
index 7b78654..4b5eb9b 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/transactions/LogManagerProperties.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/transactions/LogManagerProperties.java
@@ -49,7 +49,7 @@
this.logPageSize = txnProperties.getLogBufferPageSize();
this.numLogPages = txnProperties.getLogBufferNumPages();
long logPartitionSize = txnProperties.getLogPartitionSize();
- this.logDir = txnProperties.getLogDirectory() + nodeId;
+ this.logDir = txnProperties.getLogDirectory(nodeId);
this.logFilePrefix = DEFAULT_LOG_FILE_PREFIX;
this.groupCommitWaitPeriod = txnProperties.getGroupCommitInterval();
diff --git a/asterix-common/src/main/resources/schema/asterix-conf.xsd b/asterix-common/src/main/resources/schema/asterix-conf.xsd
index 5aefdbd..f461723 100644
--- a/asterix-common/src/main/resources/schema/asterix-conf.xsd
+++ b/asterix-common/src/main/resources/schema/asterix-conf.xsd
@@ -13,6 +13,8 @@
<xs:element name="name" type="xs:string" />
<xs:element name="value" type="xs:string" />
<xs:element name="description" type="xs:string" />
+ <xs:element name="txnLogDirPath" type="xs:string" />
+
<!-- definition of complex elements -->
<xs:element name="store">
@@ -32,6 +34,15 @@
</xs:sequence>
</xs:complexType>
</xs:element>
+
+ <xs:element name="transactionLogDir">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="mg:ncId" />
+ <xs:element ref="mg:txnLogDirPath" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
<xs:element name="property">
<xs:complexType>
@@ -50,6 +61,7 @@
<xs:element ref="mg:metadataNode" minOccurs="0"/>
<xs:element ref="mg:store" maxOccurs="unbounded" />
<xs:element ref="mg:coredump" maxOccurs="unbounded" />
+ <xs:element ref="mg:transactionLogDir" maxOccurs="unbounded"/>
<xs:element ref="mg:property" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
diff --git a/asterix-common/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java b/asterix-common/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
index 1de6bd4..2a9783b 100644
--- a/asterix-common/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
+++ b/asterix-common/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
@@ -195,7 +195,7 @@
public static InputStream executeQuery(String str) throws Exception {
InputStream resultStream = null;
- final String url = "http://localhost:19101/query";
+ final String url = "http://localhost:19002/query";
// Create an instance of HttpClient.
HttpClient client = new HttpClient();
@@ -229,7 +229,7 @@
// To execute Update statements
// Insert and Delete statements are executed here
public static void executeUpdate(String str) throws Exception {
- final String url = "http://localhost:19101/update";
+ final String url = "http://localhost:19002/update";
// Create an instance of HttpClient.
HttpClient client = new HttpClient();
@@ -261,7 +261,7 @@
// create dataverse statement
// create function statement
public static void executeDDL(String str) throws Exception {
- final String url = "http://localhost:19101/ddl";
+ final String url = "http://localhost:19002/ddl";
// Create an instance of HttpClient.
HttpClient client = new HttpClient();
@@ -378,4 +378,3 @@
}
}
}
-
diff --git a/asterix-events/src/main/resources/events/cc_start/cc_start.sh b/asterix-events/src/main/resources/events/cc_start/cc_start.sh
index 9696c82..068c152 100755
--- a/asterix-events/src/main/resources/events/cc_start/cc_start.sh
+++ b/asterix-events/src/main/resources/events/cc_start/cc_start.sh
@@ -17,4 +17,4 @@
mkdir -p $LOG_DIR
fi
cd $WORKING_DIR
-$ASTERIX_HOME/bin/asterixcc -client-net-ip-address $CLIENT_NET_IP -client-net-port 1098 -cluster-net-ip-address $CLUSTER_NET_IP -cluster-net-port 1099 -http-port 8888 &> $LOG_DIR/cc.log
+$ASTERIX_HOME/bin/asterixcc -client-net-ip-address $CLIENT_NET_IP -client-net-port $CLIENT_NET_PORT -cluster-net-ip-address $CLUSTER_NET_IP -cluster-net-port $CLUSTER_NET_PORT -http-port $HTTP_PORT &> $LOG_DIR/cc.log
diff --git a/asterix-events/src/main/resources/events/events.xml b/asterix-events/src/main/resources/events/events.xml
index a396067..01495cb 100644
--- a/asterix-events/src/main/resources/events/events.xml
+++ b/asterix-events/src/main/resources/events/events.xml
@@ -84,6 +84,13 @@
<daemon>false</daemon>
</event>
<event>
+ <type>directory_copy</type>
+ <script>file/dir_copy.sh</script>
+ <description>Copies a directory (and its contents) from the remove file system to the local file system</description>
+ <args>destination_node destination_path local_source_path</args>
+ <daemon>false</daemon>
+ </event>
+ <event>
<type>file_delete</type>
<script>file/delete.sh</script>
<description>Deletes a file on the local file system to a remote node</description>
diff --git a/asterix-events/src/main/resources/events/file/dir_copy.sh b/asterix-events/src/main/resources/events/file/dir_copy.sh
new file mode 100755
index 0000000..6015dca
--- /dev/null
+++ b/asterix-events/src/main/resources/events/file/dir_copy.sh
@@ -0,0 +1,7 @@
+USERNAME=$1
+SRC_HOST=$2
+SRC_DIR=$3
+DEST_DIR=$4
+mkdir -p $DEST_DIR
+echo "scp -r $USERNAME@$SRC_HOST:$SRC_DIR $DEST_DIR"
+scp -r $USERNAME@$SRC_HOST:$SRC_DIR $DEST_DIR
diff --git a/asterix-events/src/main/resources/events/node_join/nc_join.sh b/asterix-events/src/main/resources/events/node_join/nc_join.sh
index 5e0d28c..e0254c9 100755
--- a/asterix-events/src/main/resources/events/node_join/nc_join.sh
+++ b/asterix-events/src/main/resources/events/node_join/nc_join.sh
@@ -20,4 +20,4 @@
mkdir -p $LOG_DIR
fi
cd $WORKING_DIR
-$ASTERIX_HOME/bin/asterixnc -node-id $NC_ID -cc-host $CC_HOST -cc-port 1099 -cluster-net-ip-address $IP_LOCATION -data-ip-address $IP_LOCATION -iodevices $IO_DEVICES -result-ip-address $IP_LOCATION &> $LOG_DIR/${NC_ID}.log
+$ASTERIX_HOME/bin/asterixnc -node-id $NC_ID -cc-host $CC_HOST -cc-port $CLUSTER_NET_PORT -cluster-net-ip-address $IP_LOCATION -data-ip-address $IP_LOCATION -iodevices $IO_DEVICES -result-ip-address $IP_LOCATION &> $LOG_DIR/${NC_ID}.log
diff --git a/asterix-events/src/main/resources/schema/cluster.xsd b/asterix-events/src/main/resources/schema/cluster.xsd
index 718d7b0..f0d5bd9 100644
--- a/asterix-events/src/main/resources/schema/cluster.xsd
+++ b/asterix-events/src/main/resources/schema/cluster.xsd
@@ -17,6 +17,10 @@
<xs:element name="iodevices" type="xs:string" />
<xs:element name="java_home" type="xs:string" />
<xs:element name="username" type="xs:string" />
+ <xs:element name="web_port" type="xs:string" />
+ <xs:element name="client_port" type="xs:integer" />
+ <xs:element name="cluster_port" type="xs:integer" />
+ <xs:element name="http_port" type="xs:integer" />
<!-- definition of complex elements -->
<xs:element name="working_dir">
@@ -36,6 +40,9 @@
<xs:element ref="cl:cluster_ip" />
<xs:element ref="cl:java_home" minOccurs="0" />
<xs:element ref="cl:log_dir" minOccurs="0" />
+ <xs:element ref="cl:client_port" />
+ <xs:element ref="cl:cluster_port" />
+ <xs:element ref="cl:http_port" />
</xs:sequence>
</xs:complexType>
</xs:element>
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandHandler.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandHandler.java
index 4ba4603..230a945 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandHandler.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandHandler.java
@@ -52,6 +52,9 @@
case CONFIGURE:
cmd = new ConfigureCommand();
break;
+ case LOG:
+ cmd = new LogCommand();
+ break;
case SHUTDOWN:
cmd = new ShutdownCommand();
break;
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/HelpCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/HelpCommand.java
index d9bdc0f..a2f00b3 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/HelpCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/HelpCommand.java
@@ -58,6 +58,9 @@
case ALTER:
helpMessage = new AlterCommand().getUsageDescription();
break;
+ case LOG:
+ helpMessage = new LogCommand().getUsageDescription();
+ break;
default:
helpMessage = "Unknown command " + command;
}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ICommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ICommand.java
index 2124203..9e67bf5 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ICommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ICommand.java
@@ -27,6 +27,7 @@
ALTER,
VALIDATE,
CONFIGURE,
+ LOG,
SHUTDOWN,
HELP
}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/LogCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/LogCommand.java
new file mode 100644
index 0000000..3f99ab0
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/LogCommand.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed 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 from
+ *
+ * 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 edu.uci.ics.asterix.installer.command;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.Date;
+
+import org.apache.commons.io.FileUtils;
+import org.kohsuke.args4j.Option;
+
+import edu.uci.ics.asterix.event.management.EventrixClient;
+import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.driver.InstallerUtil;
+import edu.uci.ics.asterix.installer.error.InstallerException;
+import edu.uci.ics.asterix.installer.events.PatternCreator;
+import edu.uci.ics.asterix.installer.model.AsterixInstance;
+import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
+
+public class LogCommand extends AbstractCommand {
+
+ @Override
+ protected void execCommand() throws Exception {
+ InstallerDriver.initConfig(true);
+ String asterixInstanceName = ((LogConfig) config).name;
+ AsterixInstance instance = InstallerUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE,
+ State.UNUSABLE, State.ACTIVE);
+ PatternCreator pc = new PatternCreator();
+ EventrixClient client = InstallerUtil.getEventrixClient(instance.getCluster());
+ String outputDir = ((LogConfig) config).outputDir == null ? InstallerDriver.getManagixHome() + File.separator + "logdump"
+ : ((LogConfig) config).outputDir;
+ File f = new File(outputDir);
+ String outputDirPath = f.getAbsolutePath();
+ if (!f.exists()) {
+ boolean success = f.mkdirs();
+ if (!success) {
+ throw new InstallerException("Unable to create output directory:" + outputDirPath);
+ }
+ }
+ Patterns transferLogPattern = pc.getGenerateLogPattern(asterixInstanceName, instance.getCluster(), outputDirPath);
+ client.submit(transferLogPattern);
+ File outputDirFile = new File(outputDirPath);
+ final String destFileName = "log_" + new Date().toString().replace(' ', '_') + ".zip";
+ File destFile = new File(outputDirFile, destFileName);
+ InstallerUtil.zipDir(outputDirFile, destFile);
+
+ String[] filesToDelete = outputDirFile.list(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return !name.equals(destFileName);
+ }
+
+ });
+ for (String fileS : filesToDelete) {
+ f = new File(outputDirFile, fileS);
+ if (f.isDirectory()) {
+ FileUtils.deleteDirectory(f);
+ } else {
+ f.delete();
+ }
+ }
+ LOGGER.info("Log zip archive created at " + destFile.getAbsolutePath());
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new LogConfig();
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ return "\nCreates a tar ball containing log files corresponding to each worker node (NC) and the master (CC) for an ASTERIX instance"
+ + "\n\nAvailable arguments/options"
+ + "\n-n name of the ASTERIX instance. \n-d destination directory for producing the tar ball (defaults to) "
+ + InstallerDriver.getManagixHome();
+ }
+}
+
+class LogConfig extends CommandConfig {
+
+ @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
+ public String name;
+
+ @Option(name = "-d", required = false, usage = "Destination directory for producing log tar ball")
+ public String outputDir;
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerDriver.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerDriver.java
index 1dfee41..521adc6 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerDriver.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerDriver.java
@@ -135,6 +135,8 @@
buffer.append("describe " + ":" + " Describes an existing asterix instance" + "\n");
buffer.append("validate " + ":" + " Validates the installer/cluster configuration" + "\n");
buffer.append("configure" + ":" + " Configure the Asterix installer" + "\n");
+ buffer.append("log " + ":"
+ + " Produce a tar archive contianing log files from the master and worker nodes" + "\n");
buffer.append("shutdown " + ":" + " Shutdown the installer service" + "\n");
buffer.append("help " + ":" + " Provides usage description of a command" + "\n");
buffer.append("\nTo get more information about a command, use managix help -cmd <command>");
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerUtil.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerUtil.java
index ff7b652..e62cc59 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerUtil.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerUtil.java
@@ -48,11 +48,12 @@
import org.apache.commons.io.IOUtils;
import edu.uci.ics.asterix.common.configuration.AsterixConfiguration;
-import edu.uci.ics.asterix.common.configuration.Store;
import edu.uci.ics.asterix.common.configuration.Coredump;
+import edu.uci.ics.asterix.common.configuration.Store;
+import edu.uci.ics.asterix.common.configuration.TransactionLogDir;
import edu.uci.ics.asterix.event.driver.EventDriver;
-import edu.uci.ics.asterix.event.management.EventrixClient;
import edu.uci.ics.asterix.event.management.EventUtil;
+import edu.uci.ics.asterix.event.management.EventrixClient;
import edu.uci.ics.asterix.event.schema.cluster.Cluster;
import edu.uci.ics.asterix.event.schema.cluster.Env;
import edu.uci.ics.asterix.event.schema.cluster.Node;
@@ -69,6 +70,10 @@
public static final String TXN_LOG_DIR_KEY_SUFFIX = "txnLogDir";
public static final String ASTERIX_CONFIGURATION_FILE = "asterix-configuration.xml";
public static final String TXN_LOG_CONFIGURATION_FILE = "log.properties";
+ public static final int CLUSTER_NET_PORT_DEFAULT = 1098;
+ public static final int CLIENT_NET_PORT_DEFAULT = 1099;
+ public static final int HTTP_PORT_DEFAULT = 8888;
+ public static final int WEB_INTERFACE_PORT_DEFAULT = 19001;
public static AsterixInstance createAsterixInstance(String asterixInstanceName, Cluster cluster,
AsterixConfiguration asterixConfiguration) throws FileNotFoundException, IOException {
@@ -106,11 +111,23 @@
}
clusterProperties.add(new Property("ASTERIX_HOME", cluster.getWorkingDir().getDir() + File.separator
+ "asterix"));
- clusterProperties.add(new Property("CLUSTER_NET_IP", cluster.getMasterNode().getClusterIp()));
- clusterProperties.add(new Property("CLIENT_NET_IP", cluster.getMasterNode().getClientIp()));
clusterProperties.add(new Property("LOG_DIR", cluster.getLogDir()));
clusterProperties.add(new Property("JAVA_HOME", cluster.getJavaHome()));
clusterProperties.add(new Property("WORKING_DIR", cluster.getWorkingDir().getDir()));
+ clusterProperties.add(new Property("CLIENT_NET_IP", cluster.getMasterNode().getClientIp()));
+ clusterProperties.add(new Property("CLUSTER_NET_IP", cluster.getMasterNode().getClusterIp()));
+
+ int clusterNetPort = cluster.getMasterNode().getClusterPort() != null ? cluster.getMasterNode()
+ .getClusterPort().intValue() : CLUSTER_NET_PORT_DEFAULT;
+ int clientNetPort = cluster.getMasterNode().getClientPort() != null ? cluster.getMasterNode().getClientPort()
+ .intValue() : CLIENT_NET_PORT_DEFAULT;
+ int httpPort = cluster.getMasterNode().getHttpPort() != null ? cluster.getMasterNode().getHttpPort().intValue()
+ : HTTP_PORT_DEFAULT;
+
+ clusterProperties.add(new Property("CLIENT_NET_PORT", "" + clientNetPort));
+ clusterProperties.add(new Property("CLUSTER_NET_PORT", "" + clusterNetPort));
+ clusterProperties.add(new Property("HTTP_PORT", "" + httpPort));
+
cluster.setEnv(new Env(clusterProperties));
}
@@ -226,11 +243,17 @@
List<Coredump> coredump = new ArrayList<Coredump>();
String coredumpDir = null;
+ List<TransactionLogDir> txnLogDirs = new ArrayList<TransactionLogDir>();
+ String txnLogDir = null;
for (Node node : cluster.getNode()) {
coredumpDir = node.getLogDir() == null ? cluster.getLogDir() : node.getLogDir();
- coredump.add(new Coredump(asterixInstanceName + "_" + node.getId(), coredumpDir));
+ coredump.add(new Coredump(asterixInstanceName + "_" + node.getId(), coredumpDir + File.separator + asterixInstanceName + "_" + node.getId()));
+
+ txnLogDir = node.getTxnLogDir() == null ? cluster.getTxnLogDir() : node.getTxnLogDir();
+ txnLogDirs.add(new TransactionLogDir(asterixInstanceName + "_" + node.getId(), txnLogDir));
}
configuration.setCoredump(coredump);
+ configuration.setTransactionLogDir(txnLogDirs);
File asterixConfDir = new File(InstallerDriver.getAsterixDir() + File.separator + asterixInstanceName);
asterixConfDir.mkdirs();
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java
index ca4ec81..fe61462 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java
@@ -16,8 +16,10 @@
import java.io.File;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import edu.uci.ics.asterix.event.driver.EventDriver;
@@ -183,7 +185,7 @@
txnLogDir = node.getTxnLogDir() == null ? instance.getCluster().getTxnLogDir() : node.getTxnLogDir();
store = node.getStore() == null ? cluster.getStore() : node.getStore();
pargs = workingDir + " " + instance.getName() + " " + iodevices + " " + store + " "
- + BackupCommand.ASTERIX_ROOT_METADATA_DIR + " " + txnLogDir + " " + backupId + " " + backupDir
+ + BackupCommand.ASTERIX_ROOT_METADATA_DIR + " " + txnLogDir + " " + backupId + " " + backupDir
+ " " + "local" + " " + node.getId();
Event event = new Event("backup", nodeid, pargs);
patternList.add(new Pattern(null, 1, null, event));
@@ -479,4 +481,35 @@
return new Pattern(null, 1, null, event);
}
+ public Patterns getGenerateLogPattern(String asterixInstanceName, Cluster cluster, String outputDir) {
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ Map<String,String> nodeLogs = new HashMap<String,String>();
+
+ String username = cluster.getUsername() == null ? System.getProperty("user.name") : cluster.getUsername();
+ String srcHost = cluster.getMasterNode().getClientIp();
+ Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
+ String srcDir = cluster.getMasterNode().getLogDir() == null ? cluster.getLogDir() : cluster.getMasterNode()
+ .getLogDir();
+ String destDir = outputDir + File.separator + "cc";
+ String pargs = username + " " + srcHost + " " + srcDir + " " + destDir;
+ Event event = new Event("directory_copy", nodeid, pargs);
+ Pattern p = new Pattern(null, 1, null, event);
+ patternList.add(p);
+ nodeLogs.put(cluster.getMasterNode().getClusterIp(),srcDir);
+ for (Node node : cluster.getNode()) {
+ srcHost = node.getClusterIp();
+ srcDir = node.getLogDir() == null ? cluster.getLogDir() : node.getLogDir();
+ if(nodeLogs.get(node.getClusterIp()) != null && nodeLogs.get(node.getClusterIp()).equals(srcDir)){
+ continue;
+ }
+ destDir = outputDir + File.separator + node.getId();
+ pargs = username + " " + srcHost + " " + srcDir + " " + destDir;
+ event = new Event("directory_copy", nodeid, pargs);
+ p = new Pattern(null, 1, null, event);
+ patternList.add(p);
+ }
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
+
}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java
index 24e001a..c9a4743 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java
@@ -19,6 +19,7 @@
import java.util.Date;
import java.util.List;
+import edu.uci.ics.asterix.common.config.AsterixExternalProperties;
import edu.uci.ics.asterix.common.configuration.AsterixConfiguration;
import edu.uci.ics.asterix.common.configuration.Property;
import edu.uci.ics.asterix.event.schema.cluster.Cluster;
@@ -26,9 +27,10 @@
public class AsterixInstance implements Serializable {
- private static final long serialVersionUID = 2874439550187520449L;
+ private static final long serialVersionUID = 1L;
-
+ private static final int WEB_INTERFACE_PORT_DEFAULT = 19001;
+
public enum State {
ACTIVE,
INACTIVE,
@@ -45,7 +47,6 @@
private final String metadataNodeId;
private final String asterixVersion;
private final List<BackupInfo> backupInfo;
- private final String webInterfaceUrl;
private AsterixRuntimeState runtimeState;
private State previousState;
@@ -60,7 +61,7 @@
this.asterixVersion = asterixVersion;
this.createdTimestamp = new Date();
this.backupInfo = new ArrayList<BackupInfo>();
- this.webInterfaceUrl = "http://" + cluster.getMasterNode().getClientIp() + ":" + 19001;
+
}
public Date getModifiedTimestamp() {
@@ -112,7 +113,8 @@
StringBuffer buffer = new StringBuffer();
buffer.append("Name:" + name + "\n");
buffer.append("Created:" + createdTimestamp + "\n");
- buffer.append("Web-Url:" + webInterfaceUrl + "\n");
+
+ buffer.append("Web-Url:" + getWebInterfaceUrl() + "\n");
buffer.append("State:" + state);
if (!state.equals(State.UNUSABLE) && stateChangeTimestamp != null) {
buffer.append(" (" + stateChangeTimestamp + ")" + "\n");
@@ -137,7 +139,13 @@
}
public String getWebInterfaceUrl() {
- return webInterfaceUrl;
+ int webPort = WEB_INTERFACE_PORT_DEFAULT;
+ for (Property p : asterixConfiguration.getProperty()) {
+ if (p.getName().equalsIgnoreCase("web.port")) {
+ webPort = Integer.parseInt(p.getValue());
+ }
+ }
+ return "http://" + cluster.getMasterNode().getClientIp() + ":" + webPort;
}
public AsterixRuntimeState getAsterixRuntimeState() {
@@ -170,12 +178,29 @@
buffer.append("\n");
buffer.append("Asterix Configuration\n");
+ int lenMax = 0;
for (Property property : asterixConfiguration.getProperty()) {
- buffer.append(property.getName() + ":" + property.getValue() + "\n");
+ int nextLen = property.getName().length();
+ if (nextLen > lenMax) {
+ lenMax = nextLen;
+ }
+ }
+ for (Property property : asterixConfiguration.getProperty()) {
+ buffer.append(property.getName() + getIndentation(property.getName(), lenMax) + ":" + property.getValue()
+ + "\n");
}
}
+ private String getIndentation(String name, int lenMax) {
+ int len = name.length();
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < lenMax - len; i++) {
+ buf.append(" ");
+ }
+ return buf.toString();
+ }
+
public State getPreviousState() {
return previousState;
}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/EventList.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/EventList.java
index e8e7513..91592e7 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/EventList.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/EventList.java
@@ -28,6 +28,7 @@
FILE_TRANSFER,
FILE_CREATE,
DIRECTORY_TRANSFER,
+ DIRECTORY_COPY,
NODE_INFO
}
}
diff --git a/asterix-installer/src/main/resources/clusters/local/local.xml b/asterix-installer/src/main/resources/clusters/local/local.xml
index 70debe4..9b00486 100644
--- a/asterix-installer/src/main/resources/clusters/local/local.xml
+++ b/asterix-installer/src/main/resources/clusters/local/local.xml
@@ -13,23 +13,26 @@
! limitations under the License.
!-->
<cluster xmlns="cluster">
- <name>local</name>
- <working_dir>
- <dir>/tmp/asterix-installer</dir>
- <NFS>true</NFS>
- </working_dir>
- <log_dir>/tmp/asterix/logs</log_dir>
- <txn_log_dir>/tmp/asterix/logs</txn_log_dir>
- <iodevices>/tmp</iodevices>
- <store>asterix/storage</store>
- <java_home></java_home>
- <master_node>
- <id>master</id>
- <client_ip>127.0.0.1</client_ip>
- <cluster_ip>127.0.0.1</cluster_ip>
- </master_node>
- <node>
- <id>node1</id>
- <cluster_ip>127.0.0.1</cluster_ip>
- </node>
+ <name>local</name>
+ <working_dir>
+ <dir>/tmp/asterix-installer</dir>
+ <NFS>true</NFS>
+ </working_dir>
+ <log_dir>/tmp/asterix/logs</log_dir>
+ <txn_log_dir>/tmp/asterix/logs</txn_log_dir>
+ <iodevices>/tmp</iodevices>
+ <store>asterix/storage</store>
+ <java_home></java_home>
+ <master_node>
+ <id>master</id>
+ <client_ip>127.0.0.1</client_ip>
+ <cluster_ip>127.0.0.1</cluster_ip>
+ <cluster_port>1099</cluster_port>
+ <client_port>1098</client_port>
+ <http_port>8888</http_port>
+ </master_node>
+ <node>
+ <id>node1</id>
+ <cluster_ip>127.0.0.1</cluster_ip>
+ </node>
</cluster>
diff --git a/asterix-installer/src/main/resources/conf/asterix-configuration.xml b/asterix-installer/src/main/resources/conf/asterix-configuration.xml
index 4d57fc2..e542efd 100644
--- a/asterix-installer/src/main/resources/conf/asterix-configuration.xml
+++ b/asterix-installer/src/main/resources/conf/asterix-configuration.xml
@@ -94,14 +94,6 @@
</property>
<property>
- <name>txn.log.directory</name>
- <value>asterix_logs/</value>
- <description>The directory location for transaction logs. (Default =
- "asterix_logs/")
- </description>
- </property>
-
- <property>
<name>txn.log.buffer.numpages</name>
<value>8</value>
<description>The number of in-memory log buffer pages. (Default = "8")
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ATypeTag.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ATypeTag.java
index be64e4e..d0cf2f2 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ATypeTag.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ATypeTag.java
@@ -35,7 +35,7 @@
FLOAT(11),
DOUBLE(12),
STRING(13),
- NULL(14),
+ NULL(14),
BOOLEAN(15),
DATETIME(16),
DATE(17),
@@ -71,4 +71,6 @@
return value;
}
+ public final static int TYPE_COUNT = ATypeTag.values().length;
+
}
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/ATypeHierarchy.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/ATypeHierarchy.java
new file mode 100644
index 0000000..254a904
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/ATypeHierarchy.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ *
+ * 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 edu.uci.ics.asterix.om.types.hierachy;
+
+import java.util.BitSet;
+import java.util.HashMap;
+
+import edu.uci.ics.asterix.om.types.ATypeTag;
+
+public class ATypeHierarchy {
+
+ private static BitSet typeHierachyMap = new BitSet(ATypeTag.TYPE_COUNT * ATypeTag.TYPE_COUNT);
+ private static HashMap<Integer, ITypePromoteComputer> promoteComputerMap = new HashMap<Integer, ITypePromoteComputer>();
+
+ // allow type promotion to the type itself
+ static {
+ for (int i = 0; i < ATypeTag.TYPE_COUNT; i++) {
+ typeHierachyMap.set(i * ATypeTag.TYPE_COUNT + i);
+ }
+ }
+
+ // add default type promotion rules
+ static {
+ addPromotionRule(ATypeTag.INT8, ATypeTag.INT16, IntegerToInt16TypePromoteComputer.INSTANCE);
+ addPromotionRule(ATypeTag.INT8, ATypeTag.INT32, IntegerToInt32TypePromoteComputer.INSTANCE);
+ addPromotionRule(ATypeTag.INT8, ATypeTag.INT64, IntegerToInt64TypePromoteComputer.INSTANCE);
+ addPromotionRule(ATypeTag.INT16, ATypeTag.INT32, IntegerToInt32TypePromoteComputer.INSTANCE);
+ addPromotionRule(ATypeTag.INT16, ATypeTag.INT64, IntegerToInt64TypePromoteComputer.INSTANCE);
+ addPromotionRule(ATypeTag.INT32, ATypeTag.INT64, IntegerToInt64TypePromoteComputer.INSTANCE);
+ addPromotionRule(ATypeTag.INT8, ATypeTag.DOUBLE, IntegerToDoubleTypePromoteComputer.INSTANCE);
+ addPromotionRule(ATypeTag.INT16, ATypeTag.DOUBLE, IntegerToDoubleTypePromoteComputer.INSTANCE);
+ addPromotionRule(ATypeTag.INT32, ATypeTag.DOUBLE, IntegerToDoubleTypePromoteComputer.INSTANCE);
+ addPromotionRule(ATypeTag.INT64, ATypeTag.DOUBLE, IntegerToDoubleTypePromoteComputer.INSTANCE);
+ addPromotionRule(ATypeTag.FLOAT, ATypeTag.DOUBLE, FloatToDoubleTypePromoteComputer.INSTANCE);
+ addPromotionRule(ATypeTag.INT8, ATypeTag.FLOAT, IntegerToFloatTypePromoteComputer.INSTANCE);
+ addPromotionRule(ATypeTag.INT16, ATypeTag.FLOAT, IntegerToFloatTypePromoteComputer.INSTANCE);
+ addPromotionRule(ATypeTag.INT32, ATypeTag.FLOAT, IntegerToFloatTypePromoteComputer.INSTANCE);
+ }
+
+ public static void addPromotionRule(ATypeTag type1, ATypeTag type2, ITypePromoteComputer promoteComputer) {
+ int index = type1.ordinal() * ATypeTag.TYPE_COUNT + type2.ordinal();
+ typeHierachyMap.set(index);
+ promoteComputerMap.put(index, promoteComputer);
+ }
+
+ public static ITypePromoteComputer getTypePromoteComputer(ATypeTag type1, ATypeTag type2) {
+ if (canPromote(type1, type2)) {
+ return promoteComputerMap.get(type1.ordinal() * ATypeTag.TYPE_COUNT + type2.ordinal());
+ }
+ return null;
+ }
+
+ public static boolean canPromote(ATypeTag type1, ATypeTag type2) {
+ return typeHierachyMap.get(type1.ordinal() * ATypeTag.TYPE_COUNT + type2.ordinal());
+ }
+
+ public static boolean isCompatible(ATypeTag type1, ATypeTag type2) {
+ return canPromote(type1, type2) | canPromote(type2, type1);
+ }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/AbstractIntegerTypePromoteComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/AbstractIntegerTypePromoteComputer.java
new file mode 100644
index 0000000..12bfaf4
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/AbstractIntegerTypePromoteComputer.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ *
+ * 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 edu.uci.ics.asterix.om.types.hierachy;
+
+import java.io.IOException;
+
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.hyracks.data.std.api.IMutableValueStorage;
+
+public abstract class AbstractIntegerTypePromoteComputer implements ITypePromoteComputer {
+
+ public void promoteIntegerType(byte[] data, int start, int length, IMutableValueStorage storageForPromotedValue,
+ ATypeTag targetType, int targetTypeLength) throws IOException {
+ storageForPromotedValue.getDataOutput().writeByte(targetType.serialize());
+ long num = 0;
+ for (int i = start; i < start + length; i++) {
+ num += (data[i] & 0xff) << ((length - 1 - (i - start)) * 8);
+ }
+
+ for (int i = targetTypeLength - 1; i >= 0; i--) {
+ storageForPromotedValue.getDataOutput().writeByte((byte)((num >>> (i * 8)) & 0xFF));
+ }
+ }
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/FloatToDoubleTypePromoteComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/FloatToDoubleTypePromoteComputer.java
new file mode 100644
index 0000000..a3cfbc8
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/FloatToDoubleTypePromoteComputer.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ *
+ * 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 edu.uci.ics.asterix.om.types.hierachy;
+
+import java.io.IOException;
+
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.hyracks.data.std.api.IMutableValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.marshalling.DoubleSerializerDeserializer;
+import edu.uci.ics.hyracks.dataflow.common.data.marshalling.FloatSerializerDeserializer;
+
+public class FloatToDoubleTypePromoteComputer implements ITypePromoteComputer {
+
+ public static final FloatToDoubleTypePromoteComputer INSTANCE = new FloatToDoubleTypePromoteComputer();
+
+ private FloatToDoubleTypePromoteComputer() {
+
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.om.types.hierachy.ITypePromoteComputer#promote(byte[], int, int, edu.uci.ics.hyracks.data.std.api.IMutableValueStorage)
+ */
+ @Override
+ public void promote(byte[] data, int start, int length, IMutableValueStorage storageForPromotedValue)
+ throws IOException {
+ storageForPromotedValue.getDataOutput().writeByte(ATypeTag.DOUBLE.serialize());
+ DoubleSerializerDeserializer.INSTANCE.serialize((double) (FloatSerializerDeserializer.getFloat(data, start)),
+ storageForPromotedValue.getDataOutput());
+ }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/ITypePromoteComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/ITypePromoteComputer.java
new file mode 100644
index 0000000..e8612af
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/ITypePromoteComputer.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ *
+ * 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 edu.uci.ics.asterix.om.types.hierachy;
+
+import java.io.IOException;
+
+import edu.uci.ics.hyracks.data.std.api.IMutableValueStorage;
+
+public interface ITypePromoteComputer {
+
+ void promote(byte[] data, int start, int length, IMutableValueStorage storageForPromotedValue) throws IOException;
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/IntegerToDoubleTypePromoteComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/IntegerToDoubleTypePromoteComputer.java
new file mode 100644
index 0000000..014dc2a
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/IntegerToDoubleTypePromoteComputer.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ *
+ * 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 edu.uci.ics.asterix.om.types.hierachy;
+
+import java.io.IOException;
+
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.hyracks.data.std.api.IMutableValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.marshalling.DoubleSerializerDeserializer;
+
+public class IntegerToDoubleTypePromoteComputer implements ITypePromoteComputer {
+
+ public static final IntegerToDoubleTypePromoteComputer INSTANCE = new IntegerToDoubleTypePromoteComputer();
+
+ private IntegerToDoubleTypePromoteComputer() {
+
+ }
+
+ @Override
+ public void promote(byte[] data, int start, int length, IMutableValueStorage storageForPromotedValue)
+ throws IOException {
+ storageForPromotedValue.getDataOutput().writeByte(ATypeTag.DOUBLE.serialize());
+ long val = 0L;
+ for (int i = 0; i < length; i++) {
+ val += ((long)(data[start + i] & 0xff)) << (8 * (length - 1 - i));
+ }
+ DoubleSerializerDeserializer.INSTANCE.serialize(Double.valueOf(val), storageForPromotedValue.getDataOutput());
+ }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/IntegerToFloatTypePromoteComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/IntegerToFloatTypePromoteComputer.java
new file mode 100644
index 0000000..c1bd9e5
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/IntegerToFloatTypePromoteComputer.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ *
+ * 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 edu.uci.ics.asterix.om.types.hierachy;
+
+import java.io.IOException;
+
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.hyracks.data.std.api.IMutableValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.marshalling.FloatSerializerDeserializer;
+
+public class IntegerToFloatTypePromoteComputer implements ITypePromoteComputer {
+
+ public static final IntegerToFloatTypePromoteComputer INSTANCE = new IntegerToFloatTypePromoteComputer();
+
+ private IntegerToFloatTypePromoteComputer() {
+
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.om.types.hierachy.ITypePromoteComputer#promote(byte[], int, int, edu.uci.ics.hyracks.data.std.api.IMutableValueStorage)
+ */
+ @Override
+ public void promote(byte[] data, int start, int length, IMutableValueStorage storageForPromotedValue)
+ throws IOException {
+ storageForPromotedValue.getDataOutput().writeByte(ATypeTag.FLOAT.serialize());
+ float val = 0;
+ for (int i = 0; i < length; i++) {
+ val += (data[start + i] & 0xff) << (8 * (length - 1 - i));
+ }
+ FloatSerializerDeserializer.INSTANCE.serialize(val, storageForPromotedValue.getDataOutput());
+
+ }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/IntegerToInt16TypePromoteComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/IntegerToInt16TypePromoteComputer.java
new file mode 100644
index 0000000..8835a57
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/IntegerToInt16TypePromoteComputer.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ *
+ * 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 edu.uci.ics.asterix.om.types.hierachy;
+
+import java.io.IOException;
+
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.hyracks.data.std.api.IMutableValueStorage;
+
+public class IntegerToInt16TypePromoteComputer extends AbstractIntegerTypePromoteComputer {
+
+ public static final IntegerToInt16TypePromoteComputer INSTANCE = new IntegerToInt16TypePromoteComputer();
+
+ private IntegerToInt16TypePromoteComputer() {
+
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.om.types.hierachy.ITypePromoteComputer#promote(byte[], int, int, edu.uci.ics.hyracks.data.std.api.IMutableValueStorage)
+ */
+ @Override
+ public void promote(byte[] data, int start, int length, IMutableValueStorage storageForPromotedValue)
+ throws IOException {
+ promoteIntegerType(data, start, length, storageForPromotedValue, ATypeTag.INT16, 2);
+ }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/IntegerToInt32TypePromoteComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/IntegerToInt32TypePromoteComputer.java
new file mode 100644
index 0000000..8a808bf
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/IntegerToInt32TypePromoteComputer.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ *
+ * 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 edu.uci.ics.asterix.om.types.hierachy;
+
+import java.io.IOException;
+
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.hyracks.data.std.api.IMutableValueStorage;
+
+public class IntegerToInt32TypePromoteComputer extends AbstractIntegerTypePromoteComputer {
+
+ public static final IntegerToInt32TypePromoteComputer INSTANCE = new IntegerToInt32TypePromoteComputer();
+
+ private IntegerToInt32TypePromoteComputer() {
+ }
+
+ @Override
+ public void promote(byte[] data, int start, int length, IMutableValueStorage storageForPromotedValue)
+ throws IOException {
+ promoteIntegerType(data, start, length, storageForPromotedValue, ATypeTag.INT32, 4);
+ }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/IntegerToInt64TypePromoteComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/IntegerToInt64TypePromoteComputer.java
new file mode 100644
index 0000000..b24604d
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/hierachy/IntegerToInt64TypePromoteComputer.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ *
+ * 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 edu.uci.ics.asterix.om.types.hierachy;
+
+import java.io.IOException;
+
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.hyracks.data.std.api.IMutableValueStorage;
+
+public class IntegerToInt64TypePromoteComputer extends AbstractIntegerTypePromoteComputer {
+
+ public static final IntegerToInt64TypePromoteComputer INSTANCE = new IntegerToInt64TypePromoteComputer();
+
+ private IntegerToInt64TypePromoteComputer() {
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.om.types.hierachy.ITypePromoteComputer#promote(byte[], int, int, edu.uci.ics.hyracks.data.std.api.IMutableValueStorage)
+ */
+ @Override
+ public void promote(byte[] data, int start, int length, IMutableValueStorage storageForPromotedValue)
+ throws IOException {
+ promoteIntegerType(data, start, length, storageForPromotedValue, ATypeTag.INT64, 8);
+ }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java
index 93c7026..7815606 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/AvgAggregateDescriptor.java
@@ -31,9 +31,9 @@
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.om.base.ADouble;
-import edu.uci.ics.asterix.om.base.AInt32;
+import edu.uci.ics.asterix.om.base.AInt64;
import edu.uci.ics.asterix.om.base.AMutableDouble;
-import edu.uci.ics.asterix.om.base.AMutableInt32;
+import edu.uci.ics.asterix.om.base.AMutableInt64;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -44,6 +44,7 @@
import edu.uci.ics.asterix.om.types.BuiltinType;
import edu.uci.ics.asterix.om.types.EnumDeserializer;
import edu.uci.ics.asterix.om.types.IAType;
+import edu.uci.ics.asterix.om.types.hierachy.ATypeHierarchy;
import edu.uci.ics.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.common.AccessibleByteArrayEval;
import edu.uci.ics.asterix.runtime.evaluators.common.ClosedRecordConstructorEvalFactory.ClosedRecordConstructorEval;
@@ -83,7 +84,7 @@
ARecordType tmpRecType;
try {
tmpRecType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
- new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, true);
+ new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT64 }, true);
} catch (AsterixException e) {
throw new AlgebricksException(e);
}
@@ -103,10 +104,10 @@
private ArrayBackedValueStorage inputVal = new ArrayBackedValueStorage();
private ICopyEvaluator eval = args[0].createEvaluator(inputVal);
private double sum;
- private int count;
+ private long count;
private ATypeTag aggType;
private AMutableDouble aDouble = new AMutableDouble(0);
- private AMutableInt32 aInt32 = new AMutableInt32(0);
+ private AMutableInt64 aInt64 = new AMutableInt64(0);
private ArrayBackedValueStorage avgBytes = new ArrayBackedValueStorage();
private ByteArrayAccessibleOutputStream sumBytes = new ByteArrayAccessibleOutputStream();
@@ -122,8 +123,8 @@
private ISerializerDeserializer<ADouble> doubleSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADOUBLE);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<AInt32> intSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.AINT32);
+ private ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.AINT64);
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
@@ -146,10 +147,13 @@
return;
} else if (aggType == ATypeTag.SYSTEM_NULL) {
aggType = typeTag;
- } else if (typeTag != ATypeTag.SYSTEM_NULL && typeTag != aggType) {
+ } else if (typeTag != ATypeTag.SYSTEM_NULL && !ATypeHierarchy.isCompatible(typeTag, aggType)) {
throw new AlgebricksException("Unexpected type " + typeTag
+ " in aggregation input stream. Expected type " + aggType + ".");
+ } else if (ATypeHierarchy.canPromote(aggType, typeTag)) {
+ aggType = typeTag;
}
+
if (typeTag != ATypeTag.SYSTEM_NULL) {
++count;
}
@@ -224,8 +228,8 @@
doubleSerde.serialize(aDouble, sumBytesOutput);
}
countBytes.reset();
- aInt32.setValue(count);
- intSerde.serialize(aInt32, countBytesOutput);
+ aInt64.setValue(count);
+ intSerde.serialize(aInt64, countBytesOutput);
recordEval.evaluate(null);
} catch (IOException e) {
throw new AlgebricksException(e);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/GlobalAvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/GlobalAvgAggregateDescriptor.java
index d262ef4..eb5d6bd 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/GlobalAvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/GlobalAvgAggregateDescriptor.java
@@ -23,13 +23,13 @@
import edu.uci.ics.asterix.common.exceptions.AsterixException;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ARecordSerializerDeserializer;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.om.base.ADouble;
-import edu.uci.ics.asterix.om.base.AInt32;
+import edu.uci.ics.asterix.om.base.AInt64;
import edu.uci.ics.asterix.om.base.AMutableDouble;
-import edu.uci.ics.asterix.om.base.AMutableInt32;
+import edu.uci.ics.asterix.om.base.AMutableInt64;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -79,7 +79,7 @@
ARecordType tmpRecType;
try {
tmpRecType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
- new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, false);
+ new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT64 }, false);
} catch (AsterixException e) {
throw new AlgebricksException(e);
}
@@ -99,9 +99,9 @@
private ArrayBackedValueStorage inputVal = new ArrayBackedValueStorage();
private ICopyEvaluator eval = args[0].createEvaluator(inputVal);
private double globalSum;
- private int globalCount;
+ private long globalCount;
private AMutableDouble aDouble = new AMutableDouble(0);
- private AMutableInt32 aInt32 = new AMutableInt32(0);
+ private AMutableInt64 aInt64 = new AMutableInt64(0);
private ArrayBackedValueStorage avgBytes = new ArrayBackedValueStorage();
private ByteArrayAccessibleOutputStream sumBytes = new ByteArrayAccessibleOutputStream();
@@ -114,8 +114,8 @@
new ICopyEvaluator[] { evalSum, evalCount }, avgBytes, out);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<AInt32> intSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.AINT32);
+ private ISerializerDeserializer<AInt64> longSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.AINT64);
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADouble> doubleSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADOUBLE);
@@ -171,7 +171,7 @@
int offset2 = ARecordSerializerDeserializer.getFieldOffsetById(serBytes, 1, nullBitmapSize,
false);
if (offset2 != 0) // the count is not null
- globalCount += AInt32SerializerDeserializer.getInt(serBytes, offset2);
+ globalCount += AInt64SerializerDeserializer.getLong(serBytes, offset2);
}
@@ -201,8 +201,8 @@
doubleSerde.serialize(aDouble, sumBytesOutput);
}
countBytes.reset();
- aInt32.setValue(globalCount);
- intSerde.serialize(aInt32, countBytesOutput);
+ aInt64.setValue(globalCount);
+ longSerde.serialize(aInt64, countBytesOutput);
recordEval.evaluate(null);
} catch (IOException e) {
throw new AlgebricksException(e);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalAvgAggregateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalAvgAggregateDescriptor.java
index 5400d78..256af09 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalAvgAggregateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/LocalAvgAggregateDescriptor.java
@@ -30,9 +30,9 @@
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.om.base.ADouble;
-import edu.uci.ics.asterix.om.base.AInt32;
+import edu.uci.ics.asterix.om.base.AInt64;
import edu.uci.ics.asterix.om.base.AMutableDouble;
-import edu.uci.ics.asterix.om.base.AMutableInt32;
+import edu.uci.ics.asterix.om.base.AMutableInt64;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -43,6 +43,7 @@
import edu.uci.ics.asterix.om.types.BuiltinType;
import edu.uci.ics.asterix.om.types.EnumDeserializer;
import edu.uci.ics.asterix.om.types.IAType;
+import edu.uci.ics.asterix.om.types.hierachy.ATypeHierarchy;
import edu.uci.ics.asterix.runtime.aggregates.base.AbstractAggregateFunctionDynamicDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.common.AccessibleByteArrayEval;
import edu.uci.ics.asterix.runtime.evaluators.common.ClosedRecordConstructorEvalFactory.ClosedRecordConstructorEval;
@@ -90,7 +91,7 @@
ARecordType tmpRecType;
try {
tmpRecType = new ARecordType(null, new String[] { "sum", "count" }, new IAType[] {
- new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT32 }, false);
+ new AUnionType(unionList, "OptionalDouble"), BuiltinType.AINT64 }, false);
} catch (AsterixException e) {
throw new AlgebricksException(e);
}
@@ -104,7 +105,7 @@
private ICopyEvaluator eval = args[0].createEvaluator(inputVal);
private ATypeTag aggType;
private double sum;
- private int count;
+ private long count;
private ArrayBackedValueStorage avgBytes = new ArrayBackedValueStorage();
private ByteArrayAccessibleOutputStream sumBytes = new ByteArrayAccessibleOutputStream();
@@ -119,13 +120,13 @@
private ISerializerDeserializer<ADouble> doubleSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADOUBLE);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<AInt32> int32Serde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.AINT32);
+ private ISerializerDeserializer<AInt64> longSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.AINT64);
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
private AMutableDouble aDouble = new AMutableDouble(0);
- private AMutableInt32 aInt32 = new AMutableInt32(0);
+ private AMutableInt64 aInt64 = new AMutableInt64(0);
@Override
public void init() {
@@ -145,13 +146,17 @@
return;
} else if (aggType == ATypeTag.SYSTEM_NULL) {
aggType = typeTag;
- } else if (typeTag != ATypeTag.SYSTEM_NULL && typeTag != aggType) {
+ } else if (typeTag != ATypeTag.SYSTEM_NULL && !ATypeHierarchy.isCompatible(typeTag, aggType)) {
throw new AlgebricksException("Unexpected type " + typeTag
+ " in aggregation input stream. Expected type " + aggType + ".");
+ } else if (ATypeHierarchy.canPromote(aggType, typeTag)) {
+ aggType = typeTag;
}
+
if (typeTag != ATypeTag.SYSTEM_NULL) {
++count;
}
+
switch (typeTag) {
case INT8: {
byte val = AInt8SerializerDeserializer.getByte(inputVal.getByteArray(), 1);
@@ -197,7 +202,7 @@
@Override
public void finish() throws AlgebricksException {
try {
- if (count == 0) {
+ if (count == 0 && aggType != ATypeTag.NULL) {
out.writeByte(ATypeTag.SYSTEM_NULL.serialize());
return;
}
@@ -210,8 +215,8 @@
doubleSerde.serialize(aDouble, sumBytesOutput);
}
countBytes.reset();
- aInt32.setValue(count);
- int32Serde.serialize(aInt32, countBytesOutput);
+ aInt64.setValue(count);
+ longSerde.serialize(aInt64, countBytesOutput);
recordEval.evaluate(null);
} catch (IOException e) {
throw new AlgebricksException(e);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/MinMaxAggregateFunction.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/MinMaxAggregateFunction.java
index 9e214f4..95aba92 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/MinMaxAggregateFunction.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/MinMaxAggregateFunction.java
@@ -20,6 +20,8 @@
import edu.uci.ics.asterix.formats.nontagged.AqlBinaryComparatorFactoryProvider;
import edu.uci.ics.asterix.om.types.ATypeTag;
import edu.uci.ics.asterix.om.types.EnumDeserializer;
+import edu.uci.ics.asterix.om.types.hierachy.ATypeHierarchy;
+import edu.uci.ics.asterix.om.types.hierachy.ITypePromoteComputer;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyAggregateFunction;
import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
@@ -33,10 +35,12 @@
public class MinMaxAggregateFunction implements ICopyAggregateFunction {
private ArrayBackedValueStorage inputVal = new ArrayBackedValueStorage();
private ArrayBackedValueStorage outputVal = new ArrayBackedValueStorage();
+ private ArrayBackedValueStorage tempValForCasting = new ArrayBackedValueStorage();
private DataOutput out;
private ICopyEvaluator eval;
private ATypeTag aggType;
private IBinaryComparator cmp;
+ private ITypePromoteComputer tpc;
private final boolean isMin;
private final boolean isLocalAgg;
@@ -52,6 +56,7 @@
public void init() {
aggType = ATypeTag.SYSTEM_NULL;
outputVal.reset();
+ tempValForCasting.reset();
}
@Override
@@ -76,13 +81,54 @@
cmp = cmpFactory.createBinaryComparator();
// Initialize min value.
outputVal.assign(inputVal);
- } else if (typeTag != ATypeTag.SYSTEM_NULL && typeTag != aggType) {
+ } else if (typeTag != ATypeTag.SYSTEM_NULL && !ATypeHierarchy.isCompatible(typeTag, aggType)) {
throw new AlgebricksException("Unexpected type " + typeTag + " in aggregation input stream. Expected type "
+ aggType + ".");
- }
- if (cmp.compare(inputVal.getByteArray(), inputVal.getStartOffset(), inputVal.getLength(),
- outputVal.getByteArray(), outputVal.getStartOffset(), outputVal.getLength()) < 0) {
- outputVal.assign(inputVal);
+ } else {
+ if (ATypeHierarchy.canPromote(aggType, typeTag)) {
+ tpc = ATypeHierarchy.getTypePromoteComputer(aggType, typeTag);
+ aggType = typeTag;
+ cmp = AqlBinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(aggType, isMin)
+ .createBinaryComparator();
+ if (tpc != null) {
+ tempValForCasting.reset();
+ try {
+ tpc.promote(outputVal.getByteArray(), outputVal.getStartOffset() + 1, outputVal.getLength() - 1,
+ tempValForCasting);
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
+ outputVal.reset();
+ outputVal.assign(tempValForCasting);
+ }
+ if (cmp.compare(inputVal.getByteArray(), inputVal.getStartOffset(), inputVal.getLength(),
+ outputVal.getByteArray(), outputVal.getStartOffset(), outputVal.getLength()) < 0) {
+ outputVal.assign(inputVal);
+ }
+
+ } else {
+ tpc = ATypeHierarchy.getTypePromoteComputer(typeTag, aggType);
+ if (tpc != null) {
+ tempValForCasting.reset();
+ try {
+ tpc.promote(inputVal.getByteArray(), inputVal.getStartOffset() + 1, inputVal.getLength() - 1,
+ tempValForCasting);
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
+ if (cmp.compare(tempValForCasting.getByteArray(), tempValForCasting.getStartOffset(),
+ tempValForCasting.getLength(), outputVal.getByteArray(), outputVal.getStartOffset(),
+ outputVal.getLength()) < 0) {
+ outputVal.assign(tempValForCasting);
+ }
+ } else {
+ if (cmp.compare(inputVal.getByteArray(), inputVal.getStartOffset(), inputVal.getLength(),
+ outputVal.getByteArray(), outputVal.getStartOffset(), outputVal.getLength()) < 0) {
+ outputVal.assign(inputVal);
+ }
+ }
+
+ }
}
}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/SumAggregateFunction.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/SumAggregateFunction.java
index 752036e..31ad055 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/SumAggregateFunction.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/aggregates/std/SumAggregateFunction.java
@@ -34,6 +34,7 @@
import edu.uci.ics.asterix.om.types.ATypeTag;
import edu.uci.ics.asterix.om.types.BuiltinType;
import edu.uci.ics.asterix.om.types.EnumDeserializer;
+import edu.uci.ics.asterix.om.types.hierachy.ATypeHierarchy;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
import edu.uci.ics.hyracks.algebricks.common.exceptions.NotImplementedException;
import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyAggregateFunction;
@@ -84,10 +85,15 @@
return;
} else if (aggType == ATypeTag.SYSTEM_NULL) {
aggType = typeTag;
- } else if (typeTag != ATypeTag.SYSTEM_NULL && typeTag != aggType) {
+ } else if (typeTag != ATypeTag.SYSTEM_NULL && !ATypeHierarchy.isCompatible(typeTag, aggType)) {
throw new AlgebricksException("Unexpected type " + typeTag
- + " in aggregation input stream. Expected type " + aggType + ".");
+ + " in aggregation input stream. Expected type (or a promotable type to)" + aggType + ".");
}
+
+ if (ATypeHierarchy.canPromote(aggType, typeTag)) {
+ aggType = typeTag;
+ }
+
switch (typeTag) {
case INT8: {
byte val = AInt8SerializerDeserializer.getByte(inputVal.getByteArray(), 1);
@@ -193,6 +199,9 @@
}
break;
}
+ default:
+ throw new AlgebricksException("SumAggregationFunction: incompatible type for the result ("
+ + aggType + "). ");
}
} catch (IOException e) {
throw new AlgebricksException(e);
diff --git a/asterix-transactions/.gitignore b/asterix-transactions/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/asterix-transactions/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/PersistentLocalResourceRepository.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/PersistentLocalResourceRepository.java
index 2761555..3b6c650 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/PersistentLocalResourceRepository.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/PersistentLocalResourceRepository.java
@@ -64,7 +64,8 @@
}
private String prepareRootMetaDataFileName(String mountPoint, String nodeId, int ioDeviceId) {
- return mountPoint + ROOT_METADATA_DIRECTORY + "_" + nodeId + "_" + "iodevice" + ioDeviceId;
+ return mountPoint + File.separator + ROOT_METADATA_DIRECTORY + File.separator +
+ nodeId + "_" + "iodevice" + ioDeviceId;
}
public void initialize(String nodeId, String rootDir, boolean isNewUniverse, ResourceIdFactory resourceIdFactory)
@@ -82,7 +83,13 @@
File rootMetadataDir = new File(prepareRootMetaDataFileName(mountPoints[i], nodeId, i));
if (!rootMetadataDir.exists()) {
- rootMetadataDir.mkdir();
+ boolean success = rootMetadataDir.mkdirs();
+ if (!success) {
+ if (LOGGER.isLoggable(Level.SEVERE)) {
+ LOGGER.severe("Unable to create root metadata directory"
+ + rootMetadataDir.getAbsolutePath());
+ }
+ }
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("created the root-metadata-file's directory: " + rootMetadataDir.getAbsolutePath());
}