Temporal update based on a merge from an old branch.
Includes the following new functions: overlap-bins, get-overlapping-interval, get-interval-start-date, get-interval-start-datetime, get-interval-start-time, get-interval-end-date, get-interval-end-datetime, get-interval-end-time
Change-Id: Ie15ed39ae7de83ce71c63c4e7490f2ebf5911540
Reviewed-on: http://fulliautomatix.ics.uci.edu:8443/244
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Ildar Absalyamov <ildar.absalyamov@gmail.com>
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java
index ebc98fe..7e58a9c 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java
@@ -65,6 +65,7 @@
import edu.uci.ics.asterix.optimizer.rules.am.IntroduceJoinAccessMethodRule;
import edu.uci.ics.asterix.optimizer.rules.am.IntroduceLSMComponentFilterRule;
import edu.uci.ics.asterix.optimizer.rules.am.IntroduceSelectAccessMethodRule;
+import edu.uci.ics.asterix.optimizer.rules.temporal.TranslateIntervalExpressionRule;
import edu.uci.ics.hyracks.algebricks.core.rewriter.base.HeuristicOptimizer;
import edu.uci.ics.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule;
import edu.uci.ics.hyracks.algebricks.rewriter.rules.BreakSelectIntoConjunctsRule;
@@ -117,6 +118,12 @@
public final class RuleCollections {
+ public final static List<IAlgebraicRewriteRule> buildInitialTranslationRuleCollection() {
+ List<IAlgebraicRewriteRule> typeInfer = new LinkedList<IAlgebraicRewriteRule>();
+ typeInfer.add(new TranslateIntervalExpressionRule());
+ return typeInfer;
+ }
+
public final static List<IAlgebraicRewriteRule> buildTypeInferenceRuleCollection() {
List<IAlgebraicRewriteRule> typeInfer = new LinkedList<IAlgebraicRewriteRule>();
typeInfer.add(new InlineUnnestFunctionRule());
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/temporal/TranslateIntervalExpressionRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/temporal/TranslateIntervalExpressionRule.java
new file mode 100644
index 0000000..9a01920
--- /dev/null
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/temporal/TranslateIntervalExpressionRule.java
@@ -0,0 +1,150 @@
+/*
+ * 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.optimizer.rules.temporal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang3.mutable.Mutable;
+import org.apache.commons.lang3.mutable.MutableObject;
+
+import edu.uci.ics.asterix.aql.util.FunctionUtils;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator;
+import edu.uci.ics.hyracks.algebricks.core.algebra.base.IOptimizationContext;
+import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalExpressionTag;
+import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalOperatorTag;
+import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
+import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator;
+import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.SelectOperator;
+import edu.uci.ics.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule;
+
+/**
+ * Finds interval conditional expressions and convert them to interval start and end conditional statements.
+ * The translation exposes the condition to the Algebricks optimizer.
+ */
+public class TranslateIntervalExpressionRule implements IAlgebraicRewriteRule {
+
+ @Override
+ public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException {
+ return false;
+ }
+
+ @Override
+ public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
+ throws AlgebricksException {
+ AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
+ if (op.getOperatorTag() != LogicalOperatorTag.SELECT) {
+ return false;
+ }
+ SelectOperator selectOp = (SelectOperator) op;
+
+ Mutable<ILogicalExpression> exprRef = selectOp.getCondition();
+ boolean modified = false;
+ ILogicalExpression expr = exprRef.getValue();
+ if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
+ return false;
+ }
+ AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
+ if (funcExpr.getArguments().size() != 2) {
+ return false;
+ }
+ ILogicalExpression interval1 = funcExpr.getArguments().get(0).getValue();
+ ILogicalExpression interval2 = funcExpr.getArguments().get(1).getValue();
+ if (funcExpr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.INTERVAL_MEETS)) {
+ exprRef.setValue(getEqualExpr(getIntervalEndExpr(interval1), getIntervalStartExpr(interval2)));
+ modified = true;
+ } else if (funcExpr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.INTERVAL_MET_BY)) {
+ exprRef.setValue(getEqualExpr(getIntervalStartExpr(interval1), getIntervalEndExpr(interval2)));
+ modified = true;
+ } else if (funcExpr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.INTERVAL_STARTS)) {
+ ILogicalExpression startExpr = getEqualExpr(getIntervalStartExpr(interval1),
+ getIntervalStartExpr(interval2));
+ ILogicalExpression endExpr = getLessThanOrEqualExpr(getIntervalEndExpr(interval1),
+ getIntervalEndExpr(interval2));
+ exprRef.setValue(getAndExpr(startExpr, endExpr));
+ modified = true;
+ } else if (funcExpr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.INTERVAL_STARTED_BY)) {
+ ILogicalExpression startExpr = getEqualExpr(getIntervalStartExpr(interval1),
+ getIntervalStartExpr(interval2));
+ ILogicalExpression endExpr = getLessThanOrEqualExpr(getIntervalEndExpr(interval2),
+ getIntervalEndExpr(interval1));
+ exprRef.setValue(getAndExpr(startExpr, endExpr));
+ modified = true;
+ } else if (funcExpr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.INTERVAL_ENDS)) {
+ ILogicalExpression endExpr = getEqualExpr(getIntervalEndExpr(interval1), getIntervalEndExpr(interval2));
+ ILogicalExpression startExpr = getLessThanOrEqualExpr(getIntervalStartExpr(interval1),
+ getIntervalStartExpr(interval2));
+ exprRef.setValue(getAndExpr(startExpr, endExpr));
+ modified = true;
+ } else if (funcExpr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.INTERVAL_ENDED_BY)) {
+ ILogicalExpression endExpr = getEqualExpr(getIntervalEndExpr(interval1), getIntervalEndExpr(interval2));
+ ILogicalExpression startExpr = getLessThanOrEqualExpr(getIntervalStartExpr(interval2),
+ getIntervalStartExpr(interval1));
+ exprRef.setValue(getAndExpr(startExpr, endExpr));
+ modified = true;
+ } else if (funcExpr.getFunctionInfo().equals(AsterixBuiltinFunctions.INTERVAL_BEFORE)) {
+ // Requires new strategy, no translation for this interval and the remaining listed.
+ } else if (funcExpr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.INTERVAL_AFTER)) {
+ } else if (funcExpr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.INTERVAL_OVERLAPS)) {
+ } else if (funcExpr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.INTERVAL_OVERLAPPED_BY)) {
+ } else if (funcExpr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.INTERVAL_OVERLAPPING)) {
+ } else if (funcExpr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.INTERVAL_COVERS)) {
+ } else if (funcExpr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.INTERVAL_COVERED_BY)) {
+ }
+
+ return modified;
+ }
+
+ private ILogicalExpression getAndExpr(ILogicalExpression arg1, ILogicalExpression arg2) {
+ return getScalarExpr(AlgebricksBuiltinFunctions.AND, arg1, arg2);
+ }
+
+ private ILogicalExpression getEqualExpr(ILogicalExpression arg1, ILogicalExpression arg2) {
+ return getScalarExpr(AlgebricksBuiltinFunctions.EQ, arg1, arg2);
+ }
+
+ private ILogicalExpression getLessThanOrEqualExpr(ILogicalExpression arg1, ILogicalExpression arg2) {
+ return getScalarExpr(AlgebricksBuiltinFunctions.LE, arg1, arg2);
+ }
+
+ private ILogicalExpression getIntervalStartExpr(ILogicalExpression interval) {
+ return getScalarExpr(AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_INTERVAL_START, interval);
+ }
+
+ private ILogicalExpression getIntervalEndExpr(ILogicalExpression interval) {
+ return getScalarExpr(AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_INTERVAL_END, interval);
+ }
+
+ private ILogicalExpression getScalarExpr(FunctionIdentifier func, ILogicalExpression interval) {
+ List<Mutable<ILogicalExpression>> intervalArg = new ArrayList<Mutable<ILogicalExpression>>();
+ intervalArg.add(new MutableObject<ILogicalExpression>(interval));
+ return new ScalarFunctionCallExpression(FunctionUtils.getFunctionInfo(func), intervalArg);
+ }
+
+ private ILogicalExpression getScalarExpr(FunctionIdentifier func, ILogicalExpression interval1,
+ ILogicalExpression interval2) {
+ List<Mutable<ILogicalExpression>> intervalArg = new ArrayList<Mutable<ILogicalExpression>>();
+ intervalArg.add(new MutableObject<ILogicalExpression>(interval1));
+ intervalArg.add(new MutableObject<ILogicalExpression>(interval2));
+ return new ScalarFunctionCallExpression(FunctionUtils.getFunctionInfo(func), intervalArg);
+ }
+
+}
diff --git a/asterix-app/data/temporal/simpletemp_30.json b/asterix-app/data/temporal/simpletemp_30.json
index f0a4582..dcc9d8c 100644
--- a/asterix-app/data/temporal/simpletemp_30.json
+++ b/asterix-app/data/temporal/simpletemp_30.json
@@ -1,3 +1,3 @@
{ "date": date("4619-11-23"), "time": time("14:29:36.786Z"), "datetime": datetime("2749-01-27T17:27:30.020Z"), "duration": duration("-P474133Y7M854630DT4H40M6.45S"), "year-month-duration": year-month-duration("P193989Y3M"), "day-time-duration": day-time-duration("P4477686DT4H49M31.87S"), "date-interval": interval-date("-9537-08-04, 9656-06-03"), "time-interval": interval-time("12:04:45.689Z, 12:41:59.002Z"), "datetime-interval": interval-datetime("-2640-10-11T17:32:15.675Z, 4104-02-01T05:59:11.902Z") }
-{ "date": date("-9971-09-24"), "time": time("11:38:17.154Z"), "datetime": datetime("1259-11-13T09:49:11.852Z"), "duration": duration("P473653Y9M4566143DT10H20M53.61S"), "year-month-duration": year-month-duration("P148233Y10M"), "day-time-duration": day-time-duration("-P7236357DT2H56M56.164S"), "date-interval": interval-date("-0255-09-06, 4925-05-03"), "time-interval": interval-time("23:10:45.169Z, 01:37:48.736Z"), "datetime-interval": interval-datetime("0534-12-08T08:20:31.487Z, 6778-02-16T22:40:21.653Z") }
-{ "date": date("7986-11-25"), "time": time("12:49:39.736Z"), "datetime": datetime("-8337-01-30T15:23:07.598Z"), "duration": duration("-P184484Y7M2241423DT10H42M49.500S"), "year-month-duration": year-month-duration("-P546031Y3M"), "day-time-duration": day-time-duration("P2623386DT10H32M31.983S"), "date-interval": interval-date("-4514-05-24, 3337-08-26"), "time-interval": interval-time("04:16:42.321Z, 02:22:56.816Z"), "datetime-interval": interval-datetime("2129-12-12T13:18:35.758Z, 8647-07-01T13:10:19.691Z") }
+{ "date": date("-9971-09-24"), "time": time("11:38:17.154Z"), "datetime": datetime("1259-11-13T09:49:11.852Z"), "duration": duration("P473653Y9M4566143DT10H20M53.61S"), "year-month-duration": year-month-duration("P148233Y10M"), "day-time-duration": day-time-duration("-P7236357DT2H56M56.164S"), "date-interval": interval-date("-0255-09-06, 4925-05-03"), "time-interval": interval-time("12:10:45.169Z, 15:37:48.736Z"), "datetime-interval": interval-datetime("0534-12-08T08:20:31.487Z, 6778-02-16T22:40:21.653Z") }
+{ "date": date("7986-11-25"), "time": time("12:49:39.736Z"), "datetime": datetime("-8337-01-30T15:23:07.598Z"), "duration": duration("-P184484Y7M2241423DT10H42M49.500S"), "year-month-duration": year-month-duration("-P546031Y3M"), "day-time-duration": day-time-duration("P2623386DT10H32M31.983S"), "date-interval": interval-date("-4514-05-24, 3337-08-26"), "time-interval": interval-time("04:16:42.321Z, 12:22:56.816Z"), "datetime-interval": interval-datetime("2129-12-12T13:18:35.758Z, 8647-07-01T13:10:19.691Z") }
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
index 84a01da..51fef41 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/common/APIFramework.java
@@ -88,6 +88,8 @@
SequentialFixpointRuleController seqCtrlFullDfs = new SequentialFixpointRuleController(true);
SequentialOnceRuleController seqOnceCtrl = new SequentialOnceRuleController(true);
defaultLogicalRewrites.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqOnceCtrl,
+ RuleCollections.buildInitialTranslationRuleCollection()));
+ defaultLogicalRewrites.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqOnceCtrl,
RuleCollections.buildTypeInferenceRuleCollection()));
defaultLogicalRewrites.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqOnceCtrl,
RuleCollections.buildAutogenerateIDRuleCollection()));
diff --git a/asterix-app/src/test/resources/runtimets/queries/string/replace22/replace22.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/string/replace22/replace22.3.query.aql
index df67481..fb000b4 100644
--- a/asterix-app/src/test/resources/runtimets/queries/string/replace22/replace22.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/string/replace22/replace22.3.query.aql
@@ -1,11 +1,11 @@
use dataverse test;
-let $c1 := replace("abracadabra","", null , null)
-let $c2 := replace("abracadabra","bra", "XXX" ,"")
-let $c3 := replace(null,"hello world", "XxXx" , "x")
-let $c4 := replace("abracadabra","bra", "XXX" ,null)
-let $c5 := replace("abracadabra",null, "XXX" ,null)
-let $c6 := replace("abracadabra","Bra", null ,"i")
-let $c7 := replace("abracadabra","Bra", "" ,"i")
-let $c8 := replace("abracadabra","", "XXX" ,"")
+let $c1 := replace("abracadabra", "", null, null)
+let $c2 := replace("abracadabra", "bra", "XXX", "")
+let $c3 := replace(null,"hello world", "XxXx", "x")
+let $c4 := replace("abracadabra", "bra", "XXX", null)
+let $c5 := replace("abracadabra", null, "XXX", null)
+let $c6 := replace("abracadabra", "Bra", null, "i")
+let $c7 := replace("abracadabra", "Bra", "", "i")
+let $c8 := replace("abracadabra", "", "XXX", "")
return {"result1": $c1,"result2": $c2,"result3": $c3,"result4": $c4,"result5": $c5,"result6": $c6,"result7": $c7,"result8": $c8}
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/accessors/accessors.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors/accessors.3.query.aql
index 42cc4a6..da46b09 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temporal/accessors/accessors.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors/accessors.3.query.aql
@@ -8,5 +8,56 @@
let $c6 := time("12:23:34.930+07:00")
let $c7 := string("-0003-01-09T23:12:12.39-07:00")
let $c8 := duration("P3Y73M632DT49H743M3948.94S")
+let $c9 := year-month-duration("P8Y12M")
+let $c10 := day-time-duration("P32DT49H743M3948.94S")
-return {"year1": get-year($c1), "year2": get-year($c2), "year3": get-year($c3), "year4": get-year($c4), "year5": get-year($c5), "year6": get-year($c7), "year7": get-year($c8), "year-null": get-year(null), "month1": get-month($c1), "month2": get-month($c2), "month3": get-month($c3), "month4": get-month($c4), "month5": get-month($c5), "month6": get-month($c8), "month-null": get-month(null), "day1": get-day($c1), "day2": get-day($c2), "day3": get-day($c3), "day4": get-day($c4), "day5": get-day($c5), "day6": get-day($c8), "day-null": get-day(null), "hour1": get-hour($c2), "hour2": get-hour($c5), "hour3": get-hour($c6), "hour4": get-hour($c8), "hour-null": get-hour(null), "min1": get-minute($c2), "min2": get-minute($c5), "min3": get-minute($c6), "min4": get-minute($c8), "min-null": get-minute(null), "second1": get-second($c2), "second2": get-second($c5), "second3": get-second($c6), "second4": get-second($c8), "second-null": get-second(null), "ms1": get-millisecond($c2), "ms2": get-millisecond($c5), "ms3": get-millisecond($c6), "ms4": get-millisecond($c8), "ms-null": get-millisecond(null) }
+return {
+ "year1": get-year($c1),
+ "year2": get-year($c2),
+ "year3": get-year($c3),
+ "year4": get-year($c4),
+ "year5": get-year($c5),
+ "year6": get-year($c7),
+ "year7": get-year($c8),
+ "year8": get-year($c9),
+ "year-null": get-year(null),
+ "month1": get-month($c1),
+ "month2": get-month($c2),
+ "month3": get-month($c3),
+ "month4": get-month($c4),
+ "month5": get-month($c5),
+ "month6": get-month($c8),
+ "month7": get-month($c9),
+ "month-null": get-month(null),
+ "day1": get-day($c1),
+ "day2": get-day($c2),
+ "day3": get-day($c3),
+ "day4": get-day($c4),
+ "day5": get-day($c5),
+ "day6": get-day($c8),
+ "day7": get-day($c10),
+ "day-null": get-day(null),
+ "hour1": get-hour($c2),
+ "hour2": get-hour($c5),
+ "hour3": get-hour($c6),
+ "hour4": get-hour($c8),
+ "hour5": get-hour($c10),
+ "hour-null": get-hour(null),
+ "min1": get-minute($c2),
+ "min2": get-minute($c5),
+ "min3": get-minute($c6),
+ "min4": get-minute($c8),
+ "min5": get-minute($c10),
+ "min-null": get-minute(null),
+ "second1": get-second($c2),
+ "second2": get-second($c5),
+ "second3": get-second($c6),
+ "second4": get-second($c8),
+ "second5": get-second($c10),
+ "second-null": get-second(null),
+ "ms1": get-millisecond($c2),
+ "ms2": get-millisecond($c5),
+ "ms3": get-millisecond($c6),
+ "ms4": get-millisecond($c8),
+ "ms5": get-millisecond($c10),
+ "ms-null": get-millisecond(null) }
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/agg_max/agg_max.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/agg_max/agg_max.1.ddl.aql
new file mode 100644
index 0000000..6cc19a9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/agg_max/agg_max.1.ddl.aql
@@ -0,0 +1,15 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Schema as closed{
+ id: int32,
+ time: time,
+ date: date,
+ datetime: datetime,
+ dtduration: day-time-duration,
+ ymduration: year-month-duration
+}
+
+create dataset tsdata(Schema)
+primary key id;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/agg_max/agg_max.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/agg_max/agg_max.2.update.aql
new file mode 100644
index 0000000..bc0cf89
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/agg_max/agg_max.2.update.aql
@@ -0,0 +1,5 @@
+use dataverse test;
+
+insert into dataset tsdata({"id": 1, "time": time("23:49:23.938"), "date": date("1904-01-06"), "datetime": datetime("2012-01-12T12:31:39"), "dtduration": day-time-duration("PT5M"), "ymduration": year-month-duration("P5M")})
+insert into dataset tsdata({"id": 2, "time": time("12:37:10"), "date": date("2194-07-06"), "datetime": datetime("2013-01-12T12:31:39"), "dtduration": day-time-duration("PT5.329S"), "ymduration": year-month-duration("P1Y")})
+insert into dataset tsdata({"id": 3, "time": time("09:28:10.9"), "date": date("-1904-01-06"), "datetime": datetime("2012-01-12T18:31:39"), "dtduration": day-time-duration("P3DT2S"), "ymduration": year-month-duration("P29M")})
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/agg_max/agg_max.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/agg_max/agg_max.3.query.aql
new file mode 100644
index 0000000..9985349
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/agg_max/agg_max.3.query.aql
@@ -0,0 +1,8 @@
+use dataverse test;
+
+let $m0 := max(for $i in dataset tsdata return $i.time)
+let $m1 := max(for $i in dataset tsdata return $i.date)
+let $m2 := max(for $i in dataset tsdata return $i.datetime)
+let $m3 := max(for $i in dataset tsdata return $i.dtduration)
+let $m4 := max(for $i in dataset tsdata return $i.ymduration)
+return {"m0": $m0, "m1": $m1, "m2": $m2, "m3": $m3, "m4": $m4}
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/agg_min/agg_min.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/agg_min/agg_min.1.ddl.aql
new file mode 100644
index 0000000..6cc19a9
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/agg_min/agg_min.1.ddl.aql
@@ -0,0 +1,15 @@
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Schema as closed{
+ id: int32,
+ time: time,
+ date: date,
+ datetime: datetime,
+ dtduration: day-time-duration,
+ ymduration: year-month-duration
+}
+
+create dataset tsdata(Schema)
+primary key id;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/agg_min/agg_min.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/agg_min/agg_min.2.update.aql
new file mode 100644
index 0000000..bc0cf89
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/agg_min/agg_min.2.update.aql
@@ -0,0 +1,5 @@
+use dataverse test;
+
+insert into dataset tsdata({"id": 1, "time": time("23:49:23.938"), "date": date("1904-01-06"), "datetime": datetime("2012-01-12T12:31:39"), "dtduration": day-time-duration("PT5M"), "ymduration": year-month-duration("P5M")})
+insert into dataset tsdata({"id": 2, "time": time("12:37:10"), "date": date("2194-07-06"), "datetime": datetime("2013-01-12T12:31:39"), "dtduration": day-time-duration("PT5.329S"), "ymduration": year-month-duration("P1Y")})
+insert into dataset tsdata({"id": 3, "time": time("09:28:10.9"), "date": date("-1904-01-06"), "datetime": datetime("2012-01-12T18:31:39"), "dtduration": day-time-duration("P3DT2S"), "ymduration": year-month-duration("P29M")})
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/agg_min/agg_min.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/agg_min/agg_min.3.query.aql
new file mode 100644
index 0000000..91b2dba
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/agg_min/agg_min.3.query.aql
@@ -0,0 +1,8 @@
+use dataverse test;
+
+let $m0 := min(for $i in dataset tsdata return $i.time)
+let $m1 := min(for $i in dataset tsdata return $i.date)
+let $m2 := min(for $i in dataset tsdata return $i.datetime)
+let $m3 := min(for $i in dataset tsdata return $i.dtduration)
+let $m4 := min(for $i in dataset tsdata return $i.ymduration)
+return {"m0": $m0, "m1": $m1, "m2": $m2, "m3": $m3, "m4": $m4}
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/duration_functions/duration_functions.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/duration_functions/duration_functions.1.ddl.aql
new file mode 100644
index 0000000..5b52155
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/duration_functions/duration_functions.1.ddl.aql
@@ -0,0 +1,8 @@
+/*
+ * Description : Check temporal functions for duration
+ * Expected Result : Success
+ * Date : 08/22/2013
+ */
+
+drop dataverse test if exists;
+create dataverse test;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/duration_functions/duration_functions.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/duration_functions/duration_functions.2.update.aql
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/duration_functions/duration_functions.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/duration_functions/duration_functions.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/duration_functions/duration_functions.3.query.aql
new file mode 100644
index 0000000..9252213
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/duration_functions/duration_functions.3.query.aql
@@ -0,0 +1,16 @@
+/*
+ * Description : Check temporal functions for duration
+ * Expected Result : Success
+ * Date : 08/22/2013
+ */
+
+use dataverse test;
+
+let $itv1 := interval-from-date("2010-10-30", "2010-12-21")
+let $itv2 := interval-from-datetime("2012-06-26T01:01:01.111", "2012-07-27T02:02:02.222")
+let $itv3 := interval-from-time("12:32:38", "20:29:20")
+
+return { "dr1" : duration-from-interval($itv1),
+ "dr2" : duration-from-interval($itv2),
+ "dr3" : duration-from-interval($itv3),
+ "dr4" : duration-from-interval(null) }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/get_overlapping_interval/get_overlapping_interval.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/get_overlapping_interval/get_overlapping_interval.1.ddl.aql
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/get_overlapping_interval/get_overlapping_interval.1.ddl.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/get_overlapping_interval/get_overlapping_interval.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/get_overlapping_interval/get_overlapping_interval.2.update.aql
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/get_overlapping_interval/get_overlapping_interval.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/get_overlapping_interval/get_overlapping_interval.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/get_overlapping_interval/get_overlapping_interval.3.query.aql
new file mode 100644
index 0000000..5167f2a
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/get_overlapping_interval/get_overlapping_interval.3.query.aql
@@ -0,0 +1,11 @@
+/**
+ * get-overlapping-interval test case
+ * Expected result: success
+ **/
+
+{ "overlap1": get-overlapping-interval(interval-from-time(time("11:23:39"), time("18:27:19")), interval-from-time(time("12:23:39"), time("23:18:00"))),
+ "overlap2": get-overlapping-interval(interval-from-time(time("12:23:39"), time("18:27:19")), interval-from-time(time("07:19:39"), time("09:18:00"))),
+ "overlap3": get-overlapping-interval(interval-from-date(date("1980-11-30"), date("1999-09-09")), interval-from-date(date("2013-01-01"), date("2014-01-01"))),
+ "overlap4": get-overlapping-interval(interval-from-date(date("1980-11-30"), date("2099-09-09")), interval-from-date(date("2013-01-01"), date("2014-01-01"))),
+ "overlap5": get-overlapping-interval(interval-from-datetime(datetime("1844-03-03T11:19:39"), datetime("2000-10-30T18:27:19")), interval-from-datetime(datetime("1989-03-04T12:23:39"), datetime("2009-10-10T23:18:00"))),
+ "overlap6": get-overlapping-interval(interval-from-datetime(datetime("1989-03-04T12:23:39"), datetime("2000-10-30T18:27:19")), interval-from-datetime(datetime("1844-03-03T11:19:39"), datetime("1888-10-10T23:18:00"))) }
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins/overlap_bins.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins/overlap_bins.1.ddl.aql
new file mode 100644
index 0000000..fc82cbe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins/overlap_bins.1.ddl.aql
@@ -0,0 +1,4 @@
+/**
+ * overlap_bins test case: test the overlap_bins
+ * Expected result: success
+ **/
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins/overlap_bins.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins/overlap_bins.2.update.aql
new file mode 100644
index 0000000..fc82cbe
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins/overlap_bins.2.update.aql
@@ -0,0 +1,4 @@
+/**
+ * overlap_bins test case: test the overlap_bins
+ * Expected result: success
+ **/
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins/overlap_bins.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins/overlap_bins.3.query.aql
new file mode 100644
index 0000000..ae9058f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins/overlap_bins.3.query.aql
@@ -0,0 +1,11 @@
+/**
+ * overlap_bins test case: test the overlap_bins
+ * Expected result: success
+ **/
+
+let $itv1 := interval-from-time(time("17:23:37"), time("18:30:21"))
+let $itv2 := interval-from-date(date("1984-03-17"), date("2013-08-22"))
+let $itv3 := interval-from-datetime(datetime("1800-01-01T23:59:48.938"), datetime("2015-07-26T13:28:30.218"))
+return { "timebins": overlap-bins($itv1, time("00:00:00"), day-time-duration("PT30M")),
+ "datebins": overlap-bins($itv2, date("1990-01-01"), year-month-duration("P20Y")),
+ "datetimebins": overlap-bins($itv3, datetime("1900-01-01T00:00:00.000"), year-month-duration("P100Y")) }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_0/overlap_bins_gby_0.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_0/overlap_bins_gby_0.1.ddl.aql
new file mode 100644
index 0000000..652f81c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_0/overlap_bins_gby_0.1.ddl.aql
@@ -0,0 +1,17 @@
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Schema as closed{
+ id: int32,
+ time: time,
+ duration: day-time-duration
+}
+
+create dataset tsdata(Schema)
+primary key id;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_0/overlap_bins_gby_0.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_0/overlap_bins_gby_0.2.update.aql
new file mode 100644
index 0000000..4e9c1e4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_0/overlap_bins_gby_0.2.update.aql
@@ -0,0 +1,17 @@
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+use dataverse test;
+
+insert into dataset tsdata({"id": 1, "time": time("23:49:23.938"), "duration": day-time-duration("PT5M")})
+insert into dataset tsdata({"id": 2, "time": time("00:27:13.432"), "duration": day-time-duration("PT1H")})
+insert into dataset tsdata({"id": 3, "time": time("18:00:00"), "duration": day-time-duration("PT2H")})
+insert into dataset tsdata({"id": 4, "time": time("234933938"), "duration": day-time-duration("PT30S")})
+insert into dataset tsdata({"id": 5, "time": time("23:58:17.038"), "duration": day-time-duration("PT39.382S")})
+insert into dataset tsdata({"id": 6, "time": time("23:30:00"), "duration": day-time-duration("PT2M")})
+insert into dataset tsdata({"id": 7, "time": time("23:22:38"), "duration": day-time-duration("PT20M")})
+insert into dataset tsdata({"id": 8, "time": time("17:28:13.900"), "duration": day-time-duration("PT19S")})
+insert into dataset tsdata({"id": 9, "time": time("07:49:23.938"), "duration": day-time-duration("PT3H")})
+insert into dataset tsdata({"id": 10, "time": time("09:35:28.039"), "duration": day-time-duration("PT10H50M")})
+insert into dataset tsdata({"id": 11, "time": time("12:49:23.938"), "duration": day-time-duration("PT3H")})
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_0/overlap_bins_gby_0.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_0/overlap_bins_gby_0.3.query.aql
new file mode 100644
index 0000000..42defd6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_0/overlap_bins_gby_0.3.query.aql
@@ -0,0 +1,15 @@
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+use dataverse test;
+
+for $i in dataset tsdata
+ order by $i.time
+ for $j in overlap-bins(interval-start-from-time($i.time, $i.duration), time("00:00:00"), day-time-duration("PT1H30M"))
+ group by $bin := $j with $i
+ order by get-interval-start($bin)
+ for $x in $i
+ let $itv := interval-start-from-time($x.time, $x.duration)
+ return { "tbin": $bin, "interval": $itv, "overlap": get-overlapping-interval($bin, $itv) }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_1/overlap_bins_gby_1.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_1/overlap_bins_gby_1.1.ddl.aql
new file mode 100644
index 0000000..652f81c
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_1/overlap_bins_gby_1.1.ddl.aql
@@ -0,0 +1,17 @@
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type Schema as closed{
+ id: int32,
+ time: time,
+ duration: day-time-duration
+}
+
+create dataset tsdata(Schema)
+primary key id;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_1/overlap_bins_gby_1.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_1/overlap_bins_gby_1.2.update.aql
new file mode 100644
index 0000000..4e9c1e4
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_1/overlap_bins_gby_1.2.update.aql
@@ -0,0 +1,17 @@
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+use dataverse test;
+
+insert into dataset tsdata({"id": 1, "time": time("23:49:23.938"), "duration": day-time-duration("PT5M")})
+insert into dataset tsdata({"id": 2, "time": time("00:27:13.432"), "duration": day-time-duration("PT1H")})
+insert into dataset tsdata({"id": 3, "time": time("18:00:00"), "duration": day-time-duration("PT2H")})
+insert into dataset tsdata({"id": 4, "time": time("234933938"), "duration": day-time-duration("PT30S")})
+insert into dataset tsdata({"id": 5, "time": time("23:58:17.038"), "duration": day-time-duration("PT39.382S")})
+insert into dataset tsdata({"id": 6, "time": time("23:30:00"), "duration": day-time-duration("PT2M")})
+insert into dataset tsdata({"id": 7, "time": time("23:22:38"), "duration": day-time-duration("PT20M")})
+insert into dataset tsdata({"id": 8, "time": time("17:28:13.900"), "duration": day-time-duration("PT19S")})
+insert into dataset tsdata({"id": 9, "time": time("07:49:23.938"), "duration": day-time-duration("PT3H")})
+insert into dataset tsdata({"id": 10, "time": time("09:35:28.039"), "duration": day-time-duration("PT10H50M")})
+insert into dataset tsdata({"id": 11, "time": time("12:49:23.938"), "duration": day-time-duration("PT3H")})
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_1/overlap_bins_gby_1.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_1/overlap_bins_gby_1.3.query.aql
new file mode 100644
index 0000000..797c351
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_1/overlap_bins_gby_1.3.query.aql
@@ -0,0 +1,22 @@
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+use dataverse test;
+
+for $i2 in (
+ for $i1 in dataset tsdata
+ order by $i1.time
+ return { "interval": interval-start-from-time($i1.time, $i1.duration) })
+for $j in overlap-bins($i2.interval, time("00:00:00"), day-time-duration("PT1H30M"))
+group by $bin := $j with $i2
+order by get-interval-start($bin)
+return {
+ "timebin": $bin,
+ "count": count($i2),
+ "total_ms": sum(
+ for $i3 in $i2
+ return ms-from-day-time-duration(
+ duration-from-interval(
+ get-overlapping-interval($bin, $i3.interval)))) }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_3/overlap_bins_gby_3.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_3/overlap_bins_gby_3.1.ddl.aql
new file mode 100644
index 0000000..c5fa968
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_3/overlap_bins_gby_3.1.ddl.aql
@@ -0,0 +1,18 @@
+/**
+ * Interval_bin_gby test case: test the group-by using interval-bin function
+ * Expected result: success
+ **/
+
+drop dataverse multitask if exists;
+create dataverse multitask;
+use dataverse multitask;
+
+create type LogType as closed {
+ row_id: int32,
+ time: time,
+ duration: int32,
+ app: string
+};
+
+create dataset logs(LogType)
+primary key row_id;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_3/overlap_bins_gby_3.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_3/overlap_bins_gby_3.2.update.aql
new file mode 100644
index 0000000..82d1fe6
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_3/overlap_bins_gby_3.2.update.aql
@@ -0,0 +1,12 @@
+use dataverse multitask;
+
+insert into dataset logs { "row_id": 1, "time": time("10:27:12"), "duration": 5, "app": "Facebook" }
+insert into dataset logs { "row_id": 2, "time": time("10:27:18"), "duration": 6, "app": "Email" }
+insert into dataset logs { "row_id": 3, "time": time("10:27:25"), "duration": 26, "app": "Facebook" }
+insert into dataset logs { "row_id": 4, "time": time("10:27:52"), "duration": 19, "app": "Email" }
+insert into dataset logs { "row_id": 5, "time": time("10:28:12"), "duration": 47, "app": "Facebook" }
+insert into dataset logs { "row_id": 6, "time": time("10:29:00"), "duration": 33, "app": "Email" }
+insert into dataset logs { "row_id": 7, "time": time("10:29:10"), "duration": 18, "app": "Facebook" }
+insert into dataset logs { "row_id": 8, "time": time("10:29:29"), "duration": 159, "app": "Facebook" }
+insert into dataset logs { "row_id": 9, "time": time("11:07:15"), "duration": 30, "app": "Email" }
+insert into dataset logs { "row_id": 10, "time": time("11:07:47"), "duration": 31, "app": "Email" }
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_3/overlap_bins_gby_3.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_3/overlap_bins_gby_3.3.query.aql
new file mode 100644
index 0000000..0433b32
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/overlap_bins_gby_3/overlap_bins_gby_3.3.query.aql
@@ -0,0 +1,13 @@
+use dataverse multitask;
+
+for $bin in overlap-bins(interval-from-time(min(for $i in dataset logs return $i.time), max(for $i in dataset logs return $i.time + duration-from-ms($i.duration * 1000))), time("00:00:00.000"), day-time-duration("PT1M"))
+order by get-interval-start($bin)
+return {
+ "timebin": $bin,
+ "subgroups":
+ for $i in dataset logs
+ where interval-covers($bin, interval-start-from-time($i.time, duration-from-ms($i.duration)))
+ group by $subgid := $i.app with $i
+ order by $subgid, count($i)
+ return { "subgid": $subgid, "item_count": count($i) }
+}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/string/replace22/replace22.1.adm b/asterix-app/src/test/resources/runtimets/results/string/replace22/replace22.1.adm
index a0e11d5..09d79cf 100644
--- a/asterix-app/src/test/resources/runtimets/results/string/replace22/replace22.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/string/replace22/replace22.1.adm
@@ -1,2 +1,2 @@
-[ { "result1": "abracadabra", "result2": "aXXXcadaXXX", "result3": null, "result4": "aXXXcadaXXX", "result5": "XXXaXXXbXXXrXXXaXXXcXXXaXXXdXXXaXXXbXXXrXXXaXXX", "result6": "acada", "result7": "acada", "result8": "XXXaXXXbXXXrXXXaXXXcXXXaXXXdXXXaXXXbXXXrXXXaXXX" }
+[ { "result1": null, "result2": "aXXXcadaXXX", "result3": null, "result4": null, "result5": null, "result6": null, "result7": "acada", "result8": "XXXaXXXbXXXrXXXaXXXcXXXaXXXdXXXaXXXbXXXrXXXaXXX" }
]
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/accessors/accessors.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/accessors/accessors.1.adm
index 03a901e..33fb586 100644
--- a/asterix-app/src/test/resources/runtimets/results/temporal/accessors/accessors.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/accessors/accessors.1.adm
@@ -1,2 +1,3 @@
-[ { "year1": 2010, "year2": 1987, "year3": -1987, "year4": 928, "year5": 1937, "year6": -3, "year7": 9, "year-null": null, "month1": 10, "month2": 11, "month3": 11, "month4": 3, "month5": 12, "month6": 1, "month-null": null, "day1": 30, "day2": 19, "day3": 19, "day4": 29, "day5": 29, "day6": 634, "day-null": null, "hour1": 23, "hour2": 20, "hour3": 5, "hour4": 14, "hour-null": null, "min1": 49, "min2": 3, "min3": 23, "min4": 28, "min-null": null, "second1": 23, "second2": 6, "second3": 34, "second4": 48, "second-null": null, "ms1": 938, "ms2": 280, "ms3": 930, "ms4": 94, "ms-null": null }
+[ { "year1": 2010, "year2": 1987, "year3": -1987, "year4": 928, "year5": 1937, "year6": -3, "year7": 9, "year8": 9, "year-null": null, "month1": 10, "month2": 11, "month3": 11, "month4": 3, "month5": 12, "month6": 1, "month7": 0, "month-null": null, "day1": 30, "day2": 19, "day3": 19, "day4": 29, "day5": 29, "day6": 634, "day7": 34, "day-null": null, "hour1": 23, "hour2": 20, "hour3": 5, "hour4": 14, "hour5": 14, "hour-null": null, "min1": 49, "min2": 3, "min3": 23, "min4": 28, "min5": 28, "min-null": null, "second1": 23, "second2": 6, "second3": 34, "second4": 48, "second5": 48, "second-null": null, "ms1": 938, "ms2": 280, "ms3": 930, "ms4": 94, "ms5": 94, "ms-null": null }
]
+
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/agg_max/agg_max.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/agg_max/agg_max.1.adm
new file mode 100644
index 0000000..18ecc53
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/agg_max/agg_max.1.adm
@@ -0,0 +1,6 @@
+[ {"m0": time("23:49:23.938Z")
+, "m1": date("2194-07-06")
+, "m2": datetime("2013-01-12T12:31:39.000Z")
+, "m3": day-time-duration("P3DT2S")
+, "m4": year-month-duration("P2Y5M")}
+ ]
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/agg_min/agg_min.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/agg_min/agg_min.1.adm
new file mode 100644
index 0000000..2eccb41
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/agg_min/agg_min.1.adm
@@ -0,0 +1,6 @@
+[ {"m0": time("09:28:10.900Z")
+, "m1": date("-1904-01-06")
+, "m2": datetime("2012-01-12T12:31:39.000Z")
+, "m3": day-time-duration("PT5.329S")
+, "m4": year-month-duration("P5M")}
+ ]
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/duration_functions/duration_functions.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/duration_functions/duration_functions.1.adm
new file mode 100644
index 0000000..ab16741
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/duration_functions/duration_functions.1.adm
@@ -0,0 +1,2 @@
+[ { "dr1": day-time-duration("P52D"), "dr2": day-time-duration("P31DT1H1M1.111S"), "dr3": day-time-duration("PT7H56M42S"), "dr4": null }
+ ]
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/get_overlapping_interval/get_overlapping_interval.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/get_overlapping_interval/get_overlapping_interval.1.adm
new file mode 100644
index 0000000..175eccc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/get_overlapping_interval/get_overlapping_interval.1.adm
@@ -0,0 +1,2 @@
+[ { "overlap1": interval-time("12:23:39.000Z, 18:27:19.000Z"), "overlap2": null, "overlap3": null, "overlap4": interval-date("2013-01-01, 2014-01-01"), "overlap5": interval-datetime("1989-03-04T12:23:39.000Z, 2000-10-30T18:27:19.000Z"), "overlap6": null }
+ ]
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.1.adm
index cd19c38..74a7fb0 100644
--- a/asterix-app/src/test/resources/runtimets/results/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/insert_from_ext_ds_2/insert_from_ext_ds_2.1.adm
@@ -1,4 +1,4 @@
-[ { "date": date("-9971-09-24"), "time": time("11:38:17.154Z"), "datetime": datetime("1259-11-13T09:49:11.852Z"), "duration": duration("P473653Y9M4566143DT10H20M53.61S"), "year-month-duration": year-month-duration("P148233Y10M"), "day-time-duration": day-time-duration("-P7236357DT2H56M56.164S"), "date-interval": interval-date("-0255-09-06, 4925-05-03"), "time-interval": interval-time("23:10:45.169Z, 01:37:48.736Z"), "datetime-interval": interval-datetime("0534-12-08T08:20:31.487Z, 6778-02-16T22:40:21.653Z") }
+[ { "date": date("-9971-09-24"), "time": time("11:38:17.154Z"), "datetime": datetime("1259-11-13T09:49:11.852Z"), "duration": duration("P473653Y9M4566143DT10H20M53.61S"), "year-month-duration": year-month-duration("P148233Y10M"), "day-time-duration": day-time-duration("-P7236357DT2H56M56.164S"), "date-interval": interval-date("-0255-09-06, 4925-05-03"), "time-interval": interval-time("12:10:45.169Z, 15:37:48.736Z"), "datetime-interval": interval-datetime("0534-12-08T08:20:31.487Z, 6778-02-16T22:40:21.653Z") }
, { "date": date("4619-11-23"), "time": time("14:29:36.786Z"), "datetime": datetime("2749-01-27T17:27:30.020Z"), "duration": duration("-P474133Y7M854630DT4H40M6.45S"), "year-month-duration": year-month-duration("P193989Y3M"), "day-time-duration": day-time-duration("P4477686DT4H49M31.87S"), "date-interval": interval-date("-9537-08-04, 9656-06-03"), "time-interval": interval-time("12:04:45.689Z, 12:41:59.002Z"), "datetime-interval": interval-datetime("-2640-10-11T17:32:15.675Z, 4104-02-01T05:59:11.902Z") }
-, { "date": date("7986-11-25"), "time": time("12:49:39.736Z"), "datetime": datetime("-8337-01-30T15:23:07.598Z"), "duration": duration("-P184484Y7M2241423DT10H42M49.500S"), "year-month-duration": year-month-duration("-P546031Y3M"), "day-time-duration": day-time-duration("P2623386DT10H32M31.983S"), "date-interval": interval-date("-4514-05-24, 3337-08-26"), "time-interval": interval-time("04:16:42.321Z, 02:22:56.816Z"), "datetime-interval": interval-datetime("2129-12-12T13:18:35.758Z, 8647-07-01T13:10:19.691Z") }
- ]
+, { "date": date("7986-11-25"), "time": time("12:49:39.736Z"), "datetime": datetime("-8337-01-30T15:23:07.598Z"), "duration": duration("-P184484Y7M2241423DT10H42M49.500S"), "year-month-duration": year-month-duration("-P546031Y3M"), "day-time-duration": day-time-duration("P2623386DT10H32M31.983S"), "date-interval": interval-date("-4514-05-24, 3337-08-26"), "time-interval": interval-time("04:16:42.321Z, 12:22:56.816Z"), "datetime-interval": interval-datetime("2129-12-12T13:18:35.758Z, 8647-07-01T13:10:19.691Z") }
+ ]
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/overlap_bins/overlap_bins.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/overlap_bins/overlap_bins.1.adm
new file mode 100644
index 0000000..054fdae
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/overlap_bins/overlap_bins.1.adm
@@ -0,0 +1,2 @@
+[ { "timebins": [ interval-time("17:00:00.000Z, 17:30:00.000Z"), interval-time("17:30:00.000Z, 18:00:00.000Z"), interval-time("18:00:00.000Z, 18:30:00.000Z"), interval-time("18:30:00.000Z, 19:00:00.000Z") ], "datebins": [ interval-date("1970-01-01, 1990-01-01"), interval-date("1990-01-01, 2010-01-01"), interval-date("2010-01-01, 2030-01-01") ], "datetimebins": [ interval-datetime("1800-01-01T00:00:00.000Z, 1900-01-01T00:00:00.000Z"), interval-datetime("1900-01-01T00:00:00.000Z, 2000-01-01T00:00:00.000Z"), interval-datetime("2000-01-01T00:00:00.000Z, 2100-01-01T00:00:00.000Z") ] }
+ ]
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/overlap_bins_gby_0/overlap_bins_gby_0.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/overlap_bins_gby_0/overlap_bins_gby_0.1.adm
new file mode 100644
index 0000000..457e54d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/overlap_bins_gby_0/overlap_bins_gby_0.1.adm
@@ -0,0 +1,24 @@
+[ { "tbin": interval-time("00:00:00.000Z, 01:30:00.000Z"), "interval": interval-time("00:27:13.432Z, 01:27:13.432Z"), "overlap": interval-time("00:27:13.432Z, 01:27:13.432Z") }
+, { "tbin": interval-time("07:30:00.000Z, 09:00:00.000Z"), "interval": interval-time("07:49:23.938Z, 10:49:23.938Z"), "overlap": interval-time("07:49:23.938Z, 09:00:00.000Z") }
+, { "tbin": interval-time("09:00:00.000Z, 10:30:00.000Z"), "interval": interval-time("07:49:23.938Z, 10:49:23.938Z"), "overlap": interval-time("09:00:00.000Z, 10:30:00.000Z") }
+, { "tbin": interval-time("09:00:00.000Z, 10:30:00.000Z"), "interval": interval-time("09:35:28.039Z, 20:25:28.039Z"), "overlap": interval-time("09:35:28.039Z, 10:30:00.000Z") }
+, { "tbin": interval-time("10:30:00.000Z, 12:00:00.000Z"), "interval": interval-time("07:49:23.938Z, 10:49:23.938Z"), "overlap": interval-time("10:30:00.000Z, 10:49:23.938Z") }
+, { "tbin": interval-time("10:30:00.000Z, 12:00:00.000Z"), "interval": interval-time("09:35:28.039Z, 20:25:28.039Z"), "overlap": interval-time("10:30:00.000Z, 12:00:00.000Z") }
+, { "tbin": interval-time("12:00:00.000Z, 13:30:00.000Z"), "interval": interval-time("09:35:28.039Z, 20:25:28.039Z"), "overlap": interval-time("12:00:00.000Z, 13:30:00.000Z") }
+, { "tbin": interval-time("12:00:00.000Z, 13:30:00.000Z"), "interval": interval-time("12:49:23.938Z, 15:49:23.938Z"), "overlap": interval-time("12:49:23.938Z, 13:30:00.000Z") }
+, { "tbin": interval-time("13:30:00.000Z, 15:00:00.000Z"), "interval": interval-time("09:35:28.039Z, 20:25:28.039Z"), "overlap": interval-time("13:30:00.000Z, 15:00:00.000Z") }
+, { "tbin": interval-time("13:30:00.000Z, 15:00:00.000Z"), "interval": interval-time("12:49:23.938Z, 15:49:23.938Z"), "overlap": interval-time("13:30:00.000Z, 15:00:00.000Z") }
+, { "tbin": interval-time("15:00:00.000Z, 16:30:00.000Z"), "interval": interval-time("09:35:28.039Z, 20:25:28.039Z"), "overlap": interval-time("15:00:00.000Z, 16:30:00.000Z") }
+, { "tbin": interval-time("15:00:00.000Z, 16:30:00.000Z"), "interval": interval-time("12:49:23.938Z, 15:49:23.938Z"), "overlap": interval-time("15:00:00.000Z, 15:49:23.938Z") }
+, { "tbin": interval-time("16:30:00.000Z, 18:00:00.000Z"), "interval": interval-time("09:35:28.039Z, 20:25:28.039Z"), "overlap": interval-time("16:30:00.000Z, 18:00:00.000Z") }
+, { "tbin": interval-time("16:30:00.000Z, 18:00:00.000Z"), "interval": interval-time("17:28:13.900Z, 17:28:32.900Z"), "overlap": interval-time("17:28:13.900Z, 17:28:32.900Z") }
+, { "tbin": interval-time("18:00:00.000Z, 19:30:00.000Z"), "interval": interval-time("09:35:28.039Z, 20:25:28.039Z"), "overlap": interval-time("18:00:00.000Z, 19:30:00.000Z") }
+, { "tbin": interval-time("18:00:00.000Z, 19:30:00.000Z"), "interval": interval-time("18:00:00.000Z, 20:00:00.000Z"), "overlap": interval-time("18:00:00.000Z, 19:30:00.000Z") }
+, { "tbin": interval-time("19:30:00.000Z, 21:00:00.000Z"), "interval": interval-time("09:35:28.039Z, 20:25:28.039Z"), "overlap": interval-time("19:30:00.000Z, 20:25:28.039Z") }
+, { "tbin": interval-time("19:30:00.000Z, 21:00:00.000Z"), "interval": interval-time("18:00:00.000Z, 20:00:00.000Z"), "overlap": interval-time("19:30:00.000Z, 20:00:00.000Z") }
+, { "tbin": interval-time("22:30:00.000Z, 00:00:00.000Z"), "interval": interval-time("23:22:38.000Z, 23:42:38.000Z"), "overlap": interval-time("23:22:38.000Z, 23:42:38.000Z") }
+, { "tbin": interval-time("22:30:00.000Z, 00:00:00.000Z"), "interval": interval-time("23:30:00.000Z, 23:32:00.000Z"), "overlap": interval-time("23:30:00.000Z, 23:32:00.000Z") }
+, { "tbin": interval-time("22:30:00.000Z, 00:00:00.000Z"), "interval": interval-time("23:49:23.938Z, 23:54:23.938Z"), "overlap": interval-time("23:49:23.938Z, 23:54:23.938Z") }
+, { "tbin": interval-time("22:30:00.000Z, 00:00:00.000Z"), "interval": interval-time("23:49:33.938Z, 23:50:03.938Z"), "overlap": interval-time("23:49:33.938Z, 23:50:03.938Z") }
+, { "tbin": interval-time("22:30:00.000Z, 00:00:00.000Z"), "interval": interval-time("23:58:17.038Z, 23:58:56.420Z"), "overlap": interval-time("23:58:17.038Z, 23:58:56.420Z") }
+ ]
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/overlap_bins_gby_1/overlap_bins_gby_1.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/overlap_bins_gby_1/overlap_bins_gby_1.1.adm
new file mode 100644
index 0000000..241859d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/overlap_bins_gby_1/overlap_bins_gby_1.1.adm
@@ -0,0 +1,12 @@
+[ { "timebin": interval-time("00:00:00.000Z, 01:30:00.000Z"), "count": 1, "total_ms": 3600000 }
+, { "timebin": interval-time("07:30:00.000Z, 09:00:00.000Z"), "count": 1, "total_ms": 4236062 }
+, { "timebin": interval-time("09:00:00.000Z, 10:30:00.000Z"), "count": 2, "total_ms": 8671961 }
+, { "timebin": interval-time("10:30:00.000Z, 12:00:00.000Z"), "count": 2, "total_ms": 6563938 }
+, { "timebin": interval-time("12:00:00.000Z, 13:30:00.000Z"), "count": 2, "total_ms": 7836062 }
+, { "timebin": interval-time("13:30:00.000Z, 15:00:00.000Z"), "count": 2, "total_ms": 10800000 }
+, { "timebin": interval-time("15:00:00.000Z, 16:30:00.000Z"), "count": 2, "total_ms": 8363938 }
+, { "timebin": interval-time("16:30:00.000Z, 18:00:00.000Z"), "count": 2, "total_ms": 5419000 }
+, { "timebin": interval-time("18:00:00.000Z, 19:30:00.000Z"), "count": 2, "total_ms": 10800000 }
+, { "timebin": interval-time("19:30:00.000Z, 21:00:00.000Z"), "count": 2, "total_ms": 5128039 }
+, { "timebin": interval-time("22:30:00.000Z, 00:00:00.000Z"), "count": 5, "total_ms": 1689382 }
+ ]
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/overlap_bins_gby_3/overlap_bins_gby_3.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/overlap_bins_gby_3/overlap_bins_gby_3.1.adm
new file mode 100644
index 0000000..a972c4d
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/overlap_bins_gby_3/overlap_bins_gby_3.1.adm
@@ -0,0 +1,43 @@
+[ { "timebin": interval-time("10:27:00.000Z, 10:28:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 }, { "subgid": "Email", "item_count": 2 }, { "subgid": "Facebook", "item_count": 2 } ] }
+, { "timebin": interval-time("10:28:00.000Z, 10:29:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 }, { "subgid": "Facebook", "item_count": 1 } ] }
+, { "timebin": interval-time("10:29:00.000Z, 10:30:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 }, { "subgid": "Email", "item_count": 1 }, { "subgid": "Facebook", "item_count": 2 } ] }
+, { "timebin": interval-time("10:30:00.000Z, 10:31:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:31:00.000Z, 10:32:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:32:00.000Z, 10:33:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:33:00.000Z, 10:34:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:34:00.000Z, 10:35:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:35:00.000Z, 10:36:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:36:00.000Z, 10:37:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:37:00.000Z, 10:38:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:38:00.000Z, 10:39:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:39:00.000Z, 10:40:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:40:00.000Z, 10:41:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:41:00.000Z, 10:42:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:42:00.000Z, 10:43:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:43:00.000Z, 10:44:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:44:00.000Z, 10:45:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:45:00.000Z, 10:46:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:46:00.000Z, 10:47:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:47:00.000Z, 10:48:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:48:00.000Z, 10:49:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:49:00.000Z, 10:50:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:50:00.000Z, 10:51:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:51:00.000Z, 10:52:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:52:00.000Z, 10:53:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:53:00.000Z, 10:54:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:54:00.000Z, 10:55:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:55:00.000Z, 10:56:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:56:00.000Z, 10:57:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:57:00.000Z, 10:58:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:58:00.000Z, 10:59:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("10:59:00.000Z, 11:00:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("11:00:00.000Z, 11:01:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("11:01:00.000Z, 11:02:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("11:02:00.000Z, 11:03:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("11:03:00.000Z, 11:04:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("11:04:00.000Z, 11:05:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("11:05:00.000Z, 11:06:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("11:06:00.000Z, 11:07:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+, { "timebin": interval-time("11:07:00.000Z, 11:08:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 }, { "subgid": "Email", "item_count": 2 } ] }
+, { "timebin": interval-time("11:08:00.000Z, 11:09:00.000Z"), "subgroups": [ { "subgid": null, "item_count": 0 } ] }
+ ]
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index a22eb35..b571514 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -6135,6 +6135,41 @@
</test-group>
<test-group name="temporal">
<test-case FilePath="temporal">
+ <compilation-unit name="overlap_bins_gby_3">
+ <output-dir compare="Text">overlap_bins_gby_3</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="temporal">
+ <compilation-unit name="agg_01">
+ <output-dir compare="Text">agg_01</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="temporal">
+ <compilation-unit name="overlap_bins_gby_1">
+ <output-dir compare="Text">overlap_bins_gby_1</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="temporal">
+ <compilation-unit name="duration_functions">
+ <output-dir compare="Text">duration_functions</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="temporal">
+ <compilation-unit name="overlap_bins_gby_0">
+ <output-dir compare="Text">overlap_bins_gby_0</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="temporal">
+ <compilation-unit name="get_overlapping_interval">
+ <output-dir compare="Text">get_overlapping_interval</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="temporal">
+ <compilation-unit name="overlap_bins">
+ <output-dir compare="Text">overlap_bins</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="temporal">
<compilation-unit name="parse_02">
<output-dir compare="Text">parse_02</output-dir>
</compilation-unit>
@@ -6627,5 +6662,4 @@
</compilation-unit>
</test-case>
</test-group>
-
</test-suite>
diff --git a/asterix-doc/src/site/markdown/aql/allens.md b/asterix-doc/src/site/markdown/aql/allens.md
index a07e287..9fd6015 100644
--- a/asterix-doc/src/site/markdown/aql/allens.md
+++ b/asterix-doc/src/site/markdown/aql/allens.md
@@ -38,6 +38,122 @@
{ "interval-before": true, "interval-after": true }
+
+### interval-covers, interval-covered-by ###
+
+ * Syntax:
+
+ interval-covers(interval1, interval2)
+ interval-covered-by(interval1, interval2)
+
+ * These two functions check whether one interval covers the other interval.
+ * Arguments:
+ * `interval1`, `interval2`: two intervals to be compared
+ * Return Value:
+
+ A `boolean` value. Specifically, `interval-covers(interval1, interval2)` is true if and only if
+
+ interval1.start <= interval2.start
+ AND interval1.end >= interval2.end
+
+ `interval-covered-by(interval1, interval2)` is true if and only if
+
+ interval2.start <= interval1.start
+ AND interval2.end >= interval1.end
+
+ For both functions, if any of the two inputs is `null`, `null` is returned.
+
+ * Examples:
+
+ let $itv1 := interval-from-date("2000-01-01", "2005-01-01")
+ let $itv2 := interval-from-date("2000-03-01", "2004-09-09")
+ let $itv3 := interval-from-date("2006-08-01", "2007-03-01")
+ let $itv4 := interval-from-date("2004-09-10", "2012-08-01")
+ return {"interval-covers": interval-covers($itv1, $itv2), "interval-covered-by": interval-covered-by($itv3, $itv4)}
+
+ * The expected result is:
+
+ { "interval-covers": true, "interval-covered-by": true }
+
+
+### interval-overlaps, interval-overlapped-by ###
+
+ * Syntax:
+
+ interval-overlaps(interval1, interval2)
+ interval-overlapped-by(interval1, interval2)
+
+ * These functions check whether two intervals overlap with each other.
+ * Arguments:
+ * `interval1`, `interval2`: two intervals to be compared
+ * Return Value:
+
+ A `boolean` value. Specifically, `interval-overlaps(interval1, interval2)` is true if and only if
+
+ interval1.start < interval2.start
+ AND interval2.end > interval1.end
+ AND interval1.end > interval2.start
+
+ `interval-overlapped-by(interval1, interval2)` is true if and only if
+
+ interval2.start < interval1.start
+ AND interval1.end > interval2.end
+ AND interval2.end > interval1.start
+
+ For all these functions, if any of the two inputs is `null`, `null` is returned.
+
+ Note that `interval-overlaps` and `interval-overlapped-by` are following the Allen's relations on the definition of overlap.
+
+ * Examples:
+
+ let $itv1 := interval-from-date("2000-01-01", "2005-01-01")
+ let $itv2 := interval-from-date("2004-05-01", "2012-09-09")
+ let $itv3 := interval-from-date("2006-08-01", "2007-03-01")
+ let $itv4 := interval-from-date("2004-09-10", "2006-12-31")
+ return {"overlaps": interval-overlaps($itv1, $itv2),
+ "overlapped-by": interval-overlapped-by($itv3, $itv4)}
+
+ * The expected result is:
+
+ { "overlaps": true, "overlapped-by": true }
+
+
+### interval-overlapping ###
+Note that `interval-overlapping` is not an Allen's Relation, but syntactic sugar we added for the case that the intersect of two intervals is not empty. Basically this function returns true if any of these functions return true: `interval-overlaps`, `interval-overlapped-by`, `interval-covers`, or `interval-covered-by`.
+
+ * Syntax:
+
+ interval-overlapping(interval1, interval2)
+
+ * This functions check whether two intervals share any points with each other.
+ * Arguments:
+ * `interval1`, `interval2`: two intervals to be compared
+ * Return Value:
+
+ A `boolean` value. Specifically, `interval-overlapping(interval1, interval2)` is true if
+
+ (interval2.start >= interval1.start
+ AND interval2.start < interval1.end)
+ OR
+ (interval2.end > interval1.start
+ AND interval2.end <= interval1.end)
+
+ If any of the two inputs is `null`, `null` is returned.
+
+ * Examples:
+
+ let $itv1 := interval-from-date("2000-01-01", "2005-01-01")
+ let $itv2 := interval-from-date("2004-05-01", "2012-09-09")
+ let $itv3 := interval-from-date("2006-08-01", "2007-03-01")
+ let $itv4 := interval-from-date("2004-09-10", "2006-12-31")
+ return {"overlapping1": interval-overlapping($itv1, $itv2),
+ "overlapping2": interval-overlapping($itv3, $itv4)}
+
+ * The expected result is:
+
+ { "overlapping1": true, "overlapping2": true }
+
+
### interval-meets, interval-met-by ###
* Syntax:
@@ -65,59 +181,6 @@
{ "meets": true, "metby": true }
-### interval-overlaps, interval-overlapped-by, overlap ###
-
- * Syntax:
-
- interval-overlaps(interval1, interval2)
- interval-overlapped-by(interval1, interval2)
- overlap(interval1, interval2)
-
- * These functions check whether two intervals overlap with each other.
- * Arguments:
- * `interval1`, `interval2`: two intervals to be compared
- * Return Value:
-
- A `boolean` value. Specifically, `interval-overlaps(interval1, interval2)` is true if and only if
-
- interval1.start < interval2.start
- AND interval2.end > interval1.end
- AND interval1.end > interval2.start
-
- `interval-overlapped-by(interval1, interval2)` is true if and only if
-
- interval2.start < interval1.start
- AND interval1.end > interval2.end
- AND interval2.end > interval1.start
-
- `overlap(interval1, interval2)` is true if
-
- (interval2.start >= interval1.start
- AND interval2.start < interval1.end)
- OR
- (interval2.end > interval1.start
- AND interval2.end <= interval.end)
-
- For all these functions, if any of the two inputs is `null`, `null` is returned.
-
- Note that `interval-overlaps` and `interval-overlapped-by` are following the Allen's relations on the definition of overlap. `overlap` is a syntactic sugar for the case that the intersect of two intervals is not empty.
-
- * Examples:
-
- let $itv1 := interval-from-date("2000-01-01", "2005-01-01")
- let $itv2 := interval-from-date("2004-05-01", "2012-09-09")
- let $itv3 := interval-from-date("2006-08-01", "2007-03-01")
- let $itv4 := interval-from-date("2004-09-10", "2006-12-31")
- return {"overlaps": interval-overlaps($itv1, $itv2),
- "overlapped-by": interval-overlapped-by($itv3, $itv4),
- "overlapping1": overlap($itv1, $itv2),
- "overlapping2": overlap($itv3, $itv4)}
-
- * The expected result is:
-
- { "overlaps": true, "overlapped-by": true, "overlapping1": true, "overlapping2": true }
-
-
### interval-starts, interval-started-by ###
* Syntax:
@@ -155,43 +218,6 @@
{ "interval-starts": true, "interval-started-by": true }
-### interval-covers, interval-covered-by ###
-
- * Syntax:
-
- interval-covers(interval1, interval2)
- interval-covered-by(interval1, interval2)
-
- * These two functions check whether one interval covers the other interval.
- * Arguments:
- * `interval1`, `interval2`: two intervals to be compared
- * Return Value:
-
- A `boolean` value. Specifically, `interval-covers(interval1, interval2)` is true if and only if
-
- interval1.start <= interval2.start
- AND interval2.end >= interval1.end
-
- `interval-covered-by(interval1, interval2)` is true if and only if
-
- interval2.start <= interval1.start
- AND interval1.end >= interval2.end
-
- For both functions, if any of the two inputs is `null`, `null` is returned.
-
- * Examples:
-
- let $itv1 := interval-from-date("2000-01-01", "2005-01-01")
- let $itv2 := interval-from-date("2000-03-01", "2004-09-09")
- let $itv3 := interval-from-date("2006-08-01", "2007-03-01")
- let $itv4 := interval-from-date("2004-09-10", "2012-08-01")
- return {"interval-covers": interval-covers($itv1, $itv2), "interval-covered-by": interval-covered-by($itv3, $itv4)}
-
- * The expected result is:
-
- { "interval-covers": true, "interval-covered-by": true }
-
-
### interval-ends, interval-ended-by ###
* Syntax:
diff --git a/asterix-doc/src/site/markdown/aql/functions.md b/asterix-doc/src/site/markdown/aql/functions.md
index 89f6f64..d0a1e0a 100644
--- a/asterix-doc/src/site/markdown/aql/functions.md
+++ b/asterix-doc/src/site/markdown/aql/functions.md
@@ -449,13 +449,15 @@
### replace ###
* Syntax:
- replace(string_expression, string_pattern, string_replacement)
+ replace(string_expression, string_pattern, string_replacement[, string_flags])
* Checks whether the string `string_expression` matches the given pattern `string_pattern`, and replace the matched pattern `string_pattern` with the new pattern `string_replacement`.
* Arguments:
* `string_expression` : A `string` that might contain the pattern.
* `string_pattern` : A pattern `string` to be matched.
* `string_replacement` : A pattern `string` to be used as the replacement.
+ * `string_flag` : (Optional) A `string` with flags to be used during replace.
+ * The following modes are enabled with these flags: dotall (s), multiline (m), case-insenitive (i), and comments and whitespace (x).
* Return Value:
* Returns a `string` that is obtained after the replacements.
@@ -1509,72 +1511,6 @@
## <a id="TemporalFunctions">Temporal Functions</a> <font size="4"><a href="#toc">[Back to TOC]</a></font> ##
-### interval-from-date ###
- * Syntax:
-
- interval-from-date(string_expression1, string_expression2)
-
- * Constructor function for the `interval` type by parsing two date strings.
- * Arguments:
- * `string_expression1` : The `string` value representing the starting date.
- * `string_expression2` : The `string` value representing the ending date.
- * Return Value:
- * An `interval` value between the two dates.
-
- * Example:
-
- {"date-interval": interval-from-date("2012-01-01", "2013-04-01")}
-
-
- * The expected result is:
-
- { "date-interval": interval-date("2012-01-01, 2013-04-01") }
-
-
-### interval-from-time ###
- * Syntax:
-
- interval-from-time(string_expression1, string_expression2)
-
- * Constructor function for the `interval` type by parsing two time strings.
- * Arguments:
- * `string_expression1` : The `string` value representing the starting time.
- * `string_expression2` : The `string` value representing the ending time.
- * Return Value:
- * An `interval` value between the two times.
-
- * Example:
-
- {"time-interval": interval-from-time("12:23:34.456Z", "233445567+0800")}
-
-
- * The expected result is:
-
- { "time-interval": interval-time("12:23:34.456Z, 15:34:45.567Z") }
-
-
-### interval-from-datetime ###
- * Syntax:
-
- interval-from-datetime(string_expression1, string_expression2)
-
- * Constructor function for `interval` type by parsing two datetime strings.
- * Arguments:
- * `string_expression1` : The `string` value representing the starting datetime.
- * `string_expression2` : The `string` value representing the ending datetime.
- * Return Value:
- * An `interval` value between the two datetimes.
-
- * Example:
-
- {"datetime-interval": interval-from-datetime("2012-01-01T12:23:34.456+08:00", "20130401T153445567Z")}
-
-
- * The expected result is:
-
- { "datetime-interval": interval-datetime("2012-01-01T04:23:34.456Z, 2013-04-01T15:34:45.567Z") }
-
-
### get-year/get-month/get-day/get-hour/get-minute/get-second/get-millisecond ###
* Syntax:
@@ -1744,10 +1680,10 @@
67
-### duration-from-months/duration-from-milliseconds ###
+### duration-from-months/duration-from-ms ###
* Syntax:
- duration-from-months/duration-from-milliseconds(number_expression)
+ duration-from-months/duration-from-ms(number_expression)
* Creates a `duration` from `number_expression`.
* Arguments:
@@ -1760,12 +1696,41 @@
let $i := duration-from-months(8)
return $i;
-
* The expected result is:
duration("P8M")
+### duration-from-interval ###
+* Syntax:
+
+ duration-from-interval(interval_expression)
+
+* Creates a `duration` from `interval_expression`.
+* Arguments:
+ * `interval_expression` : An `interval` value
+* Return Value:
+ * A `duration` repesenting the time in the `interval_expression`
+
+* Example:
+
+ let $itv1 := interval-from-date("2010-10-30", "2010-12-21")
+ let $itv2 := interval-from-datetime("2012-06-26T01:01:01.111", "2012-07-27T02:02:02.222")
+ let $itv3 := interval-from-time("12:32:38", "20:29:20")
+
+ return { "dr1" : duration-from-interval($itv1),
+ "dr2" : duration-from-interval($itv2),
+ "dr3" : duration-from-interval($itv3),
+ "dr4" : duration-from-interval(null) }
+
+* The expected result is:
+
+ { "dr1": day-time-duration("P52D"),
+ "dr2": day-time-duration("P31DT1H1M1.111S"),
+ "dr3": day-time-duration("PT7H56M42S"),
+ "dr4": null }
+
+
### current-date ###
* Syntax:
@@ -1798,8 +1763,6 @@
* Example:
- use dataverse TinySocial;
-
{"current-date": current-date(),
"current-time": current-time(),
"current-datetime": current-datetime()}
@@ -1951,8 +1914,19 @@
* Creates a `date/time/date-time` value by treating `date_expression` with formatting `formatting_expression`
* Arguments:
- * `date_expression`: A `string` value representing the `date/time/datetime`
- * `formatting_expression` A `string` value providing the formatting for `date_expression`
+ * `date_expression`: A `string` value representing the `date/time/datetime`.
+ * `formatting_expression` A `string` value providing the formatting for `date_expression`.Characters used to create date expression:
+ * `h` hours
+ * `m` minutes
+ * `s` seconds
+ * `n` milliseconds
+ * `a` am/pm
+ * `z` timezone
+ * `Y` year
+ * `M` month
+ * `D` day
+ * `W` weekday
+ * `-`, `'`, `/`, `.`, `,`, `T` seperators for both time and date
* Return Value:
* A `date/time/date-time` value corresponding to `date_expression`
@@ -1961,35 +1935,43 @@
let $i := parse-time("30:30","m:s")
return $i;
-
* The expected result is:
time("00:30:30.000Z")
+### print-date/print-time/print-datetime ###
+* Syntax:
-### interval-start-from-date/time/datetime ###
- * Syntax:
+print-date/print-time/print-datetime(date_expression,formatting_expression)
- interval-start-from-date/time/datetime(date/time/datetime, duration)
+* Creates a `string` representing a `date/time/date-time` value of the `date_expression` using the formatting `formatting_expression`
+* Arguments:
+ * `date_expression`: A `date/time/datetime` value.
+ * `formatting_expression` A `string` value providing the formatting for `date_expression`. Characters used to create date expression:
+ * `h` hours
+ * `m` minutes
+ * `s` seconds
+ * `n` milliseconds
+ * `a` am/pm
+ * `z` timezone
+ * `Y` year
+ * `M` month
+ * `D` day
+ * `W` weekday
+ * `-`, `'`, `/`, `.`, `,`, `T` seperators for both time and date
+* Return Value:
+ * A `string` value corresponding to `date_expression`
- * Construct an `interval` value by the given starting `date`/`time`/`datetime` and the `duration` that the interval lasts.
- * Arguments:
- * `date/time/datetime`: a `string` representing a `date`, `time` or `datetime`, or a `date`/`time`/`datetime` value, representing the starting time point.
- * `duration`: a `string` or `duration` value representing the duration of the interval. Note that duration cannot be negative value.
- * Return Value:
- * An `interval` value representing the interval starting from the given time point with the length of duration.
+* Example:
- * Example:
+ let $i := print-time(time("00:30:30.000Z"),"m:s")
+ return $i;
- let $itv1 := interval-start-from-date("1984-01-01", "P1Y")
- let $itv2 := interval-start-from-time(time("02:23:28.394"), "PT3H24M")
- let $itv3 := interval-start-from-datetime("1999-09-09T09:09:09.999", duration("P2M30D"))
- return {"interval1": $itv1, "interval2": $itv2, "interval3": $itv3}
+* The expected result is:
- * The expectecd result is:
+ "30:30"
- { "interval1": interval-date("1984-01-01, 1985-01-01"), "interval2": interval-time("02:23:28.394Z, 05:47:28.394Z"), "interval3": interval-datetime("1999-09-09T09:09:09.999Z, 1999-12-09T09:09:09.999Z") }
### get-interval-start, get-interval-end ###
* Syntax:
@@ -2012,6 +1994,68 @@
{ "start": date("1984-01-01"), "end": date("1985-01-01") }
+
+### get-interval-start-date/get-interval-start-datetimeget-interval-start-time, get-interval-end-date/get-interval-end-datetime/get-interval-end-time ###
+ * Syntax:
+
+ get-interval-start-date/get-interval-start-datetime/get-interval-start-time/get-interval-end-date/get-interval-end-datetime/get-interval-end-time(interval)
+
+ * Gets the start/end of the given interval for the specific date/datetime/time type.
+ * Arguments:
+ * `interval`: the interval to be accessed.
+ * Return Value:
+ * A `time`, `date`, or `datetime` (depending on the function) representing the starting or ending time.
+
+ * Example:
+
+ let $itv1 := interval-start-from-date("1984-01-01", "P1Y")
+ let $itv2 := interval-start-from-datetime("1984-01-01T08:30:00.000", "P1Y1H")
+ let $itv3 := interval-start-from-time("08:30:00.000", "P1H")
+ return {"start": get-interval-start-date($itv1), "end": get-interval-end-date($itv1), "start": get-interval-start-datetime($itv2), "end": get-interval-end-datetime($itv2), "start": get-interval-start-time($itv3), "end": get-interval-end-time($itv3)}
+
+
+ * The expected result is:
+
+ { "start": date("1984-01-01"), "end": date("1985-01-01"), "start": datetime("1984-01-01T08:30:00.000"), "end": datetime("1984-02-01T09:30:00.000"), "start": date("08:30:00.000"), "end": time("09:30:00.000") }
+
+
+### get-overlapping-interval ###
+ * Syntax:
+
+ get-overlapping-interval(interval_expression_1, interval_expression_2)
+
+ * Gets the start/end of the given interval for the specific date/datetime/time type.
+ * Arguments:
+ * `interval_expression_1`: an `interval` value
+ * `interval_expression_2`: an `interval` value
+ * Return Value:
+ * Returns an `interval` that is overlapping `interval_expression_1` and `interval_expression_2`. If `interval_expression_1` and `interval_expression_2` do not overlap `null` is returned. Note each interval must be of the same type.
+
+ * Example:
+
+ { "overlap1": get-overlapping-interval(interval-from-time(time("11:23:39"), time("18:27:19")), interval-from-time(time("12:23:39"), time("23:18:00"))),
+ "overlap2": get-overlapping-interval(interval-from-time(time("12:23:39"), time("18:27:19")), interval-from-time(time("07:19:39"), time("09:18:00"))),
+ "overlap3": get-overlapping-interval(interval-from-date(date("1980-11-30"), date("1999-09-09")), interval-from-date(date("2013-01-01"), date("2014-01-01"))),
+ "overlap4": get-overlapping-interval(interval-from-date(date("1980-11-30"), date("2099-09-09")), interval-from-date(date("2013-01-01"), date("2014-01-01"))),
+ "overlap5": get-overlapping-interval(interval-from-datetime(datetime("1844-03-03T11:19:39"), datetime("2000-10-30T18:27:19")), interval-from-datetime(datetime("1989-03-04T12:23:39"), datetime("2009-10-10T23:18:00"))),
+ "overlap6": get-overlapping-interval(interval-from-datetime(datetime("1989-03-04T12:23:39"), datetime("2000-10-30T18:27:19")), interval-from-datetime(datetime("1844-03-03T11:19:39"), datetime("1888-10-10T23:18:00"))) }
+
+ * The expected result is:
+
+ { "overlap1": interval-time("12:23:39.000Z, 18:27:19.000Z"),
+ "overlap2": null,
+ "overlap3": null,
+ "overlap4": interval-date("2013-01-01, 2014-01-01"),
+ "overlap5": interval-datetime("1989-03-04T12:23:39.000Z, 2000-10-30T18:27:19.000Z"),
+ "overlap6": null }
+
+
+### interval-before/interval-after/interval-meets/interval-met-by/interval-overlaps/interval-overlapped-by/interval-overlapping/interval-starts/interval-started-by/interval-covers/interval-covered-by/interval-ends/interval-ended-by ###
+
+
+See the [Allen's Relations](allens.html).
+
+
### interval-bin ###
* Syntax:
@@ -2049,34 +2093,132 @@
"bin3": interval-time("05:23:00.000Z, 05:24:00.000Z"),
"bin4": interval-datetime("-1987-11-19T00:00:00.000Z, -1987-11-20T00:00:00.000Z")}
-### interval-before/interval-after/interval-meets/interval-met-by/interval-overlaps/interval-overlapped-by/interval-overlapping/interval-starts/interval-started-by/interval-covers/interval-covered-by/interval-ends/interval-ended-by ###
-* Syntax:
- interval-before/interval-after/interval-meets/interval-met-by/interval-overlaps/interval-overlapped-by/interval-overlapping/interval-starts/interval-started-by/interval-covers/interval-covered-by/interval-ends/interval-ended-by(interval_expression_1, interval_expression_2)
+### interval-from-date ###
+ * Syntax:
-* Determines whether two `interval` values have a specific relationship
-* Arguments:
- * `interval_expression_1`: an `interval` value
- * `interval_expression_2`: an `interval` value
-* Return Value:
- * An `boolean` value representing whether the relationship holds.
-* Possible Relationships:
- * `before/after`: The two `interval` values never meet, and the first `interval` `preceeds/follows` the second
- * `meets/met-by`: The `first/second` `interval` ends precisely where the `second/first` `interval` starts
- * `overlaps/overlapped-by`: The `first/second` `interval` ends in a sub-interval that begins the `second/first`
- * `overlapping`: The two `interval` values share a common sub-interval
- * `starts/started-by`: The `first/second` `interval` is precisely the beginning of the `second/first` `interval`
- * `ends/ended-by`: The `first/second` `interval` is precisely the end of the `second/first` `interval`
- * `covers/covered-by`: The `first/second` `interval` completely contains the `second/first` `interval`
+ interval-from-date(string_expression1, string_expression2)
-* Example:
+ * Constructor function for the `interval` type by parsing two date strings.
+ * Arguments:
+ * `string_expression1` : The `string` value representing the starting date.
+ * `string_expression2` : The `string` value representing the ending date.
+ * Return Value:
+ * An `interval` value between the two dates.
- let $i := interval-starts(interval-from-date(date("2013-01-01"), date("20130505")),interval-from-date(date("2013-01-01"), date("20130705")))
- return $i;
+ * Example:
-* The expectecd result is:
+ {"date-interval": interval-from-date("2012-01-01", "2013-04-01")}
- true
+
+ * The expected result is:
+
+ { "date-interval": interval-date("2012-01-01, 2013-04-01") }
+
+
+### interval-from-time ###
+ * Syntax:
+
+ interval-from-time(string_expression1, string_expression2)
+
+ * Constructor function for the `interval` type by parsing two time strings.
+ * Arguments:
+ * `string_expression1` : The `string` value representing the starting time.
+ * `string_expression2` : The `string` value representing the ending time.
+ * Return Value:
+ * An `interval` value between the two times.
+
+ * Example:
+
+ {"time-interval": interval-from-time("12:23:34.456Z", "233445567+0800")}
+
+
+ * The expected result is:
+
+ { "time-interval": interval-time("12:23:34.456Z, 15:34:45.567Z") }
+
+
+### interval-from-datetime ###
+ * Syntax:
+
+ interval-from-datetime(string_expression1, string_expression2)
+
+ * Constructor function for `interval` type by parsing two datetime strings.
+ * Arguments:
+ * `string_expression1` : The `string` value representing the starting datetime.
+ * `string_expression2` : The `string` value representing the ending datetime.
+ * Return Value:
+ * An `interval` value between the two datetimes.
+
+ * Example:
+
+ {"datetime-interval": interval-from-datetime("2012-01-01T12:23:34.456+08:00", "20130401T153445567Z")}
+
+
+ * The expected result is:
+
+ { "datetime-interval": interval-datetime("2012-01-01T04:23:34.456Z, 2013-04-01T15:34:45.567Z") }
+
+
+### interval-start-from-date/time/datetime ###
+ * Syntax:
+
+ interval-start-from-date/time/datetime(date/time/datetime, duration)
+
+ * Construct an `interval` value by the given starting `date`/`time`/`datetime` and the `duration` that the interval lasts.
+ * Arguments:
+ * `date/time/datetime`: a `string` representing a `date`, `time` or `datetime`, or a `date`/`time`/`datetime` value, representing the starting time point.
+ * `duration`: a `string` or `duration` value representing the duration of the interval. Note that duration cannot be negative value.
+ * Return Value:
+ * An `interval` value representing the interval starting from the given time point with the length of duration.
+
+ * Example:
+
+ let $itv1 := interval-start-from-date("1984-01-01", "P1Y")
+ let $itv2 := interval-start-from-time(time("02:23:28.394"), "PT3H24M")
+ let $itv3 := interval-start-from-datetime("1999-09-09T09:09:09.999", duration("P2M30D"))
+ return {"interval1": $itv1, "interval2": $itv2, "interval3": $itv3}
+
+ * The expectecd result is:
+
+ { "interval1": interval-date("1984-01-01, 1985-01-01"), "interval2": interval-time("02:23:28.394Z, 05:47:28.394Z"), "interval3": interval-datetime("1999-09-09T09:09:09.999Z, 1999-12-09T09:09:09.999Z") }
+
+
+### overlap-bins ###
+ * Return Value:
+ * A `interval` value representing the bin containing the `time-to-bin` value. Note that the internal type of this interval value should be the same as the `time-to-bin` type.
+
+ * Syntax:
+
+ overlap-bins(interval_expression, time-bin-anchor, duration-bin-size)
+
+ * Returns an ordered list of `interval` values representing each bin that is overlapping the `interval_expression`.
+ * Arguments:
+ * `interval_expression`: an `interval` value
+ * `time-bin-anchor`: a date/time/datetime value representing an anchor of a bin starts. The type of this argument should be the same as the first `time-to-bin` argument.
+ * `duration-bin-size`: the duration value representing the size of the bin, in the type of year-month-duration or day-time-duration. The type of this duration should be compatible with the type of `time-to-bin`, so that the arithmetic operation between `time-to-bin` and `duration-bin-size` is well-defined. Currently AsterixDB supports the following arithmetic operations:
+ * datetime +|- year-month-duration
+ * datetime +|- day-time-duration
+ * date +|- year-month-duration
+ * date +|- day-time-duration
+ * time +|- day-time-duration
+ * Return Value:
+ * A ordered list of `interval` values representing each bin that is overlapping the `interval_expression`. Note that the internal type as `time-to-bin` and `duration-bin-size`.
+
+ * Example:
+
+ let $itv1 := interval-from-time(time("17:23:37"), time("18:30:21"))
+ let $itv2 := interval-from-date(date("1984-03-17"), date("2013-08-22"))
+ let $itv3 := interval-from-datetime(datetime("1800-01-01T23:59:48.938"), datetime("2015-07-26T13:28:30.218"))
+ return { "timebins": overlap-bins($itv1, time("00:00:00"), day-time-duration("PT30M")),
+ "datebins": overlap-bins($itv2, date("1990-01-01"), year-month-duration("P20Y")),
+ "datetimebins": overlap-bins($itv3, datetime("1900-01-01T00:00:00.000"), year-month-duration("P100Y")) }
+
+ * The expected result is:
+
+ { "timebins": [ interval-time("17:00:00.000Z, 17:30:00.000Z"), interval-time("17:30:00.000Z, 18:00:00.000Z"), interval-time("18:00:00.000Z, 18:30:00.000Z"), interval-time("18:30:00.000Z, 19:00:00.000Z") ],
+ "datebins": [ interval-date("1970-01-01, 1990-01-01"), interval-date("1990-01-01, 2010-01-01"), interval-date("2010-01-01, 2030-01-01") ],
+ "datetimebins": [ interval-datetime("1800-01-01T00:00:00.000Z, 1900-01-01T00:00:00.000Z"), interval-datetime("1900-01-01T00:00:00.000Z, 2000-01-01T00:00:00.000Z"), interval-datetime("2000-01-01T00:00:00.000Z, 2100-01-01T00:00:00.000Z") ] }
## <a id="OtherFunctions">Other Functions</a> <font size="4"><a href="#toc">[Back to TOC]</a></font> ##
diff --git a/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/library/java/JObjects.java b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/library/java/JObjects.java
index b9b4c41..191fda6 100644
--- a/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/library/java/JObjects.java
+++ b/asterix-external-data/src/main/java/edu/uci/ics/asterix/external/library/java/JObjects.java
@@ -50,6 +50,7 @@
import edu.uci.ics.asterix.om.types.AUnorderedListType;
import edu.uci.ics.asterix.om.types.BuiltinType;
import edu.uci.ics.asterix.om.types.IAType;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
public class JObjects {
@@ -304,8 +305,12 @@
interval = new AMutableInterval(intervalStart, intervalEnd, (byte) 0);
}
- public void setValue(long intervalStart, long intervalEnd, byte typetag) {
- interval.setValue(intervalStart, intervalEnd, typetag);
+ public void setValue(long intervalStart, long intervalEnd, byte typetag) throws AsterixException {
+ try {
+ interval.setValue(intervalStart, intervalEnd, typetag);
+ } catch (AlgebricksException e) {
+ throw new AsterixException(e);
+ }
}
@Override
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
index 655bb7f..6fb7d4a 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
@@ -137,7 +137,11 @@
throw new HyracksDataException(e);
}
- aInterval.setValue(chrononTimeInMsStart, chrononTimeInMsEnd, ATypeTag.DATETIME.serialize());
+ try {
+ aInterval.setValue(chrononTimeInMsStart, chrononTimeInMsEnd, ATypeTag.DATETIME.serialize());
+ } catch (AlgebricksException e) {
+ throw new HyracksDataException(e);
+ }
intervalSerde.serialize(aInterval, out);
}
@@ -180,7 +184,11 @@
throw new HyracksDataException(e);
}
- aInterval.setValue(chrononTimeInMsStart, chrononTimeInMsEnd, ATypeTag.TIME.serialize());
+ try {
+ aInterval.setValue(chrononTimeInMsStart, chrononTimeInMsEnd, ATypeTag.TIME.serialize());
+ } catch (AlgebricksException e) {
+ throw new HyracksDataException(e);
+ }
intervalSerde.serialize(aInterval, out);
}
@@ -214,8 +222,12 @@
throw new HyracksDataException(e);
}
- aInterval.setValue((chrononTimeInMsStart / GregorianCalendarSystem.CHRONON_OF_DAY),
- (chrononTimeInMsEnd / GregorianCalendarSystem.CHRONON_OF_DAY), ATypeTag.DATE.serialize());
+ try {
+ aInterval.setValue((chrononTimeInMsStart / GregorianCalendarSystem.CHRONON_OF_DAY),
+ (chrononTimeInMsEnd / GregorianCalendarSystem.CHRONON_OF_DAY), ATypeTag.DATE.serialize());
+ } catch (AlgebricksException e) {
+ throw new HyracksDataException(e);
+ }
intervalSerde.serialize(aInterval, out);
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlSerializerDeserializerProvider.java b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlSerializerDeserializerProvider.java
index 8d083ee..cd61730 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlSerializerDeserializerProvider.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/formats/nontagged/AqlSerializerDeserializerProvider.java
@@ -49,6 +49,7 @@
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AUnorderedListSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AYearMonthDurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.SerializerDeserializerUtil;
+import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.base.IAObject;
import edu.uci.ics.asterix.om.types.AOrderedListType;
import edu.uci.ics.asterix.om.types.ARecordType;
@@ -193,8 +194,10 @@
@Override
public IAObject deserialize(DataInput in) throws HyracksDataException {
try {
- //deserialize the tag to move the input cursor forward
- SerializerDeserializerUtil.deserializeTag(in);
+ //deserialize the tag (move input cursor forward) and check if it's not NULL tag
+ if (SerializerDeserializerUtil.deserializeTag(in) == ATypeTag.NULL) {
+ return ANull.NULL;
+ }
} catch (IOException e) {
throw new HyracksDataException(e);
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AMutableInterval.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AMutableInterval.java
index f7f216b..f76add7 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AMutableInterval.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/AMutableInterval.java
@@ -14,13 +14,18 @@
*/
package edu.uci.ics.asterix.om.base;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+
public class AMutableInterval extends AInterval {
public AMutableInterval(long intervalStart, long intervalEnd, byte typetag) {
super(intervalStart, intervalEnd, typetag);
}
- public void setValue(long intervalStart, long intervalEnd, byte typetag) {
+ public void setValue(long intervalStart, long intervalEnd, byte typetag) throws AlgebricksException {
+ if (intervalStart >= intervalEnd) {
+ throw new AlgebricksException("Invalid interval: the starting time should be less than the ending time.");
+ }
this.intervalStart = intervalStart;
this.intervalEnd = intervalEnd;
this.typetag = typetag;
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/DurationArithmeticOperations.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/DurationArithmeticOperations.java
index d760292..ef87888 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/DurationArithmeticOperations.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/DurationArithmeticOperations.java
@@ -40,11 +40,13 @@
public static long addDuration(long pointChronon, int yearMonthDuration, long dayTimeDuration, boolean isTimeOnly) {
if (isTimeOnly) {
- int rtnChronon = (int) ((pointChronon + dayTimeDuration) % GregorianCalendarSystem.CHRONON_OF_DAY);
- if (rtnChronon < 0) {
- rtnChronon += GregorianCalendarSystem.CHRONON_OF_DAY;
+ long rtnChronon = pointChronon + dayTimeDuration;
+ if (rtnChronon < 0L || rtnChronon > GregorianCalendarSystem.CHRONON_OF_DAY) {
+ rtnChronon %= GregorianCalendarSystem.CHRONON_OF_DAY;
+ if (rtnChronon < 0L) {
+ rtnChronon += GregorianCalendarSystem.CHRONON_OF_DAY;
+ }
}
-
return rtnChronon;
}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
index 6b7b871..cfecd9c 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
@@ -48,6 +48,7 @@
import edu.uci.ics.asterix.om.typecomputer.impl.ConcatNonNullTypeComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.FieldAccessByIndexResultType;
import edu.uci.ics.asterix.om.typecomputer.impl.FieldAccessNestedResultType;
+import edu.uci.ics.asterix.om.typecomputer.impl.GetOverlappingInvervalTypeComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.InjectFailureTypeComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.NonTaggedCollectionMemberResultType;
import edu.uci.ics.asterix.om.typecomputer.impl.NonTaggedFieldAccessByNameResultType;
@@ -88,6 +89,7 @@
import edu.uci.ics.asterix.om.typecomputer.impl.OrderedListConstructorResultType;
import edu.uci.ics.asterix.om.typecomputer.impl.OrderedListOfAInt32TypeComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.OrderedListOfAInt64TypeComputer;
+import edu.uci.ics.asterix.om.typecomputer.impl.OrderedListOfAIntervalTypeComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.OrderedListOfAPointTypeComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.OrderedListOfAStringTypeComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.OrderedListOfAnyTypeComputer;
@@ -526,7 +528,7 @@
"interval-overlaps", 2);
public final static FunctionIdentifier INTERVAL_OVERLAPPED_BY = new FunctionIdentifier(
FunctionConstants.ASTERIX_NS, "interval-overlapped-by", 2);
- public final static FunctionIdentifier OVERLAP = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+ public final static FunctionIdentifier INTERVAL_OVERLAPPING = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
"interval-overlapping", 2);
public final static FunctionIdentifier INTERVAL_STARTS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
"interval-starts", 2);
@@ -569,6 +571,8 @@
FunctionConstants.ASTERIX_NS, "get-year-month-duration", 1);
public final static FunctionIdentifier GET_DAY_TIME_DURATION = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
"get-day-time-duration", 1);
+ public final static FunctionIdentifier DURATION_FROM_INTERVAL = new FunctionIdentifier(
+ FunctionConstants.ASTERIX_NS, "duration-from-interval", 1);
// spatial
public final static FunctionIdentifier CREATE_POINT = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
@@ -626,8 +630,24 @@
FunctionConstants.ASTERIX_NS, "get-interval-start", 1);
public static final FunctionIdentifier ACCESSOR_TEMPORAL_INTERVAL_END = new FunctionIdentifier(
FunctionConstants.ASTERIX_NS, "get-interval-end", 1);
+ public static final FunctionIdentifier ACCESSOR_TEMPORAL_INTERVAL_START_DATETIME = new FunctionIdentifier(
+ FunctionConstants.ASTERIX_NS, "get-interval-start-datetime", 1);
+ public static final FunctionIdentifier ACCESSOR_TEMPORAL_INTERVAL_END_DATETIME = new FunctionIdentifier(
+ FunctionConstants.ASTERIX_NS, "get-interval-end-datetime", 1);
+ public static final FunctionIdentifier ACCESSOR_TEMPORAL_INTERVAL_START_DATE = new FunctionIdentifier(
+ FunctionConstants.ASTERIX_NS, "get-interval-start-date", 1);
+ public static final FunctionIdentifier ACCESSOR_TEMPORAL_INTERVAL_END_DATE = new FunctionIdentifier(
+ FunctionConstants.ASTERIX_NS, "get-interval-end-date", 1);
+ public static final FunctionIdentifier ACCESSOR_TEMPORAL_INTERVAL_START_TIME = new FunctionIdentifier(
+ FunctionConstants.ASTERIX_NS, "get-interval-start-time", 1);
+ public static final FunctionIdentifier ACCESSOR_TEMPORAL_INTERVAL_END_TIME = new FunctionIdentifier(
+ FunctionConstants.ASTERIX_NS, "get-interval-end-time", 1);
public static final FunctionIdentifier INTERVAL_BIN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
"interval-bin", 3);
+ public static final FunctionIdentifier OVERLAP_BINS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+ "overlap-bins", 3);
+ public static final FunctionIdentifier GET_OVERLAPPING_INTERVAL = new FunctionIdentifier(
+ FunctionConstants.ASTERIX_NS, "get-overlapping-interval", 2);
// Temporal functions
public static final FunctionIdentifier DATE_FROM_UNIX_TIME_IN_DAYS = new FunctionIdentifier(
@@ -990,6 +1010,12 @@
addFunction(ACCESSOR_TEMPORAL_MILLISEC, OptionalAInt64TypeComputer.INSTANCE, true);
addFunction(ACCESSOR_TEMPORAL_INTERVAL_START, OptionalATemporalInstanceTypeComputer.INSTANCE, true);
addFunction(ACCESSOR_TEMPORAL_INTERVAL_END, OptionalATemporalInstanceTypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_INTERVAL_START_DATETIME, OptionalADateTimeTypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_INTERVAL_END_DATETIME, OptionalADateTimeTypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_INTERVAL_START_DATE, OptionalADateTypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_INTERVAL_END_DATE, OptionalADateTypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_INTERVAL_START_TIME, OptionalATimeTypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_INTERVAL_END_TIME, OptionalATimeTypeComputer.INSTANCE, true);
// temporal functions
addFunction(DATE_FROM_UNIX_TIME_IN_DAYS, OptionalADateTypeComputer.INSTANCE, true);
@@ -1009,7 +1035,7 @@
addFunction(INTERVAL_MET_BY, OptionalABooleanTypeComputer.INSTANCE, true);
addFunction(INTERVAL_OVERLAPS, OptionalABooleanTypeComputer.INSTANCE, true);
addFunction(INTERVAL_OVERLAPPED_BY, OptionalABooleanTypeComputer.INSTANCE, true);
- addFunction(OVERLAP, OptionalABooleanTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_OVERLAPPING, OptionalABooleanTypeComputer.INSTANCE, true);
addFunction(INTERVAL_STARTS, OptionalABooleanTypeComputer.INSTANCE, true);
addFunction(INTERVAL_STARTED_BY, OptionalABooleanTypeComputer.INSTANCE, true);
addFunction(INTERVAL_COVERS, OptionalABooleanTypeComputer.INSTANCE, true);
@@ -1038,6 +1064,9 @@
addFunction(PRINT_DATE, OptionalAStringTypeComputer.INSTANCE, true);
addFunction(PRINT_TIME, OptionalAStringTypeComputer.INSTANCE, true);
addFunction(PRINT_DATETIME, OptionalAStringTypeComputer.INSTANCE, true);
+ addFunction(OVERLAP_BINS, OrderedListOfAIntervalTypeComputer.INSTANCE, true);
+ addFunction(GET_OVERLAPPING_INTERVAL, GetOverlappingInvervalTypeComputer.INSTANCE, true);
+ addFunction(DURATION_FROM_INTERVAL, OptionalADayTimeDurationTypeComputer.INSTANCE, true);
// interval constructors
addFunction(INTERVAL_CONSTRUCTOR_DATE, OptionalAIntervalTypeComputer.INSTANCE, true);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/base/TypeComputerUtilities.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/base/TypeComputerUtilities.java
index 6464c4a..c13d6ed 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/base/TypeComputerUtilities.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/base/TypeComputerUtilities.java
@@ -67,7 +67,7 @@
return null;
}
- public static boolean nullableType(ILogicalExpression expression, IVariableTypeEnvironment env)
+ public static boolean inputInferednullableType(ILogicalExpression expression, IVariableTypeEnvironment env)
throws AlgebricksException {
AbstractFunctionCallExpression func = (AbstractFunctionCallExpression) expression;
if (!(func instanceof ScalarFunctionCallExpression)) {
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/AIntervalTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/AIntervalTypeComputer.java
new file mode 100644
index 0000000..a6c3d1c
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/AIntervalTypeComputer.java
@@ -0,0 +1,41 @@
+/*
+ * 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.typecomputer.impl;
+
+import edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.IAType;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
+
+public class AIntervalTypeComputer implements IResultTypeComputer {
+
+ public static final AIntervalTypeComputer INSTANCE = new AIntervalTypeComputer();
+
+ private AIntervalTypeComputer() {
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer#computeType(edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression, edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment, edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider)
+ */
+ @Override
+ public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
+ IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ return BuiltinType.AINTERVAL;
+ }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/GetOverlappingInvervalTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/GetOverlappingInvervalTypeComputer.java
new file mode 100644
index 0000000..52b13f4
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/GetOverlappingInvervalTypeComputer.java
@@ -0,0 +1,45 @@
+/*
+ * 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.typecomputer.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer;
+import edu.uci.ics.asterix.om.types.AUnionType;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.IAType;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
+
+public class GetOverlappingInvervalTypeComputer implements IResultTypeComputer {
+
+ public static final GetOverlappingInvervalTypeComputer INSTANCE = new GetOverlappingInvervalTypeComputer();
+
+ private GetOverlappingInvervalTypeComputer() {
+
+ }
+
+ public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
+ IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ List<IAType> unionList = new ArrayList<IAType>();
+ unionList.add(BuiltinType.ANULL);
+ unionList.add(BuiltinType.AINTERVAL);
+ return new AUnionType(unionList, "IntervalOrNullResult");
+ }
+
+}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedMinMaxAggTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedMinMaxAggTypeComputer.java
index 86d3ffae..a4a460d 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedMinMaxAggTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedMinMaxAggTypeComputer.java
@@ -81,6 +81,21 @@
case STRING:
unionList.add(BuiltinType.ASTRING);
break;
+ case DATE:
+ unionList.add(BuiltinType.ADATE);
+ break;
+ case TIME:
+ unionList.add(BuiltinType.ATIME);
+ break;
+ case DATETIME:
+ unionList.add(BuiltinType.ADATETIME);
+ break;
+ case YEARMONTHDURATION:
+ unionList.add(BuiltinType.AYEARMONTHDURATION);
+ break;
+ case DAYTIMEDURATION:
+ unionList.add(BuiltinType.ADAYTIMEDURATION);
+ break;
case ANY:
return BuiltinType.ANY;
default: {
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalABinaryTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalABinaryTypeComputer.java
index 01d507f..68e9b63 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalABinaryTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalABinaryTypeComputer.java
@@ -37,7 +37,7 @@
@Override public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ABINARY);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalABooleanTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalABooleanTypeComputer.java
index 764624f..a274a49 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalABooleanTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalABooleanTypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ABOOLEAN);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalACircleTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalACircleTypeComputer.java
index 92e26e0..69cb3a8 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalACircleTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalACircleTypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ACIRCLE);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADateTimeTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADateTimeTypeComputer.java
index f0d2caf..d66e794 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADateTimeTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADateTimeTypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ADATETIME);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADateTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADateTypeComputer.java
index 093849d..b61d116 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADateTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADateTypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ADATE);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADayTimeDurationTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADayTimeDurationTypeComputer.java
index c3c7c25..c1e7e80 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADayTimeDurationTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADayTimeDurationTypeComputer.java
@@ -41,7 +41,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ADAYTIMEDURATION);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADoubleTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADoubleTypeComputer.java
index 324e078..10f6ab0 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADoubleTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADoubleTypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ADOUBLE);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADurationTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADurationTypeComputer.java
index 85556ed..e12e173 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADurationTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalADurationTypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ADURATION);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAFloatTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAFloatTypeComputer.java
index d9da2b8..9b7f571 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAFloatTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAFloatTypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.AFLOAT);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAInt16TypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAInt16TypeComputer.java
index a737ed2..b26f41a 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAInt16TypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAInt16TypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.AINT16);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAInt32TypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAInt32TypeComputer.java
index c666d36..77735e7 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAInt32TypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAInt32TypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.AINT32);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAInt64TypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAInt64TypeComputer.java
index 701b1ae..7d967d8 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAInt64TypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAInt64TypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.AINT64);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAInt8TypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAInt8TypeComputer.java
index ad6b130..e6bf314 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAInt8TypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAInt8TypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.AINT8);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAIntervalTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAIntervalTypeComputer.java
index 9c5a7d5..69bccc0 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAIntervalTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAIntervalTypeComputer.java
@@ -37,7 +37,7 @@
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.AINTERVAL);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalALineTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalALineTypeComputer.java
index e692dbd..0da2d4c 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalALineTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalALineTypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ALINE);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAPoint3DTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAPoint3DTypeComputer.java
index 8f0bf7a..8ab5eb7 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAPoint3DTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAPoint3DTypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.APOINT3D);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAPointTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAPointTypeComputer.java
index 1a93ee6..f558274 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAPointTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAPointTypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.APOINT);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAPolygonTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAPolygonTypeComputer.java
index 405608c..bbc6fad 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAPolygonTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAPolygonTypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.APOLYGON);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalARectangleTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalARectangleTypeComputer.java
index c6a8026..d9cf904 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalARectangleTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalARectangleTypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ARECTANGLE);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAStringTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAStringTypeComputer.java
index 5b0642d..b24ebb6 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAStringTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAStringTypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ASTRING);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalATimeTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalATimeTypeComputer.java
index 4d466e7..7a8406f 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalATimeTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalATimeTypeComputer.java
@@ -37,7 +37,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.ATIME);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAYearMonthDurationTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAYearMonthDurationTypeComputer.java
index 3350674..b05bece 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAYearMonthDurationTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalAYearMonthDurationTypeComputer.java
@@ -41,7 +41,7 @@
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.nullableType(expression, env)) {
+ if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
List<IAType> unionList = new ArrayList<IAType>();
unionList.add(BuiltinType.ANULL);
unionList.add(BuiltinType.AYEARMONTHDURATION);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OrderedListOfAIntervalTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OrderedListOfAIntervalTypeComputer.java
new file mode 100644
index 0000000..4e5a354
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OrderedListOfAIntervalTypeComputer.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.typecomputer.impl;
+
+import edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer;
+import edu.uci.ics.asterix.om.types.AOrderedListType;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.IAType;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
+
+public class OrderedListOfAIntervalTypeComputer implements IResultTypeComputer {
+
+ public static final OrderedListOfAIntervalTypeComputer INSTANCE = new OrderedListOfAIntervalTypeComputer();
+
+ private OrderedListOfAIntervalTypeComputer() {
+ }
+
+ @Override
+ public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
+ IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ return new AOrderedListType(BuiltinType.AINTERVAL, null);
+ }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/CircleCenterAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/CircleCenterAccessor.java
index 38edf28..e889c0b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/CircleCenterAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/CircleCenterAccessor.java
@@ -46,7 +46,7 @@
private static final FunctionIdentifier FID = AsterixBuiltinFunctions.GET_CIRCLE_CENTER_ACCESSOR;
private static final byte SER_CICLE_TAG = ATypeTag.CIRCLE.serialize();
- private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+ private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/CircleRadiusAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/CircleRadiusAccessor.java
index c8f467b..c43e25a 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/CircleRadiusAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/CircleRadiusAccessor.java
@@ -17,7 +17,6 @@
import java.io.DataOutput;
import java.io.IOException;
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ACircleSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
@@ -45,7 +44,7 @@
private static final FunctionIdentifier FID = AsterixBuiltinFunctions.GET_CIRCLE_RADIUS_ACCESSOR;
private static final byte SER_CICLE_TAG = ATypeTag.CIRCLE.serialize();
- private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+ private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/LineRectanglePolygonAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/LineRectanglePolygonAccessor.java
index e5496ca..27f9370 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/LineRectanglePolygonAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/LineRectanglePolygonAccessor.java
@@ -18,7 +18,6 @@
import java.io.IOException;
import edu.uci.ics.asterix.builders.OrderedListBuilder;
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
import edu.uci.ics.asterix.dataflow.data.nontagged.Coordinate;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
@@ -54,7 +53,7 @@
private static final byte SER_LINE_TAG = ATypeTag.LINE.serialize();
private static final byte SER_RECTANGLE_TAG = ATypeTag.RECTANGLE.serialize();
private static final byte SER_POLYGON_TAG = ATypeTag.POLYGON.serialize();
- private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+ private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/PointXCoordinateAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/PointXCoordinateAccessor.java
index 498fa39..97f94c7 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/PointXCoordinateAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/PointXCoordinateAccessor.java
@@ -17,7 +17,6 @@
import java.io.DataOutput;
import java.io.IOException;
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
import edu.uci.ics.asterix.dataflow.data.nontagged.Coordinate;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.APointSerializerDeserializer;
@@ -46,7 +45,7 @@
private static final FunctionIdentifier FID = AsterixBuiltinFunctions.GET_POINT_X_COORDINATE_ACCESSOR;
private static final byte SER_POINT_TAG = ATypeTag.POINT.serialize();
- private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+ private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/PointYCoordinateAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/PointYCoordinateAccessor.java
index 72d7072..37d33d8 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/PointYCoordinateAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/PointYCoordinateAccessor.java
@@ -17,7 +17,6 @@
import java.io.DataOutput;
import java.io.IOException;
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
import edu.uci.ics.asterix.dataflow.data.nontagged.Coordinate;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.APointSerializerDeserializer;
@@ -46,7 +45,7 @@
private static final FunctionIdentifier FID = AsterixBuiltinFunctions.GET_POINT_Y_COORDINATE_ACCESSOR;
private static final byte SER_POINT_TAG = ATypeTag.POINT.serialize();
- private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+ private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalDayAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalDayAccessor.java
index fb9bf4c..2497b54 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalDayAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalDayAccessor.java
@@ -17,6 +17,7 @@
import java.io.DataOutput;
import java.io.IOException;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADayTimeDurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
@@ -50,6 +51,7 @@
private static final byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
private static final byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
private static final byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+ private static final byte SER_DAY_TIME_DURATION_TYPE_TAG = ATypeTag.DAYTIMEDURATION.serialize();
private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@@ -73,21 +75,21 @@
public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
return new ICopyEvaluator() {
- private DataOutput out = output.getDataOutput();
+ private final DataOutput out = output.getDataOutput();
- private ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+ private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
- private ICopyEvaluator eval = args[0].createEvaluator(argOut);
+ private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
- private GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
+ private final GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
// for output: type integer
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
- private AMutableInt64 aMutableInt64 = new AMutableInt64(0);
+ private final AMutableInt64 aMutableInt64 = new AMutableInt64(0);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
@Override
@@ -105,6 +107,13 @@
return;
}
+ if (bytes[0] == SER_DAY_TIME_DURATION_TYPE_TAG) {
+ aMutableInt64.setValue(calSystem.getDurationDay(ADayTimeDurationSerializerDeserializer
+ .getDayTime(bytes, 1)));
+ intSerde.serialize(aMutableInt64, out);
+ return;
+ }
+
long chrononTimeInMs = 0;
if (bytes[0] == SER_DATE_TYPE_TAG) {
chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, 1)
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalHourAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalHourAccessor.java
index 33dc9fd..2024d61 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalHourAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalHourAccessor.java
@@ -17,6 +17,7 @@
import java.io.DataOutput;
import java.io.IOException;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADayTimeDurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
@@ -50,6 +51,7 @@
private static final byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
private static final byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
private static final byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+ private static final byte SER_DAY_TIME_DURATION_TYPE_TAG = ATypeTag.DAYTIMEDURATION.serialize();
private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@@ -74,21 +76,21 @@
public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
return new ICopyEvaluator() {
- private DataOutput out = output.getDataOutput();
+ private final DataOutput out = output.getDataOutput();
- private ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+ private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
- private ICopyEvaluator eval = args[0].createEvaluator(argOut);
+ private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
- private GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
+ private final GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
// for output: type integer
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
- private AMutableInt64 aMutableInt64 = new AMutableInt64(0);
+ private final AMutableInt64 aMutableInt64 = new AMutableInt64(0);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
@Override
@@ -106,6 +108,13 @@
return;
}
+ if (bytes[0] == SER_DAY_TIME_DURATION_TYPE_TAG) {
+ aMutableInt64.setValue(calSystem.getDurationHour(ADayTimeDurationSerializerDeserializer
+ .getDayTime(bytes, 1)));
+ intSerde.serialize(aMutableInt64, out);
+ return;
+ }
+
long chrononTimeInMs = 0;
if (bytes[0] == SER_TIME_TYPE_TAG) {
chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, 1);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalEndAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalEndAccessor.java
index e8ea6d5..e6789a1 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalEndAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalEndAccessor.java
@@ -72,27 +72,27 @@
public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
return new ICopyEvaluator() {
- private DataOutput out = output.getDataOutput();
+ private final DataOutput out = output.getDataOutput();
- private ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+ private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
- private ICopyEvaluator eval = args[0].createEvaluator(argOut);
+ private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
// possible output
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ADate> dateSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<ADate> dateSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATE);
- private AMutableDate aDate = new AMutableDate(0);
+ private final AMutableDate aDate = new AMutableDate(0);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATETIME);
- private AMutableDateTime aDateTime = new AMutableDateTime(0);
+ private final AMutableDateTime aDateTime = new AMutableDateTime(0);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ATIME);
- private AMutableTime aTime = new AMutableTime(0);
+ private final AMutableTime aTime = new AMutableTime(0);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
@Override
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalEndDateAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalEndDateAccessor.java
new file mode 100644
index 0000000..5f3832e
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalEndDateAccessor.java
@@ -0,0 +1,128 @@
+/*
+ * 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.runtime.evaluators.accessors;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.ADate;
+import edu.uci.ics.asterix.om.base.AMutableDate;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+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.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class TemporalIntervalEndDateAccessor extends AbstractScalarFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final FunctionIdentifier FID = AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_INTERVAL_END_DATE;
+
+ private static final byte SER_INTERVAL_TYPE_TAG = ATypeTag.INTERVAL.serialize();
+ private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+
+ private static final byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
+
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new TemporalIntervalEndDateAccessor();
+ }
+ };
+
+ public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+ return new ICopyEvaluatorFactory() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+ return new ICopyEvaluator() {
+
+ private final DataOutput out = output.getDataOutput();
+
+ private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+
+ private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+
+ // possible output
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<ADate> dateSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ADATE);
+ private final AMutableDate aDate = new AMutableDate(0);
+
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ANULL);
+
+ @Override
+ public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+ argOut.reset();
+ eval.evaluate(tuple);
+ byte[] bytes = argOut.getByteArray();
+
+ try {
+ if (bytes[0] == SER_NULL_TYPE_TAG) {
+ nullSerde.serialize(ANull.NULL, out);
+ return;
+ } else if (bytes[0] == SER_INTERVAL_TYPE_TAG) {
+ byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes, 1);
+ long endTime = AIntervalSerializerDeserializer.getIntervalEnd(bytes, 1);
+ if (timeType == SER_DATE_TYPE_TAG) {
+ aDate.setValue((int) (endTime));
+ dateSerde.serialize(aDate, out);
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/INTERVAL(of DATE), but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]));
+ }
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/INTERVAL(of DATE), but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]));
+ }
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
+ }
+ };
+ }
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+ */
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return FID;
+ }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalEndDatetimeAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalEndDatetimeAccessor.java
new file mode 100644
index 0000000..a59fdf6
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalEndDatetimeAccessor.java
@@ -0,0 +1,127 @@
+/*
+ * 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.runtime.evaluators.accessors;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.ADateTime;
+import edu.uci.ics.asterix.om.base.AMutableDateTime;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+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.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class TemporalIntervalEndDatetimeAccessor extends AbstractScalarFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final FunctionIdentifier FID = AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_INTERVAL_END_DATETIME;
+
+ private static final byte SER_INTERVAL_TYPE_TAG = ATypeTag.INTERVAL.serialize();
+ private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+
+ private static final byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
+
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new TemporalIntervalEndDatetimeAccessor();
+ }
+ };
+
+ public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+ return new ICopyEvaluatorFactory() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+ return new ICopyEvaluator() {
+
+ private final DataOutput out = output.getDataOutput();
+
+ private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+
+ private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+
+ // possible output
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ADATETIME);
+ private final AMutableDateTime aDateTime = new AMutableDateTime(0);
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ANULL);
+
+ @Override
+ public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+ argOut.reset();
+ eval.evaluate(tuple);
+ byte[] bytes = argOut.getByteArray();
+
+ try {
+ if (bytes[0] == SER_NULL_TYPE_TAG) {
+ nullSerde.serialize(ANull.NULL, out);
+ return;
+ } else if (bytes[0] == SER_INTERVAL_TYPE_TAG) {
+ byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes, 1);
+ long endTime = AIntervalSerializerDeserializer.getIntervalEnd(bytes, 1);
+ if (timeType == SER_DATETIME_TYPE_TAG) {
+ aDateTime.setValue(endTime);
+ datetimeSerde.serialize(aDateTime, out);
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/INTERVAL(of DATETIME), but got INTERVAL(of "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(timeType) + ")");
+ }
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/INTERVAL(of DATETIME), but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]));
+ }
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
+ }
+ };
+ }
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+ */
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return FID;
+ }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalEndTimeAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalEndTimeAccessor.java
new file mode 100644
index 0000000..83bd135
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalEndTimeAccessor.java
@@ -0,0 +1,127 @@
+/*
+ * 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.runtime.evaluators.accessors;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.AMutableTime;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.base.ATime;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+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.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class TemporalIntervalEndTimeAccessor extends AbstractScalarFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final FunctionIdentifier FID = AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_INTERVAL_END_TIME;
+
+ private static final byte SER_INTERVAL_TYPE_TAG = ATypeTag.INTERVAL.serialize();
+ private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+
+ private static final byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
+
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new TemporalIntervalEndTimeAccessor();
+ }
+ };
+
+ public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+ return new ICopyEvaluatorFactory() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+ return new ICopyEvaluator() {
+
+ private final DataOutput out = output.getDataOutput();
+
+ private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+
+ private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+
+ // possible output
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ATIME);
+ private final AMutableTime aTime = new AMutableTime(0);
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ANULL);
+
+ @Override
+ public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+ argOut.reset();
+ eval.evaluate(tuple);
+ byte[] bytes = argOut.getByteArray();
+
+ try {
+ if (bytes[0] == SER_NULL_TYPE_TAG) {
+ nullSerde.serialize(ANull.NULL, out);
+ return;
+ } else if (bytes[0] == SER_INTERVAL_TYPE_TAG) {
+ byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes, 1);
+ long endTime = AIntervalSerializerDeserializer.getIntervalEnd(bytes, 1);
+ if (timeType == SER_TIME_TYPE_TAG) {
+ aTime.setValue((int) (endTime));
+ timeSerde.serialize(aTime, out);
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/INTERVAL(of TIME), but got INTERVAL(of "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(timeType) + ")");
+ }
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/INTERVAL(of TIME), but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]));
+ }
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
+ }
+ };
+ }
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+ */
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return FID;
+ }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalStartAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalStartAccessor.java
index ef76934..0db2063 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalStartAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalStartAccessor.java
@@ -72,27 +72,27 @@
public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
return new ICopyEvaluator() {
- private DataOutput out = output.getDataOutput();
+ private final DataOutput out = output.getDataOutput();
- private ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+ private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
- private ICopyEvaluator eval = args[0].createEvaluator(argOut);
+ private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
// possible output
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ADate> dateSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<ADate> dateSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATE);
- private AMutableDate aDate = new AMutableDate(0);
+ private final AMutableDate aDate = new AMutableDate(0);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATETIME);
- private AMutableDateTime aDateTime = new AMutableDateTime(0);
+ private final AMutableDateTime aDateTime = new AMutableDateTime(0);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ATIME);
- private AMutableTime aTime = new AMutableTime(0);
+ private final AMutableTime aTime = new AMutableTime(0);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
@Override
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalStartDateAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalStartDateAccessor.java
new file mode 100644
index 0000000..b533859
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalStartDateAccessor.java
@@ -0,0 +1,127 @@
+/*
+ * 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.runtime.evaluators.accessors;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.ADate;
+import edu.uci.ics.asterix.om.base.AMutableDate;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+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.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class TemporalIntervalStartDateAccessor extends AbstractScalarFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final FunctionIdentifier FID = AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_INTERVAL_START_DATE;
+
+ private static final byte SER_INTERVAL_TYPE_TAG = ATypeTag.INTERVAL.serialize();
+ private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+
+ private static final byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
+
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new TemporalIntervalStartDateAccessor();
+ }
+ };
+
+ public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+ return new ICopyEvaluatorFactory() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+ return new ICopyEvaluator() {
+
+ private final DataOutput out = output.getDataOutput();
+
+ private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+
+ private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+
+ // possible output
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<ADate> dateSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ADATE);
+ private final AMutableDate aDate = new AMutableDate(0);
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ANULL);
+
+ @Override
+ public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+ argOut.reset();
+ eval.evaluate(tuple);
+ byte[] bytes = argOut.getByteArray();
+
+ try {
+ if (bytes[0] == SER_NULL_TYPE_TAG) {
+ nullSerde.serialize(ANull.NULL, out);
+ return;
+ } else if (bytes[0] == SER_INTERVAL_TYPE_TAG) {
+ byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes, 1);
+ long startTime = AIntervalSerializerDeserializer.getIntervalStart(bytes, 1);
+ if (timeType == SER_DATE_TYPE_TAG) {
+ aDate.setValue((int) (startTime));
+ dateSerde.serialize(aDate, out);
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/INTERVAL(of DATE), but got INTERVAL(of "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(timeType) + ")");
+ }
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/INTERVAL(of DATE), but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]));
+ }
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
+ }
+ };
+ }
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+ */
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return FID;
+ }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalStartDatetimeAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalStartDatetimeAccessor.java
new file mode 100644
index 0000000..25e9d59
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalStartDatetimeAccessor.java
@@ -0,0 +1,127 @@
+/*
+ * 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.runtime.evaluators.accessors;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.ADateTime;
+import edu.uci.ics.asterix.om.base.AMutableDateTime;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+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.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class TemporalIntervalStartDatetimeAccessor extends AbstractScalarFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final FunctionIdentifier FID = AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_INTERVAL_START_DATETIME;
+
+ private static final byte SER_INTERVAL_TYPE_TAG = ATypeTag.INTERVAL.serialize();
+ private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+
+ private static final byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
+
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new TemporalIntervalStartDatetimeAccessor();
+ }
+ };
+
+ public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+ return new ICopyEvaluatorFactory() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+ return new ICopyEvaluator() {
+
+ private final DataOutput out = output.getDataOutput();
+
+ private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+
+ private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+
+ // possible output
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ADATETIME);
+ private final AMutableDateTime aDateTime = new AMutableDateTime(0);
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ANULL);
+
+ @Override
+ public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+ argOut.reset();
+ eval.evaluate(tuple);
+ byte[] bytes = argOut.getByteArray();
+
+ try {
+ if (bytes[0] == SER_NULL_TYPE_TAG) {
+ nullSerde.serialize(ANull.NULL, out);
+ return;
+ } else if (bytes[0] == SER_INTERVAL_TYPE_TAG) {
+ byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes, 1);
+ long startTime = AIntervalSerializerDeserializer.getIntervalStart(bytes, 1);
+ if (timeType == SER_DATETIME_TYPE_TAG) {
+ aDateTime.setValue(startTime);
+ datetimeSerde.serialize(aDateTime, out);
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/INTERVAL(of DATETIME), but got INTERVAL(of "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(timeType) + ")");
+ }
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/INTERVAL(of DATETIME), but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]));
+ }
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
+ }
+ };
+ }
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+ */
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return FID;
+ }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalStartTimeAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalStartTimeAccessor.java
new file mode 100644
index 0000000..ca1f5c2
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalStartTimeAccessor.java
@@ -0,0 +1,126 @@
+/*
+ * 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.runtime.evaluators.accessors;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.AMutableTime;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.base.ATime;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+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.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class TemporalIntervalStartTimeAccessor extends AbstractScalarFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final FunctionIdentifier FID = AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_INTERVAL_START_TIME;
+
+ private static final byte SER_INTERVAL_TYPE_TAG = ATypeTag.INTERVAL.serialize();
+ private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+
+ private static final byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
+
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new TemporalIntervalStartTimeAccessor();
+ }
+ };
+
+ public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+ return new ICopyEvaluatorFactory() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+ return new ICopyEvaluator() {
+
+ private final DataOutput out = output.getDataOutput();
+
+ private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+
+ private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+
+ // possible output
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ATIME);
+ private final AMutableTime aTime = new AMutableTime(0);
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ANULL);
+
+ @Override
+ public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+ argOut.reset();
+ eval.evaluate(tuple);
+ byte[] bytes = argOut.getByteArray();
+
+ try {
+ if (bytes[0] == SER_NULL_TYPE_TAG) {
+ nullSerde.serialize(ANull.NULL, out);
+ return;
+ } else if (bytes[0] == SER_INTERVAL_TYPE_TAG) {
+ byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes, 1);
+ long startTime = AIntervalSerializerDeserializer.getIntervalStart(bytes, 1);
+ if (timeType == SER_TIME_TYPE_TAG) {
+ aTime.setValue((int) (startTime));
+ timeSerde.serialize(aTime, out);
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/INTERVAL(of TIME), but got INTERVAL(of "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]) + ")");
+ }
+ } else {
+ throw new AlgebricksException(FID.getName() + ": expects NULL/INTERVAL, but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]));
+ }
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
+ }
+ };
+ }
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+ */
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return FID;
+ }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java
index 701ecd3..35ae381 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java
@@ -17,6 +17,7 @@
import java.io.DataOutput;
import java.io.IOException;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADayTimeDurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
@@ -50,6 +51,7 @@
private static final byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
private static final byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
private static final byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+ private static final byte SER_DAY_TIME_DURATION_TYPE_TAG = ATypeTag.DAYTIMEDURATION.serialize();
private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@@ -74,21 +76,21 @@
public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
return new ICopyEvaluator() {
- private DataOutput out = output.getDataOutput();
+ private final DataOutput out = output.getDataOutput();
- private ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+ private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
- private ICopyEvaluator eval = args[0].createEvaluator(argOut);
+ private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
- private GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
+ private final GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
// for output: type integer
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
- private AMutableInt64 aMutableInt64 = new AMutableInt64(0);
+ private final AMutableInt64 aMutableInt64 = new AMutableInt64(0);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
@Override
@@ -106,6 +108,14 @@
return;
}
+ if (bytes[0] == SER_DAY_TIME_DURATION_TYPE_TAG) {
+ aMutableInt64.setValue(calSystem
+ .getDurationMillisecond(ADayTimeDurationSerializerDeserializer.getDayTime(
+ bytes, 1)));
+ intSerde.serialize(aMutableInt64, out);
+ return;
+ }
+
long chrononTimeInMs = 0;
if (bytes[0] == SER_TIME_TYPE_TAG) {
chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, 1);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java
index 13c3213..727c797 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java
@@ -17,6 +17,7 @@
import java.io.DataOutput;
import java.io.IOException;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADayTimeDurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
@@ -50,6 +51,7 @@
private static final byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
private static final byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
private static final byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+ private static final byte SER_DAY_TIME_DURATION_TYPE_TAG = ATypeTag.DAYTIMEDURATION.serialize();
private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@@ -74,21 +76,21 @@
public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
return new ICopyEvaluator() {
- private DataOutput out = output.getDataOutput();
+ private final DataOutput out = output.getDataOutput();
- private ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+ private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
- private ICopyEvaluator eval = args[0].createEvaluator(argOut);
+ private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
- private GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
+ private final GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
// for output: type integer
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
- private AMutableInt64 aMutableInt64 = new AMutableInt64(0);
+ private final AMutableInt64 aMutableInt64 = new AMutableInt64(0);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
@Override
@@ -106,6 +108,14 @@
return;
}
+ if (bytes[0] == SER_DAY_TIME_DURATION_TYPE_TAG) {
+ aMutableInt64
+ .setValue(calSystem.getDurationMinute(ADayTimeDurationSerializerDeserializer
+ .getDayTime(bytes, 1)));
+ intSerde.serialize(aMutableInt64, out);
+ return;
+ }
+
long chrononTimeInMs = 0;
if (bytes[0] == SER_TIME_TYPE_TAG) {
chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, 1);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java
index 85c6aee..ead5445 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java
@@ -20,6 +20,7 @@
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
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.AYearMonthDurationSerializerDeserializer;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.om.base.AInt64;
import edu.uci.ics.asterix.om.base.AMutableInt64;
@@ -50,6 +51,7 @@
private static final byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
private static final byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
private static final byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+ private static final byte SER_YEAR_MONTH_TYPE_TAG = ATypeTag.YEARMONTHDURATION.serialize();
private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@@ -74,21 +76,21 @@
public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
return new ICopyEvaluator() {
- private DataOutput out = output.getDataOutput();
+ private final DataOutput out = output.getDataOutput();
- private ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+ private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
- private ICopyEvaluator eval = args[0].createEvaluator(argOut);
+ private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
- private GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
+ private final GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
// for output: type integer
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
- private AMutableInt64 aMutableInt64 = new AMutableInt64(0);
+ private final AMutableInt64 aMutableInt64 = new AMutableInt64(0);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
@Override
@@ -106,6 +108,14 @@
return;
}
+ if (bytes[0] == SER_YEAR_MONTH_TYPE_TAG) {
+ aMutableInt64.setValue(calSystem
+ .getDurationMonth(AYearMonthDurationSerializerDeserializer.getYearMonth(bytes,
+ 1)));
+ intSerde.serialize(aMutableInt64, out);
+ return;
+ }
+
long chrononTimeInMs = 0;
if (bytes[0] == SER_DATE_TYPE_TAG) {
chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, 1)
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java
index 25ebbbc..c94bc4a 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java
@@ -17,6 +17,7 @@
import java.io.DataOutput;
import java.io.IOException;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADayTimeDurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
@@ -50,6 +51,7 @@
private static final byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
private static final byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
private static final byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+ private static final byte SER_DAY_TIME_DURATION_TYPE_TAG = ATypeTag.DAYTIMEDURATION.serialize();
private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@@ -74,21 +76,21 @@
public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
return new ICopyEvaluator() {
- private DataOutput out = output.getDataOutput();
+ private final DataOutput out = output.getDataOutput();
- private ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+ private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
- private ICopyEvaluator eval = args[0].createEvaluator(argOut);
+ private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
- private GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
+ private final GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
// for output: type integer
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
- private AMutableInt64 aMutableInt64 = new AMutableInt64(0);
+ private final AMutableInt64 aMutableInt64 = new AMutableInt64(0);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
@Override
@@ -106,6 +108,14 @@
return;
}
+ if (bytes[0] == SER_DAY_TIME_DURATION_TYPE_TAG) {
+ aMutableInt64
+ .setValue(calSystem.getDurationSecond(ADayTimeDurationSerializerDeserializer
+ .getDayTime(bytes, 1)));
+ intSerde.serialize(aMutableInt64, out);
+ return;
+ }
+
long chrononTimeInMs = 0;
if (bytes[0] == SER_TIME_TYPE_TAG) {
chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, 1);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java
index b9520d9..8ee5cd6 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java
@@ -20,6 +20,7 @@
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
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.AYearMonthDurationSerializerDeserializer;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.om.base.AInt64;
import edu.uci.ics.asterix.om.base.AMutableInt64;
@@ -51,6 +52,7 @@
private static final byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
private static final byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
private static final byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+ private static final byte SER_YEAR_MONTH_DURATION_TYPE_TAG = ATypeTag.YEARMONTHDURATION.serialize();
private static final byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
@@ -72,21 +74,21 @@
public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
return new ICopyEvaluator() {
- private DataOutput out = output.getDataOutput();
+ private final DataOutput out = output.getDataOutput();
- private ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+ private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
- private ICopyEvaluator eval = args[0].createEvaluator(argOut);
+ private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
- private GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
+ private final GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
// for output: type integer
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
- private AMutableInt64 aMutableInt64 = new AMutableInt64(0);
+ private final AMutableInt64 aMutableInt64 = new AMutableInt64(0);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
@Override
@@ -104,6 +106,14 @@
return;
}
+ if (bytes[0] == SER_YEAR_MONTH_DURATION_TYPE_TAG) {
+ aMutableInt64.setValue(calSystem
+ .getDurationYear(AYearMonthDurationSerializerDeserializer
+ .getYearMonth(bytes, 1)));
+ intSerde.serialize(aMutableInt64, out);
+ return;
+ }
+
long chrononTimeInMs = 0;
if (bytes[0] == SER_DATE_TYPE_TAG) {
chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, 1)
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
index 9b17c90..04a61a5 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
@@ -18,7 +18,9 @@
import java.io.IOException;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADateSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADayTimeDurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AYearMonthDurationSerializerDeserializer;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.om.base.AInterval;
import edu.uci.ics.asterix.om.base.AMutableDuration;
@@ -53,6 +55,8 @@
private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
private final static byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
private final static byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+ private final static byte SER_YEAR_MONTH_DURATION_TYPE_TAG = ATypeTag.YEARMONTHDURATION.serialize();
+ private final static byte SER_DAY_TIME_DURATION_TYPE_TAG = ATypeTag.DAYTIMEDURATION.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
public IFunctionDescriptor createFunctionDescriptor() {
@@ -123,6 +127,14 @@
intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
ADurationSerializerDeserializer.getYearMonth(argOut1.getByteArray(), 1),
ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1), false);
+ } else if (argOut1.getByteArray()[0] == SER_DAY_TIME_DURATION_TYPE_TAG) {
+ intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
+ 0,
+ ADayTimeDurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1), false);
+ } else if (argOut1.getByteArray()[0] == SER_YEAR_MONTH_DURATION_TYPE_TAG) {
+ intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
+ AYearMonthDurationSerializerDeserializer.getYearMonth(argOut1.getByteArray(), 1),
+ 0, false);
} else if (argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
// duration
int stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
index ce4681a..8191a98 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
@@ -18,7 +18,9 @@
import java.io.IOException;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADayTimeDurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AYearMonthDurationSerializerDeserializer;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import edu.uci.ics.asterix.om.base.AInterval;
import edu.uci.ics.asterix.om.base.AMutableDuration;
@@ -53,6 +55,8 @@
private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
private final static byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
private final static byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+ private final static byte SER_DAY_TIME_DURATION_TYPE_TAG = ATypeTag.DAYTIMEDURATION.serialize();
+ private final static byte SER_YEAR_MONTH_DURATION_TYPE_TAG = ATypeTag.YEARMONTHDURATION.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
public IFunctionDescriptor createFunctionDescriptor() {
@@ -135,6 +139,16 @@
intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
ADurationSerializerDeserializer.getYearMonth(argOut1.getByteArray(), 1),
ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1), false);
+ } else if (argOut1.getByteArray()[0] == SER_YEAR_MONTH_DURATION_TYPE_TAG) {
+ intervalEnd = DurationArithmeticOperations
+ .addDuration(
+ intervalStart,
+ AYearMonthDurationSerializerDeserializer.getYearMonth(
+ argOut1.getByteArray(), 1), 0, false);
+ } else if (argOut1.getByteArray()[0] == SER_DAY_TIME_DURATION_TYPE_TAG) {
+ intervalEnd = DurationArithmeticOperations.addDuration(intervalStart, 0,
+ ADayTimeDurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1),
+ false);
} else if (argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
// duration
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
index d4168e1..2e52e9c 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
@@ -17,6 +17,7 @@
import java.io.DataOutput;
import java.io.IOException;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADayTimeDurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ATimeSerializerDeserializer;
import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
@@ -53,6 +54,7 @@
private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
private final static byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
private final static byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+ private final static byte SER_DAY_TIME_DURATION_TYPE_TAG = ATypeTag.DAYTIMEDURATION.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
public IFunctionDescriptor createFunctionDescriptor() {
@@ -132,6 +134,12 @@
intervalEnd = DurationArithmeticOperations.addDuration(intervalStart, 0,
ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1), false);
+ } else if (argOut1.getByteArray()[0] == SER_DAY_TIME_DURATION_TYPE_TAG) {
+
+ intervalEnd = DurationArithmeticOperations.addDuration(intervalStart, 0,
+ ADayTimeDurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1),
+ false);
+
} else if (argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
// duration
@@ -149,7 +157,7 @@
intervalEnd = DurationArithmeticOperations.addDuration(intervalStart, 0,
aDuration.getMilliseconds(), false);
} else {
- throw new AlgebricksException("Wrong format for interval constructor from dates.");
+ throw new AlgebricksException("Wrong format for interval constructor from time.");
}
if (intervalEnd > GregorianCalendarSystem.CHRONON_OF_DAY) {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AbstractQuadStringStringEval.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AbstractQuadStringStringEval.java
index a5afc65..e21d7d8 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AbstractQuadStringStringEval.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AbstractQuadStringStringEval.java
@@ -85,23 +85,20 @@
eval3.evaluate(tuple);
try {
- if (array0.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+ if (array0.getByteArray()[0] == SER_NULL_TYPE_TAG || array1.getByteArray()[0] == SER_NULL_TYPE_TAG
+ || array2.getByteArray()[0] == SER_NULL_TYPE_TAG || array3.getByteArray()[0] == SER_NULL_TYPE_TAG) {
nullSerde.serialize(ANull.NULL, dout);
return;
- } else if (array0.getByteArray()[0] == SER_STRING_TYPE_TAG) {
- if ((array1.getByteArray()[0] != SER_STRING_TYPE_TAG && array1.getByteArray()[0] != SER_NULL_TYPE_TAG)
- || (array2.getByteArray()[0] != SER_STRING_TYPE_TAG && array2.getByteArray()[0] != SER_NULL_TYPE_TAG)
- || (array3.getByteArray()[0] != SER_STRING_TYPE_TAG && array3.getByteArray()[0] != SER_NULL_TYPE_TAG)) {
- throw new AlgebricksException(funcID.getName()
- + ": expects input type (STRING/NULL, STRING/NULL, STRING/NULL, STRING/NULL), but got ("
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array0.getByteArray()[0]) + ", "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array1.getByteArray()[0]) + ", "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array2.getByteArray()[0]) + ", "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array3.getByteArray()[0]) + ".");
- }
-
- } else {
- throw new AlgebricksException("Expects String or NULL Type.");
+ } else if (array0.getByteArray()[0] != SER_STRING_TYPE_TAG
+ || array1.getByteArray()[0] != SER_STRING_TYPE_TAG
+ || array2.getByteArray()[0] != SER_STRING_TYPE_TAG
+ || array3.getByteArray()[0] != SER_STRING_TYPE_TAG) {
+ throw new AlgebricksException(funcID.getName()
+ + ": expects input type (STRING/NULL, STRING/NULL, STRING/NULL, STRING/NULL), but got ("
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array0.getByteArray()[0]) + ", "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array1.getByteArray()[0]) + ", "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array2.getByteArray()[0]) + ", "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array3.getByteArray()[0]) + ".");
}
} catch (HyracksDataException e) {
throw new AlgebricksException(e);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AbstractTripleStringStringEval.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AbstractTripleStringStringEval.java
index aabbcb0..4bd068f 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AbstractTripleStringStringEval.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AbstractTripleStringStringEval.java
@@ -76,22 +76,18 @@
eval2.evaluate(tuple);
try {
- // type-check: (string?, string, string)
-
- if (array0.getByteArray()[0] == SER_NULL_TYPE_TAG) {
- if (array1.getByteArray()[0] == SER_STRING_TYPE_TAG && array2.getByteArray()[0] == SER_STRING_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, dout);
- return;
- }
- }
-
- if (array0.getByteArray()[0] != SER_STRING_TYPE_TAG || array1.getByteArray()[0] != SER_STRING_TYPE_TAG
+ if (array0.getByteArray()[0] == SER_NULL_TYPE_TAG || array1.getByteArray()[0] == SER_NULL_TYPE_TAG
+ || array2.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+ nullSerde.serialize(ANull.NULL, dout);
+ return;
+ } else if (array0.getByteArray()[0] != SER_STRING_TYPE_TAG
+ || array1.getByteArray()[0] != SER_STRING_TYPE_TAG
|| array2.getByteArray()[0] != SER_STRING_TYPE_TAG) {
throw new AlgebricksException(funcID.getName()
- + ": expects input type (STRING/NULL, STRING, STRING), but got ("
+ + ": expects input type (STRING/NULL, STRING/NULL, STRING/NULL), but got ("
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array0.getByteArray()[0]) + ", "
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array1.getByteArray()[0]) + ", "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array2.getByteArray()[0]) + ").");
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array2.getByteArray()[0]) + ".");
}
} catch (HyracksDataException e) {
throw new AlgebricksException(e);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StringReplaceDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StringReplaceDescriptor.java
index cfaed70..4e468d5 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StringReplaceDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/StringReplaceDescriptor.java
@@ -122,8 +122,9 @@
astrReplace = (AString) stringSerde.deserialize(di);
replace = astrReplace.getStringValue();
}
- if (newPattern)
+ if (newPattern) {
pattern = Pattern.compile(strPattern);
+ }
carSeq.reset(array0, 1);
if (newPattern) {
matcher = pattern.matcher(carSeq);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java
new file mode 100644
index 0000000..45b7b32
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java
@@ -0,0 +1,126 @@
+/*
+ * 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.runtime.evaluators.functions.temporal;
+
+import java.io.DataOutput;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.ADayTimeDuration;
+import edu.uci.ics.asterix.om.base.AMutableDayTimeDuration;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+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.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class DurationFromIntervalDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+ public final static FunctionIdentifier FID = AsterixBuiltinFunctions.DURATION_FROM_INTERVAL;
+
+ // allowed input types
+ private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+ private final static byte SER_INTERVAL_TYPE_TAG = ATypeTag.INTERVAL.serialize();
+
+ public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new DurationFromIntervalDescriptor();
+ }
+
+ };
+
+ @Override
+ public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+ return new ICopyEvaluatorFactory() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+ return new ICopyEvaluator() {
+
+ private DataOutput out = output.getDataOutput();
+ private ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+ private ICopyEvaluator eval = args[0].createEvaluator(argOut);
+
+ @SuppressWarnings("unchecked")
+ private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ANULL);
+
+ @SuppressWarnings("unchecked")
+ private ISerializerDeserializer<ADayTimeDuration> dayTimeDurationSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ADAYTIMEDURATION);
+
+ private AMutableDayTimeDuration aDayTimeDuration = new AMutableDayTimeDuration(0);
+
+ @Override
+ public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+ argOut.reset();
+ eval.evaluate(tuple);
+
+ try {
+ if (argOut.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+ nullSerde.serialize(ANull.NULL, out);
+ return;
+ } else if (argOut.getByteArray()[0] != SER_INTERVAL_TYPE_TAG) {
+ throw new AlgebricksException(FID.getName()
+ + ": expects INTERVAL/NULL as the input but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut.getByteArray()[0]));
+ }
+ long chrononStart = AIntervalSerializerDeserializer.getIntervalStart(argOut.getByteArray(),
+ 1);
+ long chrononEnd = AIntervalSerializerDeserializer.getIntervalEnd(argOut.getByteArray(), 1);
+ byte intervalTypeTag = AIntervalSerializerDeserializer.getIntervalTimeType(
+ argOut.getByteArray(), 1);
+
+ if (intervalTypeTag == ATypeTag.DATE.serialize()) {
+ chrononStart *= GregorianCalendarSystem.CHRONON_OF_DAY;
+ chrononEnd *= GregorianCalendarSystem.CHRONON_OF_DAY;
+ }
+
+ aDayTimeDuration.setMilliseconds(chrononEnd - chrononStart);
+ dayTimeDurationSerde.serialize(aDayTimeDuration, out);
+
+ } catch (HyracksDataException hex) {
+ throw new AlgebricksException(hex);
+ }
+ }
+ };
+ }
+ };
+ }
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return FID;
+ }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java
new file mode 100644
index 0000000..2cf60ca
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java
@@ -0,0 +1,143 @@
+/*
+ * 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.runtime.evaluators.functions.temporal;
+
+import java.io.DataOutput;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.AInterval;
+import edu.uci.ics.asterix.om.base.AMutableInterval;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+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.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class GetOverlappingIntervalDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final byte SER_INTERVAL_TYPE_TAG = ATypeTag.INTERVAL.serialize();
+ private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new GetOverlappingIntervalDescriptor();
+ }
+ };
+
+ public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+ return new ICopyEvaluatorFactory() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+ return new ICopyEvaluator() {
+
+ private DataOutput out = output.getDataOutput();
+ private ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
+ private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
+ private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
+ private ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
+
+ private final AMutableInterval aInterval = new AMutableInterval(0, 0, (byte) -1);
+
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ANULL);
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<AInterval> intervalSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.AINTERVAL);
+
+ @Override
+ public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+ argOut0.reset();
+ eval0.evaluate(tuple);
+ argOut1.reset();
+ eval1.evaluate(tuple);
+
+ try {
+ if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
+ || argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+ nullSerde.serialize(ANull.NULL, out);
+ } else if (argOut0.getByteArray()[0] == SER_INTERVAL_TYPE_TAG
+ && argOut0.getByteArray()[0] == argOut1.getByteArray()[0]) {
+ byte type0 = AIntervalSerializerDeserializer.getIntervalTimeType(
+ argOut0.getByteArray(), 1);
+ byte type1 = AIntervalSerializerDeserializer.getIntervalTimeType(
+ argOut1.getByteArray(), 1);
+ if (type0 != type1) {
+ throw new AlgebricksException(
+ getIdentifier().getName()
+ + ": expecting two (nullable) interval values with the same internal time type but got interval of "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(type0)
+ + " and interval of "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(type1));
+ }
+
+ long start0 = AIntervalSerializerDeserializer.getIntervalStart(argOut0.getByteArray(),
+ 1);
+ long end0 = AIntervalSerializerDeserializer.getIntervalEnd(argOut0.getByteArray(), 1);
+
+ long start1 = AIntervalSerializerDeserializer.getIntervalStart(argOut1.getByteArray(),
+ 1);
+ long end1 = AIntervalSerializerDeserializer.getIntervalEnd(argOut1.getByteArray(), 1);
+
+ if (IntervalLogic.overlap(start0, end0, start1, end1)
+ || IntervalLogic.overlappedBy(start0, end0, start1, end1)
+ || IntervalLogic.covers(start0, end0, start1, end1)
+ || IntervalLogic.coveredBy(start0, end0, start1, end1)) {
+ aInterval.setValue(Math.max(start0, start1), Math.min(end0, end1), type0);
+ intervalSerde.serialize(aInterval, out);
+ } else {
+ nullSerde.serialize(ANull.NULL, out);
+ }
+ } else {
+ throw new AlgebricksException(getIdentifier().getName()
+ + ": expecting two (nullable) interval values but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0])
+ + " and "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[1]));
+ }
+ } catch (HyracksDataException hex) {
+ throw new AlgebricksException(hex);
+ }
+ }
+
+ };
+ }
+ };
+ }
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.GET_OVERLAPPING_INTERVAL;
+ }
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/IntervalLogic.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/IntervalLogic.java
index 021de2d..b746ccd 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/IntervalLogic.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/IntervalLogic.java
@@ -91,7 +91,7 @@
* @return
*/
public static <T extends Comparable<T>> boolean overlap(T s1, T e1, T s2, T e2) {
- return s1.compareTo(e2) < 0 && s2.compareTo(e1) < 0;
+ return (s2.compareTo(s1) >= 0 && s2.compareTo(e1) < 0) || (e2.compareTo(e1) <= 0 && e2.compareTo(s1) > 0);
}
/**
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java
new file mode 100644
index 0000000..e24feed
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java
@@ -0,0 +1,338 @@
+/*
+ * 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.runtime.evaluators.functions.temporal;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import edu.uci.ics.asterix.builders.OrderedListBuilder;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADateSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADayTimeDurationSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ATimeSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AYearMonthDurationSerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.AInterval;
+import edu.uci.ics.asterix.om.base.AMutableInterval;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.base.temporal.DurationArithmeticOperations;
+import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+import edu.uci.ics.asterix.om.types.AOrderedListType;
+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.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new OverlapBinsDescriptor();
+ }
+ };
+
+ @Override
+ public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+ return new ICopyEvaluatorFactory() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+ return new ICopyEvaluator() {
+
+ private final DataOutput out = output.getDataOutput();
+
+ private final ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
+ private final ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
+ private final ArrayBackedValueStorage argOut2 = new ArrayBackedValueStorage();
+
+ private final ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
+ private final ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
+ private final ICopyEvaluator eval2 = args[2].createEvaluator(argOut2);
+
+ // for output
+ private OrderedListBuilder listBuilder = new OrderedListBuilder();
+ private ArrayBackedValueStorage listStorage = new ArrayBackedValueStorage();
+ protected final AOrderedListType intListType = new AOrderedListType(BuiltinType.AINTERVAL, null);
+
+ private final AMutableInterval aInterval = new AMutableInterval(0, 0, (byte) -1);
+
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ANULL);
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<AInterval> intervalSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.AINTERVAL);
+
+ private final GregorianCalendarSystem GREG_CAL = GregorianCalendarSystem.getInstance();
+
+ @Override
+ public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+ argOut0.reset();
+ eval0.evaluate(tuple);
+
+ ATypeTag type0 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]);
+
+ long intervalStart = 0, intervalEnd = 0;
+ byte intervalTypeTag;
+
+ if (type0 == ATypeTag.INTERVAL) {
+ intervalStart = AIntervalSerializerDeserializer.getIntervalStart(argOut0.getByteArray(), 1);
+ intervalEnd = AIntervalSerializerDeserializer.getIntervalEnd(argOut0.getByteArray(), 1);
+ intervalTypeTag = AIntervalSerializerDeserializer.getIntervalTimeType(
+ argOut0.getByteArray(), 1);
+ } else if (type0 == ATypeTag.NULL) {
+ try {
+ nullSerde.serialize(ANull.NULL, out);
+ } catch (HyracksDataException e) {
+ throw new AlgebricksException(e);
+ }
+ return;
+ } else {
+ throw new AlgebricksException(getIdentifier().getName()
+ + ": the first argument should be INTERVAL/NULL but got " + type0);
+ }
+
+ // get the anchor instance time
+ argOut1.reset();
+ eval1.evaluate(tuple);
+
+ ATypeTag type1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]);
+
+ if (intervalTypeTag != type1.serialize()) {
+ if (intervalTypeTag != ATypeTag.NULL.serialize() && type1 != ATypeTag.NULL)
+ throw new AlgebricksException(getIdentifier().getName()
+ + ": expecting compatible type to " + type0 + "(" + intervalTypeTag
+ + ") for the second argument but got " + type1);
+ }
+
+ long anchorTime = 0;
+ switch (type1) {
+ case DATE:
+ anchorTime = ADateSerializerDeserializer.getChronon(argOut1.getByteArray(), 1)
+ * GregorianCalendarSystem.CHRONON_OF_DAY;
+ break;
+ case TIME:
+ anchorTime = ATimeSerializerDeserializer.getChronon(argOut1.getByteArray(), 1);
+ break;
+ case DATETIME:
+ anchorTime = ADateTimeSerializerDeserializer.getChronon(argOut1.getByteArray(), 1);
+ break;
+ case NULL:
+ try {
+ nullSerde.serialize(ANull.NULL, out);
+ } catch (HyracksDataException e) {
+ throw new AlgebricksException(e);
+ }
+ return;
+ default:
+ throw new AlgebricksException(getIdentifier().getName()
+ + ": expecting compatible type to " + type0 + "(" + intervalTypeTag
+ + ") for the second argument but got " + type1);
+ }
+
+ argOut2.reset();
+ eval2.evaluate(tuple);
+
+ ATypeTag type2 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut2.getByteArray()[0]);
+
+ int yearMonth = 0;
+ long dayTime = 0;
+ long firstBinIndex;
+ switch (type2) {
+ case YEARMONTHDURATION:
+ yearMonth = AYearMonthDurationSerializerDeserializer.getYearMonth(
+ argOut2.getByteArray(), 1);
+
+ int yearStart = GREG_CAL.getYear(anchorTime);
+ int monthStart = GREG_CAL.getMonthOfYear(anchorTime, yearStart);
+ int yearToBin = GREG_CAL.getYear(intervalStart);
+ int monthToBin = GREG_CAL.getMonthOfYear(intervalStart, yearToBin);
+
+ int totalMonths = (yearToBin - yearStart) * 12 + (monthToBin - monthStart);
+
+ firstBinIndex = totalMonths / yearMonth
+ + ((totalMonths < 0 && totalMonths % yearMonth != 0) ? -1 : 0);
+
+ if (firstBinIndex > Integer.MAX_VALUE) {
+ throw new AlgebricksException(getIdentifier().getName()
+ + ": Overflowing time value to be binned!");
+ }
+
+ if (firstBinIndex < Integer.MIN_VALUE) {
+ throw new AlgebricksException(getIdentifier().getName()
+ + ": Underflowing time value to be binned!");
+ }
+ break;
+
+ case DAYTIMEDURATION:
+ dayTime = ADayTimeDurationSerializerDeserializer.getDayTime(argOut2.getByteArray(), 1);
+
+ long totalChronon = intervalStart - anchorTime;
+
+ firstBinIndex = totalChronon / dayTime
+ + ((totalChronon < 0 && totalChronon % dayTime != 0) ? -1 : 0);
+ break;
+
+ case NULL:
+ try {
+ nullSerde.serialize(ANull.NULL, out);
+ } catch (HyracksDataException e) {
+ throw new AlgebricksException(e);
+ }
+ return;
+
+ default:
+ throw new AlgebricksException(
+ getIdentifier().getName()
+ + ": expecting YEARMONTHDURATION/DAYTIMEDURATION for the thrid argument but got "
+ + type2);
+ }
+
+ long binStartChronon, binEndChronon;
+ int binOffset;
+
+ listBuilder.reset(intListType);
+
+ try {
+ if (intervalTypeTag == ATypeTag.DATE.serialize()) {
+
+ binOffset = 0;
+
+ do {
+ binStartChronon = DurationArithmeticOperations.addDuration(anchorTime, yearMonth
+ * (int) (firstBinIndex + binOffset), dayTime * (firstBinIndex + binOffset),
+ false);
+ binEndChronon = DurationArithmeticOperations.addDuration(anchorTime, yearMonth
+ * ((int) (firstBinIndex + binOffset) + 1), dayTime
+ * ((firstBinIndex + binOffset) + 1), false);
+ binStartChronon = binStartChronon
+ / GregorianCalendarSystem.CHRONON_OF_DAY
+ + ((binStartChronon < 0 && binStartChronon
+ % GregorianCalendarSystem.CHRONON_OF_DAY != 0) ? -1 : 0);
+ binEndChronon = binEndChronon
+ / GregorianCalendarSystem.CHRONON_OF_DAY
+ + ((binEndChronon < 0 && binEndChronon
+ % GregorianCalendarSystem.CHRONON_OF_DAY != 0) ? -1 : 0);
+ aInterval.setValue(binStartChronon, binEndChronon, intervalTypeTag);
+ listStorage.reset();
+ intervalSerde.serialize(aInterval, listStorage.getDataOutput());
+ listBuilder.addItem(listStorage);
+ binOffset++;
+ } while (binEndChronon < intervalEnd);
+
+ } else if (intervalTypeTag == ATypeTag.TIME.serialize()) {
+ if (yearMonth != 0) {
+ throw new AlgebricksException(getIdentifier().getName()
+ + ": cannot create year-month bin for a time value");
+ }
+
+ binOffset = 0;
+
+ binStartChronon = DurationArithmeticOperations.addDuration(anchorTime, yearMonth
+ * (int) (firstBinIndex + binOffset), dayTime * (firstBinIndex + binOffset),
+ true);
+ binEndChronon = DurationArithmeticOperations.addDuration(anchorTime, yearMonth
+ * ((int) (firstBinIndex + binOffset) + 1), dayTime
+ * ((firstBinIndex + binOffset) + 1), true);
+
+ if (binStartChronon < 0 || binStartChronon >= GregorianCalendarSystem.CHRONON_OF_DAY) {
+ // avoid the case where a time bin is before 00:00:00 or no early than 24:00:00
+ throw new AlgebricksException(
+ getIdentifier().getName()
+ + ": reaches a bin with the end earlier than the start; probably the window is beyond the time scope. Maybe use DATETIME?");
+ }
+
+ while (!((binStartChronon < intervalStart && binEndChronon <= intervalStart) || (binStartChronon >= intervalEnd && binEndChronon > intervalEnd))) {
+
+ aInterval.setValue(binStartChronon, binEndChronon, intervalTypeTag);
+ listStorage.reset();
+ intervalSerde.serialize(aInterval, listStorage.getDataOutput());
+ listBuilder.addItem(listStorage);
+ binOffset++;
+ binStartChronon = DurationArithmeticOperations.addDuration(anchorTime, yearMonth
+ * (int) (firstBinIndex + binOffset), dayTime * (firstBinIndex + binOffset),
+ true);
+ binEndChronon = DurationArithmeticOperations.addDuration(anchorTime, yearMonth
+ * ((int) (firstBinIndex + binOffset) + 1), dayTime
+ * ((firstBinIndex + binOffset) + 1), true);
+
+ if (binStartChronon == GregorianCalendarSystem.CHRONON_OF_DAY) {
+ break;
+ }
+
+ if (binEndChronon < binStartChronon) {
+ throw new AlgebricksException(
+ getIdentifier().getName()
+ + ": reaches a bin with the end earlier than the start; probably the window is beyond the time scope. Maybe use DATETIME?");
+ }
+ }
+ } else if (intervalTypeTag == ATypeTag.DATETIME.serialize()) {
+ binOffset = 0;
+ do {
+ binStartChronon = DurationArithmeticOperations.addDuration(anchorTime, yearMonth
+ * (int) (firstBinIndex + binOffset), dayTime * (firstBinIndex + binOffset),
+ false);
+ binEndChronon = DurationArithmeticOperations.addDuration(anchorTime, yearMonth
+ * ((int) (firstBinIndex + binOffset) + 1), dayTime
+ * ((firstBinIndex + binOffset) + 1), false);
+ aInterval.setValue(binStartChronon, binEndChronon, intervalTypeTag);
+ listStorage.reset();
+ intervalSerde.serialize(aInterval, listStorage.getDataOutput());
+ listBuilder.addItem(listStorage);
+ binOffset++;
+ } while (binEndChronon < intervalEnd);
+ } else {
+ throw new AlgebricksException(getIdentifier().getName()
+ + ": the first argument should be DATE/TIME/DATETIME/NULL but got " + type0);
+ }
+
+ listBuilder.write(out, true);
+ } catch (IOException e1) {
+ throw new AlgebricksException(e1.getMessage());
+ }
+
+ }
+ };
+ }
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+ */
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.OVERLAP_BINS;
+ }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/OverlapDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/OverlapDescriptor.java
index 927cea1..bc9c980 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/OverlapDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/OverlapDescriptor.java
@@ -22,7 +22,7 @@
public class OverlapDescriptor extends AbstractIntervalLogicFuncDescriptor {
private final static long serialVersionUID = 1L;
- public final static FunctionIdentifier FID = AsterixBuiltinFunctions.OVERLAP;
+ public final static FunctionIdentifier FID = AsterixBuiltinFunctions.INTERVAL_OVERLAPPING;
public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/formats/NonTaggedDataFormat.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/formats/NonTaggedDataFormat.java
index 8fda408..3871aef 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/formats/NonTaggedDataFormat.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/formats/NonTaggedDataFormat.java
@@ -120,7 +120,13 @@
import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalDayAccessor;
import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalHourAccessor;
import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalIntervalEndAccessor;
+import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalIntervalEndDateAccessor;
+import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalIntervalEndDatetimeAccessor;
+import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalIntervalEndTimeAccessor;
import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalIntervalStartAccessor;
+import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalIntervalStartDateAccessor;
+import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalIntervalStartDatetimeAccessor;
+import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalIntervalStartTimeAccessor;
import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalMillisecondAccessor;
import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalMinuteAccessor;
import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalMonthAccessor;
@@ -271,9 +277,11 @@
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.DayOfWeekDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.DayTimeDurationComparatorDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.DurationEqualDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.DurationFromIntervalDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.DurationFromMillisecondsDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.DurationFromMonthsDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.GetDayTimeDurationDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.GetOverlappingIntervalDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.GetYearMonthDurationDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalAfterDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalBeforeDescriptor;
@@ -290,6 +298,7 @@
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalStartsDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.MillisecondsFromDayTimeDurationDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.MonthsFromYearMonthDurationDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.OverlapBinsDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.OverlapDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.ParseDateDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.ParseDateTimeDescriptor;
@@ -603,6 +612,12 @@
temp.add(TemporalMillisecondAccessor.FACTORY);
temp.add(TemporalIntervalStartAccessor.FACTORY);
temp.add(TemporalIntervalEndAccessor.FACTORY);
+ temp.add(TemporalIntervalStartDateAccessor.FACTORY);
+ temp.add(TemporalIntervalEndDateAccessor.FACTORY);
+ temp.add(TemporalIntervalStartTimeAccessor.FACTORY);
+ temp.add(TemporalIntervalEndTimeAccessor.FACTORY);
+ temp.add(TemporalIntervalStartDatetimeAccessor.FACTORY);
+ temp.add(TemporalIntervalEndDatetimeAccessor.FACTORY);
// Temporal functions
temp.add(DateFromUnixTimeInDaysDescriptor.FACTORY);
@@ -644,6 +659,7 @@
temp.add(GetYearMonthDurationDescriptor.FACTORY);
temp.add(GetDayTimeDurationDescriptor.FACTORY);
temp.add(IntervalBinDescriptor.FACTORY);
+ temp.add(OverlapBinsDescriptor.FACTORY);
temp.add(DayOfWeekDescriptor.FACTORY);
temp.add(ParseDateDescriptor.FACTORY);
temp.add(ParseTimeDescriptor.FACTORY);
@@ -651,6 +667,8 @@
temp.add(PrintDateDescriptor.FACTORY);
temp.add(PrintTimeDescriptor.FACTORY);
temp.add(PrintDateTimeDescriptor.FACTORY);
+ temp.add(GetOverlappingIntervalDescriptor.FACTORY);
+ temp.add(DurationFromIntervalDescriptor.FACTORY);
// Interval constructor
temp.add(AIntervalFromDateConstructorDescriptor.FACTORY);
@@ -1056,12 +1074,13 @@
@Override
public ITupleParserFactory createTupleParser(ARecordType recType, IParseFileSplitsDecl decl) {
- return createTupleParser(recType, decl.isDelimitedFileFormat(), decl.getDelimChar(), decl.getQuote(), decl.getHasHeader());
+ return createTupleParser(recType, decl.isDelimitedFileFormat(), decl.getDelimChar(), decl.getQuote(),
+ decl.getHasHeader());
}
@Override
public ITupleParserFactory createTupleParser(ARecordType recType, boolean delimitedFormat, char delimiter,
- char quote, boolean hasHeader) {
+ char quote, boolean hasHeader) {
if (delimitedFormat) {
int n = recType.getFieldTypes().length;
IValueParserFactory[] fieldParserFactories = new IValueParserFactory[n];