checkpoint 513#1: fixed temporal arthmetic operations to use symobl-based operations instead of functions.
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.1.ddl.aql
index c57f9a0..04c1e6f 100644
--- a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.1.ddl.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.1.ddl.aql
@@ -6,9 +6,9 @@
*
*/
-drop dataverse tempdb if exists;
-create dataverse tempdb;
-use dataverse tempdb;
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
create type TestType as open{
id:int32,
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.2.update.aql
index 9a2a29b..2e0bb6c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.2.update.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.2.update.aql
@@ -6,7 +6,7 @@
*
*/
-use dataverse tempdb;
+use dataverse test;
insert into dataset t1({"id":5,"name":"Smith"});
insert into dataset t1({"id":12,"name":"Roger"});
diff --git a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.3.query.aql
index 20e06aa..1fa706c 100644
--- a/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/aggregate/issue531_string_min_max/issue531_string_min_max.3.query.aql
@@ -6,7 +6,7 @@
*
*/
-use dataverse tempdb;
+use dataverse test;
{"min": min(for $l in dataset t1
return $l.name), "max": max(for $l in dataset t1
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/calendar_duration/calendar_duration.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/calendar_duration/calendar_duration.3.query.aql
index 016f3b3..b1c3a20 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temporal/calendar_duration/calendar_duration.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/calendar_duration/calendar_duration.3.query.aql
@@ -8,36 +8,36 @@
let $dr3 := duration("P1Y90M")
let $dr4 := duration("-P3Y89M4089DT47382.983S")
let $cdr1 := calendar-duration-from-datetime($t1, $dr1)
-let $dt1 := add-datetime-duration($t1, $dr1)
-let $dtt1 := add-datetime-duration($t1, $cdr1)
+let $dt1 := $t1 + $dr1
+let $dtt1 := $t1 + $cdr1
let $c1 := $dt1 = $dtt1
let $cdr2 := calendar-duration-from-datetime($t1, $dr2)
-let $dt2 := add-datetime-duration($t1, $dr2)
-let $dtt2 := add-datetime-duration($t1, $cdr2)
+let $dt2 := $t1 + $dr2
+let $dtt2 := $t1 + $cdr2
let $c2 := $dt2 = $dtt2
let $cdr3 := calendar-duration-from-datetime($t1, $dr3)
-let $dt3 := add-datetime-duration($t1, $dr3)
-let $dtt3 := add-datetime-duration($t1, $cdr3)
+let $dt3 := $t1 + $dr3
+let $dtt3 := $t1 + $cdr3
let $c3 := $dt3 = $dtt3
let $cdr4 := calendar-duration-from-datetime($t1, $dr4)
-let $dt4 := add-datetime-duration($t1, $dr4)
-let $dtt4 := add-datetime-duration($t1, $cdr4)
+let $dt4 := $t1 + $dr4
+let $dtt4 := $t1 + $cdr4
let $c4 := $dt4 = $dtt4
let $cdr5 := calendar-duration-from-date($t2, $dr1)
-let $dt5 := add-date-duration($t2, $dr1)
-let $dtt5 := add-date-duration($t2, $cdr5)
+let $dt5 := $t2 + $dr1
+let $dtt5 := $t2 + $cdr5
let $c5 := $dt5 = $dtt5
let $cdr6 := calendar-duration-from-date($t2, $dr2)
-let $dt6 := add-date-duration($t2, $dr2)
-let $dtt6 := add-date-duration($t2, $cdr6)
+let $dt6 := $t2 + $dr2
+let $dtt6 := $t2 + $cdr6
let $c6 := $dt6 = $dtt6
let $cdr7 := calendar-duration-from-date($t2, $dr3)
-let $dt7 := add-date-duration($t2, $dr3)
-let $dtt7 := add-date-duration($t2, $cdr7)
+let $dt7 := $t2 + $dr3
+let $dtt7 := $t2 + $cdr7
let $c7 := $dt7 = $dtt7
let $cdr8 := calendar-duration-from-date($t2, $dr4)
-let $dt8 := add-date-duration($t2, $dr4)
-let $dtt8 := add-date-duration($t2, $cdr8)
+let $dt8 := $t2 + $dr4
+let $dtt8 := $t2 + $cdr8
let $c8 := $dt8 = $dtt8
return { "cduration1":$cdr1, "c1":$c1, "cduration2":$cdr2, "c2":$c2, "cduration3":$cdr3, "c3":$c3, "cduration4":$cdr4, "c4":$c4, "cduration5":$cdr5, "c5":$c5, "cduration6":$cdr6, "c6":$c6, "cduration7":$cdr7, "c7":$c7, "cduration8":$cdr8, "c8":$c8, "cduration-null-1": calendar-duration-from-datetime(null, $dr1), "cduration-null-2": calendar-duration-from-datetime($t1, null), "cduration-null-3": calendar-duration-from-date(null, $dr1), "cduration-null-4": calendar-duration-from-date($t2, null) }
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/date_functions/date_functions.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/date_functions/date_functions.3.query.aql
index 3927f72..e540817 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temporal/date_functions/date_functions.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/date_functions/date_functions.3.query.aql
@@ -9,16 +9,16 @@
let $dt2 := datetime("2012-10-11T02:30:23+03:00")
let $d3 := get-date-from-datetime($dt2)
let $dr1 := duration("-P2Y1M90DT30H")
-let $d4 := add-date-duration($d1, $dr1)
-let $null3 := add-date-duration(null, $dr1)
-let $null4 := add-date-duration($d1, null)
-let $c1 := $d1 = add-date-duration($d4, subtract-date($d1, $d4))
+let $d4 := $d1 + $dr1
+let $null3 := null + $dr1
+let $null4 := $d1 + null
+let $c1 := ($d1 = ($d4 + ($d1 - $d4)))
let $dr2 := duration("P300Y900MT360000M")
-let $d5 := add-date-duration($d2, $dr2)
-let $c2 := $d2 = add-date-duration($d5, subtract-date($d2, $d5))
-let $dr3 := subtract-date($d5, $d2)
-let $dr4 := subtract-date($d4, $d1)
-let $null5 := subtract-date(null, $d2)
-let $null6 := subtract-date($d5, null)
+let $d5 := $d2 + $dr2
+let $c2 := ($d2 = ($d5 + ($d2 - $d5)))
+let $dr3 := $d5 - $d2
+let $dr4 := $d4 - $d1
+let $null5 := null - $d2
+let $null6 := $d5 - null
return { "date1": $d1, "date2": $d2, "date3": $d3, "date4": $d4, "date5": $d5, "duration1": $dr3, "duration2": $dr4, "c1": $c1, "c2": $c2, "null1": $null1, "null2": $null2, "null3": $null3, "null4": $null4, "null5": $null5, "null6": $null6 }
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/datetime_functions/datetime_functions.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/datetime_functions/datetime_functions.3.query.aql
index 3d24549..fe0c099 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temporal/datetime_functions/datetime_functions.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/datetime_functions/datetime_functions.3.query.aql
@@ -8,12 +8,12 @@
let $dt2 := datetime-from-date-time($d1, $t1)
let $null2 := datetime-from-date-time(null, $t1)
let $null3 := datetime-from-date-time($d1, null)
-let $dr1 := subtract-datetime($dt2, $dt1)
-let $null4 := subtract-datetime(null, $dt1)
-let $null5 := subtract-datetime($dt2, null)
-let $dt3 := add-datetime-duration($dt1, $dr1)
-let $null6 := add-datetime-duration(null, $dr1)
-let $null7 := add-datetime-duration($dt1, null)
-let $c1 := $dt1 = add-datetime-duration($dt3, subtract-datetime($dt1, $dt3))
+let $dr1 := $dt2 - $dt1
+let $null4 := null - $dt1
+let $null5 := $dt2 - null
+let $dt3 := $dt1 + $dr1
+let $null6 := null + $dr1
+let $null7 := $dt1 + null
+let $c1 := $dt1 = ($dt1 - $dt3) + $dt3
return { "datetime1" : $dt1, "datetime2" : $dt2, "datetime3" : $dt3, "duration1" : $dr1, "c1" : $c1, "null1" : $null1, "null2" : $null2, "null3" : $null3, "null4" : $null4, "null5" : $null5, "null6" : $null6, "null7" : $null7 }
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/time_functions/time_functions.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/time_functions/time_functions.3.query.aql
index d2befcc..09e1aa9 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temporal/time_functions/time_functions.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/time_functions/time_functions.3.query.aql
@@ -8,18 +8,18 @@
let $null2 := get-time-from-datetime(null)
let $dt2 := datetime("2012-10-11T02:30:23+03:00")
let $t3 := get-time-from-datetime($dt2)
-let $dr1 := duration("-PT30H")
-let $t4 := add-time-duration($t1, $dr1)
-let $null3 := add-time-duration(null, $dr1)
-let $null4 := add-time-duration($t1, null)
-let $c1 := $t1 = add-time-duration($t4, subtract-time($t1, $t4))
-let $dr2 := duration("PT36M")
-let $t5 := add-time-duration($t2, $dr2)
-let $c2 := $t2 = add-time-duration($t5, subtract-time($t2, $t5))
-let $dr3 := subtract-time($t5, $t2)
-let $dr4 := subtract-time($t4, $t1)
-let $null5 := subtract-time(null, $t1)
-let $null6 := subtract-time($t4, null)
+let $dr1 := day-time-duration("-PT30H")
+let $t4 := $t1 + $dr1
+let $null3 := null + $dr1
+let $null4 := $t1 + null
+let $c1 := $t1 = ($t1 - $t4) + $t4
+let $dr2 := day-time-duration("PT36M")
+let $t5 := $t2 + $dr2
+let $c2 := $t2 = $t5 + ($t2 - $t5)
+let $dr3 := $t5 - $t2
+let $dr4 := $t4 - $t1
+let $null5 := null - $t1
+let $null6 := $t4 - null
let $ct := current-time()
let $cd := current-date()
let $cdt := current-datetime()
diff --git a/asterix-installer/ittest/asterix-lifecycle_backupRestore.adm b/asterix-installer/ittest/asterix-lifecycle_backupRestore.adm
index 8605e82..8498591 100644
--- a/asterix-installer/ittest/asterix-lifecycle_backupRestore.adm
+++ b/asterix-installer/ittest/asterix-lifecycle_backupRestore.adm
@@ -1 +1 @@
-{ "DataverseName": "backupDataverse", "DataFormat": "edu.uci.ics.asterix.runtime.formats.NonTaggedDataFormat", "Timestamp": "Sun Jun 23 23:30:46 PDT 2013", "PendingOp": 0 }
+{ "DataverseName": "backupDataverse", "DataFormat": "edu.uci.ics.asterix.runtime.formats.NonTaggedDataFormat", "Timestamp": "Sun Jun 30 12:51:57 PDT 2013", "PendingOp": 0 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AObjectSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AObjectSerializerDeserializer.java
index 486f271..379f99f 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AObjectSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AObjectSerializerDeserializer.java
@@ -101,7 +101,7 @@
return ADurationSerializerDeserializer.INSTANCE.deserialize(in);
}
case YEARMONTHDURATION: {
- return AYearMonthDurationerializerDeserializer.INSTANCE.deserialize(in);
+ return AYearMonthDurationSerializerDeserializer.INSTANCE.deserialize(in);
}
case DAYTIMEDURATION: {
return ADayTimeDurationSerializerDeserializer.INSTNACE.deserialize(in);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AYearMonthDurationerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AYearMonthDurationSerializerDeserializer.java
similarity index 92%
rename from asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AYearMonthDurationerializerDeserializer.java
rename to asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AYearMonthDurationSerializerDeserializer.java
index 79bf3c0..e0e1259 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AYearMonthDurationerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AYearMonthDurationSerializerDeserializer.java
@@ -27,11 +27,11 @@
import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
-public class AYearMonthDurationerializerDeserializer implements ISerializerDeserializer<AYearMonthDuration> {
+public class AYearMonthDurationSerializerDeserializer implements ISerializerDeserializer<AYearMonthDuration> {
private static final long serialVersionUID = 1L;
- public static final AYearMonthDurationerializerDeserializer INSTANCE = new AYearMonthDurationerializerDeserializer();
+ public static final AYearMonthDurationSerializerDeserializer INSTANCE = new AYearMonthDurationSerializerDeserializer();
@SuppressWarnings("unchecked")
private static final ISerializerDeserializer<AYearMonthDuration> yearMonthDurationSerde = AqlSerializerDeserializerProvider.INSTANCE
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 ff1a14c..cfc1004 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
@@ -44,7 +44,7 @@
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AStringSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ATimeSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AUnorderedListSerializerDeserializer;
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AYearMonthDurationerializerDeserializer;
+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.IAObject;
import edu.uci.ics.asterix.om.types.AOrderedListType;
@@ -129,7 +129,7 @@
return ADurationSerializerDeserializer.INSTANCE;
}
case YEARMONTHDURATION: {
- return AYearMonthDurationerializerDeserializer.INSTANCE;
+ return AYearMonthDurationSerializerDeserializer.INSTANCE;
}
case DAYTIMEDURATION: {
return ADayTimeDurationSerializerDeserializer.INSTNACE;
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 e9271e5..193592d 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
@@ -26,9 +26,7 @@
* <a
* href="http://www.w3.org/TR/xmlschema-2/#adding-durations-to-dateTimes">"XML: adding durations to dateTimes"</a>.
* <p/>
- * The basic algorithm is like this: duration is applied to the time point as two separated fields: year-month field
- * and day-time field. Year-month field is applied firstly by reserving the correct day within the month's range
- * (for example add 1M to 03-31 will return 04-30). Then day-time field is applied.
+ * The basic algorithm is like this: duration is applied to the time point as two separated fields: year-month field and day-time field. Year-month field is applied firstly by reserving the correct day within the month's range (for example add 1M to 03-31 will return 04-30). Then day-time field is applied.
* <p/>
*
* @param pointChronon
@@ -36,7 +34,16 @@
* @param dayTimeDuration
* @return
*/
- public static long addDuration(long pointChronon, int yearMonthDuration, long dayTimeDuration) {
+ 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;
+ }
+
+ return rtnChronon;
+ }
int year = calSystem.getYear(pointChronon);
int month = calSystem.getMonthOfYear(pointChronon, year);
@@ -75,13 +82,4 @@
return calSystem.getChronon(year, month, day, hour, min, sec, ms, 0) + dayTimeDuration;
}
- public static int addDuration(int pointChronon, long dayTimeDuration) {
- int rtnChronon = (int) ((pointChronon + dayTimeDuration) % GregorianCalendarSystem.CHRONON_OF_DAY);
- if (rtnChronon < 0) {
- 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 24e64fa..1754e2e 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
@@ -524,26 +524,14 @@
FunctionConstants.ASTERIX_NS, "date-from-unix-time-in-days", 1);
public static final FunctionIdentifier DATE_FROM_DATETIME = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
"get-date-from-datetime", 1);
- public final static FunctionIdentifier ADD_DATE_DURATION = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
- "add-date-duration", 2);
- public final static FunctionIdentifier SUBTRACT_DATE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
- "subtract-date", 2);
public final static FunctionIdentifier TIME_FROM_UNIX_TIME_IN_MS = new FunctionIdentifier(
FunctionConstants.ASTERIX_NS, "time-from-unix-time-in-ms", 1);
public final static FunctionIdentifier TIME_FROM_DATETIME = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
"get-time-from-datetime", 1);
- public final static FunctionIdentifier SUBTRACT_TIME = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
- "subtract-time", 2);
- public final static FunctionIdentifier ADD_TIME_DURATION = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
- "add-time-duration", 2);
public final static FunctionIdentifier DATETIME_FROM_UNIX_TIME_IN_MS = new FunctionIdentifier(
FunctionConstants.ASTERIX_NS, "datetime-from-unix-time-in-ms", 1);
public final static FunctionIdentifier DATETIME_FROM_DATE_TIME = new FunctionIdentifier(
FunctionConstants.ASTERIX_NS, "datetime-from-date-time", 2);
- public final static FunctionIdentifier SUBTRACT_DATETIME = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
- "subtract-datetime", 2);
- public final static FunctionIdentifier ADD_DATETIME_DURATION = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
- "add-datetime-duration", 2);
public final static FunctionIdentifier CALENDAR_DURATION_FROM_DATETIME = new FunctionIdentifier(
FunctionConstants.ASTERIX_NS, "calendar-duration-from-datetime", 2);
public final static FunctionIdentifier CALENDAR_DURATION_FROM_DATE = new FunctionIdentifier(
@@ -832,16 +820,10 @@
// temporal functions
addFunction(DATE_FROM_UNIX_TIME_IN_DAYS, OptionalADateTypeComputer.INSTANCE);
addFunction(DATE_FROM_DATETIME, OptionalADateTypeComputer.INSTANCE);
- addFunction(ADD_DATE_DURATION, OptionalADateTypeComputer.INSTANCE);
- addFunction(SUBTRACT_DATE, OptionalADurationTypeComputer.INSTANCE);
addFunction(TIME_FROM_UNIX_TIME_IN_MS, OptionalATimeTypeComputer.INSTANCE);
addFunction(TIME_FROM_DATETIME, OptionalATimeTypeComputer.INSTANCE);
- addFunction(SUBTRACT_TIME, OptionalADurationTypeComputer.INSTANCE);
- addFunction(ADD_TIME_DURATION, OptionalATimeTypeComputer.INSTANCE);
addFunction(DATETIME_FROM_DATE_TIME, OptionalADateTimeTypeComputer.INSTANCE);
addFunction(DATETIME_FROM_UNIX_TIME_IN_MS, OptionalADateTimeTypeComputer.INSTANCE);
- addFunction(SUBTRACT_DATETIME, OptionalADurationTypeComputer.INSTANCE);
- addFunction(ADD_DATETIME_DURATION, OptionalADateTimeTypeComputer.INSTANCE);
addFunction(CALENDAR_DURATION_FROM_DATETIME, OptionalADurationTypeComputer.INSTANCE);
addFunction(CALENDAR_DURATION_FROM_DATE, OptionalADurationTypeComputer.INSTANCE);
addFunction(ADJUST_DATETIME_FOR_TIMEZONE, OptionalAStringTypeComputer.INSTANCE);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedNumericAddSubMulDivTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedNumericAddSubMulDivTypeComputer.java
index 6c46f3a..154ce65 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedNumericAddSubMulDivTypeComputer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/NonTaggedNumericAddSubMulDivTypeComputer.java
@@ -231,6 +231,111 @@
}
}
}
+ case DATE: {
+ switch (tag2) {
+ case DATE:
+ unionList.add(BuiltinType.ADURATION);
+ break;
+ case YEARMONTHDURATION:
+ case DAYTIMEDURATION:
+ case DURATION:
+ unionList.add(BuiltinType.ADATE);
+ break;
+ default: {
+ throw new NotImplementedException(errMsg + tag2);
+ }
+ }
+ break;
+ }
+ case TIME: {
+ switch (tag2) {
+ case TIME:
+ unionList.add(BuiltinType.ADURATION);
+ break;
+ case YEARMONTHDURATION:
+ case DAYTIMEDURATION:
+ case DURATION:
+ unionList.add(BuiltinType.ATIME);
+ break;
+ default: {
+ throw new NotImplementedException(errMsg + tag2);
+ }
+ }
+ break;
+ }
+ case DATETIME: {
+ switch (tag2) {
+ case DATETIME:
+ unionList.add(BuiltinType.ADURATION);
+ break;
+ case YEARMONTHDURATION:
+ case DAYTIMEDURATION:
+ case DURATION:
+ unionList.add(BuiltinType.ADATETIME);
+ break;
+ default: {
+ throw new NotImplementedException(errMsg + tag2);
+ }
+ }
+ break;
+ }
+ case DURATION: {
+ switch(tag2){
+ case DATE:
+ unionList.add(BuiltinType.ADATE);
+ break;
+ case TIME:
+ unionList.add(BuiltinType.ATIME);
+ break;
+ case DATETIME:
+ unionList.add(BuiltinType.ADATETIME);
+ break;
+ default: {
+ throw new NotImplementedException(errMsg + tag2);
+ }
+ }
+ break;
+ }
+ case YEARMONTHDURATION: {
+ switch(tag2){
+ 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;
+ default: {
+ throw new NotImplementedException(errMsg + tag2);
+ }
+ }
+ break;
+ }
+ case DAYTIMEDURATION: {
+ switch(tag2){
+ case DATE:
+ unionList.add(BuiltinType.ADATE);
+ break;
+ case TIME:
+ unionList.add(BuiltinType.ATIME);
+ break;
+ case DATETIME:
+ unionList.add(BuiltinType.ADATETIME);
+ break;
+ case DAYTIMEDURATION:
+ unionList.add(BuiltinType.ADAYTIMEDURATION);
+ break;
+ default: {
+ throw new NotImplementedException(errMsg + tag2);
+ }
+ }
+ break;
+ }
default: {
throw new NotImplementedException(errMsg + tag1);
}
diff --git a/asterix-runtime/pom.xml b/asterix-runtime/pom.xml
index 4a3ece9..3d76f92 100644
--- a/asterix-runtime/pom.xml
+++ b/asterix-runtime/pom.xml
@@ -90,7 +90,7 @@
lexer-generator-maven-plugin
</artifactId>
<versionRange>
- [0.1,)
+ [0.0,0)
</versionRange>
<goals>
<goal>generate-lexer</goal>
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 eb33cc4..9b17c90 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
@@ -122,7 +122,7 @@
if (argOut1.getByteArray()[0] == SER_DURATION_TYPE_TAG) {
intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
ADurationSerializerDeserializer.getYearMonth(argOut1.getByteArray(), 1),
- ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1));
+ ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1), false);
} else if (argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
// duration
int stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
@@ -131,7 +131,7 @@
ADurationParserFactory.parseDuration(argOut1.getByteArray(), 3, stringLength,
aDuration, ADurationParseOption.All);
intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
- aDuration.getMonths(), aDuration.getMilliseconds());
+ aDuration.getMonths(), aDuration.getMilliseconds(), false);
} else {
throw new AlgebricksException(FID.getName()
+ ": expects NULL/STRING/DURATION for the second argument, but got "
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 f7b4cdd..ce4681a 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
@@ -134,7 +134,7 @@
if (argOut1.getByteArray()[0] == SER_DURATION_TYPE_TAG) {
intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
ADurationSerializerDeserializer.getYearMonth(argOut1.getByteArray(), 1),
- ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1));
+ ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1), false);
} else if (argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
// duration
@@ -145,7 +145,7 @@
aDuration, ADurationParseOption.All);
intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
- aDuration.getMonths(), aDuration.getMilliseconds());
+ aDuration.getMonths(), aDuration.getMilliseconds(), false);
} else {
throw new AlgebricksException(FID.getName()
+ ": expects NULL/STRING/DURATION for the second argument but got "
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 3f8e5a8..d4168e1 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
@@ -130,7 +130,7 @@
}
intervalEnd = DurationArithmeticOperations.addDuration(intervalStart, 0,
- ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1));
+ ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1), false);
} else if (argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
// duration
@@ -147,7 +147,7 @@
}
intervalEnd = DurationArithmeticOperations.addDuration(intervalStart, 0,
- aDuration.getMilliseconds());
+ aDuration.getMilliseconds(), false);
} else {
throw new AlgebricksException("Wrong format for interval constructor from dates.");
}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java
index 379b934..84b9a32 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java
@@ -16,20 +16,31 @@
import java.io.DataOutput;
+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.ADoubleSerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
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.AInt8SerializerDeserializer;
+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.AMutableDate;
+import edu.uci.ics.asterix.om.base.AMutableDateTime;
import edu.uci.ics.asterix.om.base.AMutableDouble;
+import edu.uci.ics.asterix.om.base.AMutableDuration;
import edu.uci.ics.asterix.om.base.AMutableFloat;
import edu.uci.ics.asterix.om.base.AMutableInt16;
import edu.uci.ics.asterix.om.base.AMutableInt32;
import edu.uci.ics.asterix.om.base.AMutableInt64;
import edu.uci.ics.asterix.om.base.AMutableInt8;
+import edu.uci.ics.asterix.om.base.AMutableTime;
import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
import edu.uci.ics.asterix.om.types.ATypeTag;
import edu.uci.ics.asterix.om.types.BuiltinType;
import edu.uci.ics.asterix.om.types.EnumDeserializer;
@@ -51,6 +62,29 @@
abstract protected double evaluateDouble(double lhs, double rhs) throws HyracksDataException;
+ /**
+ * abstract method for arithmetic operation between a time instance (date/time/datetime)
+ * and a duration (duration/year-month-duration/day-time-duration)
+ *
+ * @param chronon
+ * @param yearMonth
+ * @param dayTime
+ * @return
+ * @throws HyracksDataException
+ */
+ abstract protected long evaluateTimeDurationArithmetic(long chronon, int yearMonth, long dayTime, boolean isTimeOnly)
+ throws HyracksDataException;
+
+ /**
+ * abstract method for arithmetic operation between two time instances (date/time/datetime)
+ *
+ * @param chronon0
+ * @param chronon1
+ * @return
+ * @throws HyracksDataException
+ */
+ abstract protected long evaluateTimeInstanceArithmetic(long chronon0, long chronon1) throws HyracksDataException;
+
@Override
public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
return new ICopyEvaluatorFactory() {
@@ -62,9 +96,10 @@
return new ICopyEvaluator() {
private DataOutput out = output.getDataOutput();
// one temp. buffer re-used by both children
- private ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
- private ICopyEvaluator evalLeft = args[0].createEvaluator(argOut);
- private ICopyEvaluator evalRight = args[1].createEvaluator(argOut);
+ private ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
+ private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
+ private ICopyEvaluator evalLeft = args[0].createEvaluator(argOut0);
+ private ICopyEvaluator evalRight = args[1].createEvaluator(argOut1);
private double[] operandsFloating = new double[args.length];
private long[] operandsInteger = new long[args.length];
private int resultType;
@@ -81,6 +116,12 @@
protected AMutableInt32 aInt32 = new AMutableInt32(0);
protected AMutableInt16 aInt16 = new AMutableInt16((short) 0);
protected AMutableInt8 aInt8 = new AMutableInt8((byte) 0);
+
+ protected AMutableDuration aDuration = new AMutableDuration(0, 0);
+ protected AMutableDate aDate = new AMutableDate(0);
+ protected AMutableTime aTime = new AMutableTime(0);
+ protected AMutableDateTime aDatetime = new AMutableDateTime(0);
+
private ATypeTag typeTag;
@SuppressWarnings("rawtypes")
private ISerializerDeserializer serde;
@@ -93,11 +134,16 @@
resultType = 0;
int currentType = 0;
for (int i = 0; i < args.length; i++) {
- argOut.reset();
- if (i == 0)
+ ArrayBackedValueStorage argOut;
+ if (i == 0) {
+ argOut0.reset();
evalLeft.evaluate(tuple);
- else
+ argOut = argOut0;
+ } else {
+ argOut1.reset();
evalRight.evaluate(tuple);
+ argOut = argOut1;
+ }
typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut.getByteArray()[0]);
switch (typeTag) {
case INT8: {
@@ -144,6 +190,14 @@
argOut.getByteArray(), 1);
break;
}
+ case DATE:
+ case TIME:
+ case DATETIME:
+ case DURATION:
+ case YEARMONTHDURATION:
+ case DAYTIMEDURATION:
+ evaluateTemporalArthmeticOperation(typeTag, tuple);
+ return;
case NULL: {
serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
@@ -237,9 +291,236 @@
throw new AlgebricksException(hde);
}
}
+
+ @SuppressWarnings("unchecked")
+ private void evaluateTemporalArthmeticOperation(ATypeTag leftType, IFrameTupleReference tuple)
+ throws HyracksDataException, AlgebricksException {
+ argOut1.reset();
+ evalRight.evaluate(tuple);
+ ATypeTag rightType = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argOut1.getByteArray()[0]);
+
+ if (leftType == ATypeTag.NULL || rightType == ATypeTag.NULL) {
+ serde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ANULL);
+ serde.serialize(ANull.NULL, out);
+ return;
+ }
+
+ if (rightType == leftType) {
+
+ serde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ADURATION);
+
+ long leftChronon = 0, rightChronon = 0, dayTime = 0;
+
+ int yearMonth = 0;
+
+ switch (leftType) {
+ case DATE:
+ leftChronon = ADateSerializerDeserializer.getChronon(argOut0.getByteArray(), 1)
+ * GregorianCalendarSystem.CHRONON_OF_DAY;
+ rightChronon = ADateSerializerDeserializer.getChronon(argOut1.getByteArray(), 1)
+ * GregorianCalendarSystem.CHRONON_OF_DAY;
+
+ break;
+ case TIME:
+ leftChronon = ATimeSerializerDeserializer.getChronon(argOut0.getByteArray(), 1);
+ rightChronon = ATimeSerializerDeserializer.getChronon(argOut1.getByteArray(), 1);
+ break;
+ case DATETIME:
+ leftChronon = ADateTimeSerializerDeserializer.getChronon(argOut0.getByteArray(), 1);
+ rightChronon = ADateTimeSerializerDeserializer
+ .getChronon(argOut1.getByteArray(), 1);
+ break;
+ case YEARMONTHDURATION:
+ yearMonth = (int) evaluateTimeInstanceArithmetic(
+ AYearMonthDurationSerializerDeserializer.getYearMonth(
+ argOut0.getByteArray(), 1),
+ AYearMonthDurationSerializerDeserializer.getYearMonth(
+ argOut1.getByteArray(), 1));
+ break;
+ case DAYTIMEDURATION:
+ leftChronon = ADayTimeDurationSerializerDeserializer.getDayTime(
+ argOut0.getByteArray(), 1);
+ rightChronon = ADayTimeDurationSerializerDeserializer.getDayTime(
+ argOut1.getByteArray(), 1);
+ break;
+ default:
+ throw new NotImplementedException();
+ }
+
+ dayTime = evaluateTimeInstanceArithmetic(leftChronon, rightChronon);
+
+ aDuration.setValue(yearMonth, dayTime);
+
+ serde.serialize(aDuration, out);
+
+ } else {
+ long chronon = 0, dayTime = 0;
+ int yearMonth = 0;
+ ATypeTag resultType = null;
+
+ boolean isTimeOnly = false;
+
+ switch (leftType) {
+ case TIME:
+ serde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ATIME);
+ chronon = ATimeSerializerDeserializer.getChronon(argOut0.getByteArray(), 1);
+ isTimeOnly = true;
+ resultType = ATypeTag.TIME;
+ switch (rightType) {
+ case DAYTIMEDURATION:
+ dayTime = ADayTimeDurationSerializerDeserializer.getDayTime(
+ argOut1.getByteArray(), 1);
+ break;
+ case DURATION:
+ dayTime = ADurationSerializerDeserializer.getDayTime(
+ argOut1.getByteArray(), 1);
+ yearMonth = ADurationSerializerDeserializer.getYearMonth(
+ argOut1.getByteArray(), 1);
+ break;
+ default:
+ throw new NotImplementedException(getIdentifier().getName()
+ + ": arithmetic operation between " + leftType + " and a "
+ + rightType + " value is not supported.");
+ }
+ break;
+ case DATE:
+ serde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ADATE);
+ resultType = ATypeTag.DATE;
+ chronon = ADateSerializerDeserializer.getChronon(argOut0.getByteArray(), 1)
+ * GregorianCalendarSystem.CHRONON_OF_DAY;
+ case DATETIME:
+ if (leftType == ATypeTag.DATETIME) {
+ serde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ADATETIME);
+ resultType = ATypeTag.DATETIME;
+ chronon = ADateTimeSerializerDeserializer.getChronon(argOut0.getByteArray(), 1);
+ }
+ switch (rightType) {
+ case DURATION:
+ yearMonth = ADurationSerializerDeserializer.getYearMonth(
+ argOut1.getByteArray(), 1);
+ dayTime = ADurationSerializerDeserializer.getDayTime(
+ argOut1.getByteArray(), 1);
+ break;
+ case YEARMONTHDURATION:
+ yearMonth = AYearMonthDurationSerializerDeserializer.getYearMonth(
+ argOut1.getByteArray(), 1);
+ break;
+ case DAYTIMEDURATION:
+ dayTime = ADayTimeDurationSerializerDeserializer.getDayTime(
+ argOut1.getByteArray(), 1);
+ break;
+ default:
+ throw new NotImplementedException(getIdentifier().getName()
+ + ": arithmetic operation between " + leftType + " and a "
+ + rightType + " value is not supported.");
+ }
+ break;
+ case YEARMONTHDURATION:
+ yearMonth = AYearMonthDurationSerializerDeserializer.getYearMonth(
+ argOut0.getByteArray(), 1);
+ switch (rightType) {
+ case DATETIME:
+ serde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ADATETIME);
+ resultType = ATypeTag.DATETIME;
+ chronon = ADateTimeSerializerDeserializer.getChronon(
+ argOut1.getByteArray(), 1);
+ break;
+ case DATE:
+ serde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ADATE);
+ resultType = ATypeTag.DATE;
+ chronon = ADateSerializerDeserializer.getChronon(argOut1.getByteArray(), 1)
+ * GregorianCalendarSystem.CHRONON_OF_DAY;
+ break;
+ default:
+ throw new NotImplementedException(getIdentifier().getName()
+ + ": arithmetic operation between " + leftType + " and a "
+ + rightType + " value is not supported.");
+ }
+ break;
+ case DURATION:
+ yearMonth = ADurationSerializerDeserializer.getYearMonth(argOut0.getByteArray(), 1);
+ dayTime = ADurationSerializerDeserializer.getDayTime(argOut0.getByteArray(), 1);
+ case DAYTIMEDURATION:
+ if (leftType == ATypeTag.DAYTIMEDURATION) {
+ dayTime = ADayTimeDurationSerializerDeserializer.getDayTime(
+ argOut0.getByteArray(), 1);
+ }
+ switch (rightType) {
+ case DATETIME:
+ serde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ADATETIME);
+ resultType = ATypeTag.DATETIME;
+ chronon = ADateTimeSerializerDeserializer.getChronon(
+ argOut1.getByteArray(), 1);
+ break;
+ case DATE:
+ serde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ADATE);
+ resultType = ATypeTag.DATE;
+ chronon = ADateSerializerDeserializer.getChronon(argOut1.getByteArray(), 1)
+ * GregorianCalendarSystem.CHRONON_OF_DAY;
+ break;
+ case TIME:
+ if (yearMonth == 0) {
+ serde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ATIME);
+ resultType = ATypeTag.TIME;
+ chronon = ATimeSerializerDeserializer.getChronon(
+ argOut1.getByteArray(), 1);
+ isTimeOnly = true;
+ break;
+ }
+ default:
+ throw new NotImplementedException(getIdentifier().getName()
+ + ": arithmetic operation between " + leftType + " and a "
+ + rightType + " value is not supported.");
+ }
+ break;
+ default:
+ throw new NotImplementedException(getIdentifier().getName()
+ + ": arithmetic operation between " + leftType + " and a " + rightType
+ + " value is not supported.");
+ }
+
+ chronon = evaluateTimeDurationArithmetic(chronon, yearMonth, dayTime, isTimeOnly);
+
+ switch (resultType) {
+ case DATE:
+
+ if (chronon < 0 && chronon % GregorianCalendarSystem.CHRONON_OF_DAY != 0) {
+ chronon = chronon / GregorianCalendarSystem.CHRONON_OF_DAY - 1;
+ } else {
+ chronon = chronon / GregorianCalendarSystem.CHRONON_OF_DAY;
+ }
+ aDate.setValue((int) chronon);
+ serde.serialize(aDate, out);
+ break;
+ case TIME:
+ aTime.setValue((int) chronon);
+ serde.serialize(aTime, out);
+ break;
+ case DATETIME:
+ aDatetime.setValue(chronon);
+ serde.serialize(aDatetime, out);
+ break;
+ default:
+ throw new NotImplementedException(getIdentifier().getName()
+ + ": arithmetic operation between " + leftType + " and a " + rightType
+ + " value is not supported.");
+
+ }
+ }
+ }
};
}
};
}
-
}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericAddDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericAddDescriptor.java
index bb63d27..7cd96fa 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericAddDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericAddDescriptor.java
@@ -14,6 +14,7 @@
*/
package edu.uci.ics.asterix.runtime.evaluators.functions;
+import edu.uci.ics.asterix.om.base.temporal.DurationArithmeticOperations;
import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -49,4 +50,15 @@
protected double evaluateDouble(double lhs, double rhs) throws HyracksDataException {
return lhs + rhs;
}
+
+ @Override
+ protected long evaluateTimeDurationArithmetic(long chronon, int yearMonth, long dayTime, boolean isTimeOnly)
+ throws HyracksDataException {
+ return DurationArithmeticOperations.addDuration(chronon, yearMonth, dayTime, isTimeOnly);
+ }
+
+ @Override
+ protected long evaluateTimeInstanceArithmetic(long chronon0, long chronon1) throws HyracksDataException {
+ throw new HyracksDataException("Undefined addition operation between two time instances.");
+ }
}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericCaretDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericCaretDescriptor.java
index 208c454..502c013 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericCaretDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericCaretDescriptor.java
@@ -17,6 +17,7 @@
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.hyracks.algebricks.common.exceptions.NotImplementedException;
import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
@@ -61,4 +62,15 @@
return AsterixBuiltinFunctions.CARET;
}
+ @Override
+ protected long evaluateTimeDurationArithmetic(long chronon, int yearMonth, long dayTime, boolean isTimeOnly)
+ throws HyracksDataException {
+ throw new NotImplementedException("Caret operation is not defined for temporal types");
+ }
+
+ @Override
+ protected long evaluateTimeInstanceArithmetic(long chronon0, long chronon1) throws HyracksDataException {
+ throw new NotImplementedException("Caret operation is not defined for temporal types");
+ }
+
}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericDivideDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericDivideDescriptor.java
index 9b3b0e9..069007c 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericDivideDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericDivideDescriptor.java
@@ -17,6 +17,7 @@
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.hyracks.algebricks.common.exceptions.NotImplementedException;
import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
@@ -45,4 +46,15 @@
protected double evaluateDouble(double lhs, double rhs) {
return lhs / rhs;
}
+
+ @Override
+ protected long evaluateTimeDurationArithmetic(long chronon, int yearMonth, long dayTime, boolean isTimeOnly)
+ throws HyracksDataException {
+ throw new NotImplementedException("Divide operation is not defined for temporal types");
+ }
+
+ @Override
+ protected long evaluateTimeInstanceArithmetic(long chronon0, long chronon1) throws HyracksDataException {
+ throw new NotImplementedException("Divide operation is not defined for temporal types");
+ }
}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericMultiplyDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericMultiplyDescriptor.java
index a95c693..92f15b4 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericMultiplyDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericMultiplyDescriptor.java
@@ -17,6 +17,7 @@
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.hyracks.algebricks.common.exceptions.NotImplementedException;
import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
@@ -57,4 +58,15 @@
return lhs * rhs;
}
+
+ @Override
+ protected long evaluateTimeDurationArithmetic(long chronon, int yearMonth, long dayTime, boolean isTimeOnly)
+ throws HyracksDataException {
+ throw new NotImplementedException("Multiply operation is not defined for temporal types");
+ }
+
+ @Override
+ protected long evaluateTimeInstanceArithmetic(long chronon0, long chronon1) throws HyracksDataException {
+ throw new NotImplementedException("Multiply operation is not defined for temporal types");
+ }
}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericSubDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericSubDescriptor.java
new file mode 100644
index 0000000..84c308f
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/NumericSubDescriptor.java
@@ -0,0 +1,77 @@
+/*
+ * 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;
+
+import edu.uci.ics.asterix.om.base.temporal.DurationArithmeticOperations;
+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.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+
+public class NumericSubDescriptor extends AbstractNumericArithmeticEval {
+
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new NumericSubDescriptor();
+ }
+ };
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.NUMERIC_SUBTRACT;
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.runtime.evaluators.functions.AbstractNumericArithmeticEval#evaluateInteger(long, long)
+ */
+ @Override
+ protected long evaluateInteger(long lhs, long rhs) throws HyracksDataException {
+ long res = lhs - rhs;
+ if (lhs > 0) {
+ if (rhs < 0 && res < 0)
+ throw new HyracksDataException("Overflow adding " + lhs + " + " + rhs);
+ } else if (rhs > 0 && res > 0)
+ throw new HyracksDataException("Underflow adding " + lhs + " + " + rhs);
+ return res;
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.runtime.evaluators.functions.AbstractNumericArithmeticEval#evaluateDouble(double, double)
+ */
+ @Override
+ protected double evaluateDouble(double lhs, double rhs) throws HyracksDataException {
+ return lhs - rhs;
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.runtime.evaluators.functions.AbstractNumericArithmeticEval#evaluateTimeDurationArithmetic(long, int, long, boolean)
+ */
+ @Override
+ protected long evaluateTimeDurationArithmetic(long chronon, int yearMonth, long dayTime, boolean isTimeOnly)
+ throws HyracksDataException {
+ return DurationArithmeticOperations.addDuration(chronon, -1 * yearMonth, -1 * dayTime, isTimeOnly);
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.runtime.evaluators.functions.AbstractNumericArithmeticEval#evaluateTimeInstanceArithmetic(long, long)
+ */
+ @Override
+ protected long evaluateTimeInstanceArithmetic(long chronon0, long chronon1) throws HyracksDataException {
+ return evaluateInteger(chronon0, chronon1);
+ }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AddDateDurationDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AddDateDurationDescriptor.java
deleted file mode 100644
index eccee9d..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AddDateDurationDescriptor.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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.ADateSerializerDeserializer;
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
-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.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.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 AddDateDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
- private final static long serialVersionUID = 1L;
- public final static FunctionIdentifier FID = AsterixBuiltinFunctions.ADD_DATE_DURATION;
-
- // allowed input types
- 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();
-
- public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
-
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new AddDateDurationDescriptor();
- }
- };
-
- @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 argOut0 = new ArrayBackedValueStorage();
- private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
- private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
- private ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
-
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ADate> dateSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ADATE);
-
- private AMutableDate aDate = new AMutableDate(0);
-
- @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);
- return;
- }
-
- if (argOut0.getByteArray()[0] != SER_DATE_TYPE_TAG) {
- throw new AlgebricksException(FID.getName()
- + ": expects type DATE/NULL for parameter 0 but got "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
- }
-
- if (argOut1.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
- throw new AlgebricksException(FID.getName()
- + ": expects type DURATION/NULL for parameter 1 but got "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
- }
-
- // get duration fields: yearMonth field and dayTime field
- int yearMonth = ADurationSerializerDeserializer.getYearMonth(argOut1.getByteArray(), 1);
- long dayTime = ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1);
-
- // get date fields
- long datetimeChronon = ADateSerializerDeserializer.getChronon(argOut0.getByteArray(), 1)
- * GregorianCalendarSystem.CHRONON_OF_DAY;
-
- datetimeChronon = DurationArithmeticOperations.addDuration(datetimeChronon, yearMonth,
- dayTime);
-
- int dateChrononInDays = (int) (datetimeChronon / GregorianCalendarSystem.CHRONON_OF_DAY);
- if (dateChrononInDays < 0 && datetimeChronon % GregorianCalendarSystem.CHRONON_OF_DAY != 0) {
- dateChrononInDays -= 1;
- }
-
- aDate.setValue(dateChrononInDays);
-
- dateSerde.serialize(aDate, 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/AddDatetimeDurationDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AddDatetimeDurationDescriptor.java
deleted file mode 100644
index 0037b38..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AddDatetimeDurationDescriptor.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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.ADateTimeSerializerDeserializer;
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
-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.base.temporal.DurationArithmeticOperations;
-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 AddDatetimeDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
- private final static long serialVersionUID = 1L;
- public final static FunctionIdentifier FID = AsterixBuiltinFunctions.ADD_DATETIME_DURATION;
-
- // allowed input types
- 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();
-
- public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
-
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new AddDatetimeDurationDescriptor();
- }
- };
-
- /* (non-Javadoc)
- * @see edu.uci.ics.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
- */
- @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 argOut0 = new ArrayBackedValueStorage();
- private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
- private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
- private ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
-
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ADATETIME);
-
- private AMutableDateTime aDatetime = new AMutableDateTime(0);
-
- @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);
- return;
- }
-
- if (argOut0.getByteArray()[0] != SER_DATETIME_TYPE_TAG) {
- throw new AlgebricksException(FID.getName()
- + ": expects type DATETIME/NULL for parameter 0 but got "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
- }
-
- if (argOut1.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
- throw new AlgebricksException(FID.getName()
- + ": expects type DURATION/NULL for parameter 1 but got "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
- }
-
- // get duration fields: yearMonth field and dayTime field
- int yearMonth = ADurationSerializerDeserializer.getYearMonth(argOut1.getByteArray(), 1);
- long dayTime = ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1);
-
- // get date fields
- long datetimeChronon = ADateTimeSerializerDeserializer
- .getChronon(argOut0.getByteArray(), 1);
-
- datetimeChronon = DurationArithmeticOperations.addDuration(datetimeChronon, yearMonth,
- dayTime);
-
- aDatetime.setValue(datetimeChronon);
-
- datetimeSerde.serialize(aDatetime, out);
-
- } catch (HyracksDataException hex) {
- throw new AlgebricksException(hex);
- }
- }
- };
- }
- };
- }
-
- /* (non-Javadoc)
- * @see edu.uci.ics.asterix.om.functions.IFunctionDescriptor#getIdentifier()
- */
- @Override
- public FunctionIdentifier getIdentifier() {
- return FID;
- }
-
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AddTimeDurationDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AddTimeDurationDescriptor.java
deleted file mode 100644
index ca86379..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AddTimeDurationDescriptor.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.ADurationSerializerDeserializer;
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ATimeSerializerDeserializer;
-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.base.temporal.DurationArithmeticOperations;
-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 AddTimeDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
- private final static long serialVersionUID = 1L;
- public final static FunctionIdentifier FID = AsterixBuiltinFunctions.ADD_TIME_DURATION;
-
- // allowed input types
- 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();
-
- public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
-
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new AddTimeDurationDescriptor();
- }
- };
-
- /* (non-Javadoc)
- * @see edu.uci.ics.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
- */
- @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 argOut0 = new ArrayBackedValueStorage();
- private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
- private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
- private ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
-
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ATIME);
-
- private AMutableTime aTime = new AMutableTime(0);
-
- @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);
- return;
- }
-
- if (argOut0.getByteArray()[0] != SER_TIME_TYPE_TAG) {
- throw new AlgebricksException(FID.getName()
- + ": expects type TIME/NULL for parameter 0 but got "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
- }
-
- if (argOut1.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
- throw new AlgebricksException(FID.getName()
- + ": expects type DURATION/NULL for parameter 1 but got "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
- }
-
- // get duration fields: yearMonth field and dayTime field
- int yearMonth = ADurationSerializerDeserializer.getYearMonth(argOut1.getByteArray(), 1);
-
- // cannot add a year-month duration to a time value
- if (yearMonth != 0) {
- throw new AlgebricksException(FID.getName()
- + ": a TIME value cannot be added by a DURATION value with year-month field.");
- }
-
- long dayTime = ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1);
-
- // get time fields
- int timeChronon = ATimeSerializerDeserializer.getChronon(argOut0.getByteArray(), 1);
-
- timeChronon = DurationArithmeticOperations.addDuration(timeChronon, dayTime);
-
- aTime.setValue(timeChronon);
-
- timeSerde.serialize(aTime, out);
-
- } catch (HyracksDataException hex) {
- throw new AlgebricksException(hex);
- }
- }
- };
- }
- };
- }
-
- /* (non-Javadoc)
- * @see edu.uci.ics.asterix.om.functions.IFunctionDescriptor#getIdentifier()
- */
- @Override
- public FunctionIdentifier getIdentifier() {
- return FID;
- }
-
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java
index 9e603ed..9ef3f58 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java
@@ -127,7 +127,7 @@
* GregorianCalendarSystem.CHRONON_OF_DAY;
long endingTimePoint = DurationArithmeticOperations.addDuration(startingTimePoint,
- yearMonthDurationInMonths, dayTimeDurationInMs);
+ yearMonthDurationInMonths, dayTimeDurationInMs, false);
if (startingTimePoint == endingTimePoint) {
aDuration.setValue(0, 0);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java
index 10cc1c0..da5f195 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java
@@ -141,7 +141,7 @@
1);
long endingTimePoint = DurationArithmeticOperations.addDuration(startingTimePoint,
- yearMonthDurationInMonths, dayTimeDurationInMs);
+ yearMonthDurationInMonths, dayTimeDurationInMs, false);
if (startingTimePoint == endingTimePoint) {
aDuration.setValue(0, 0);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
index 9a66d45..d2f2b07 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
@@ -16,7 +16,7 @@
import java.io.DataOutput;
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AYearMonthDurationerializerDeserializer;
+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.AInt32;
import edu.uci.ics.asterix.om.base.AMutableInt32;
@@ -96,7 +96,7 @@
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
}
- aInt32.setValue(AYearMonthDurationerializerDeserializer.getYearMonth(
+ aInt32.setValue(AYearMonthDurationSerializerDeserializer.getYearMonth(
argOut0.getByteArray(), 1));
int32Serde.serialize(aInt32, out);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/SubtractDateDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/SubtractDateDescriptor.java
deleted file mode 100644
index eaaf900..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/SubtractDateDescriptor.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * 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.ADateSerializerDeserializer;
-import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import edu.uci.ics.asterix.om.base.ADuration;
-import edu.uci.ics.asterix.om.base.AMutableDuration;
-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 SubtractDateDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
- private final static long serialVersionUID = 1L;
- public final static FunctionIdentifier FID = AsterixBuiltinFunctions.SUBTRACT_DATE;
-
- // allowed input types
- private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
- private final static byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
-
- public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
-
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new SubtractDateDescriptor();
- }
- };
-
- @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 argOut0 = new ArrayBackedValueStorage();
- private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
- private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
- private ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
-
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ADURATION);
-
- private AMutableDuration aDuration = new AMutableDuration(0, 0);
-
- @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);
- return;
- }
-
- if (argOut0.getByteArray()[0] != SER_DATE_TYPE_TAG
- && argOut1.getByteArray()[0] != SER_DATE_TYPE_TAG) {
- throw new AlgebricksException(FID.getName()
- + ": expects input type (DATE/NULL, DATE/NULL) but got ("
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0])
- + ", "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0])
- + ").");
- }
-
- long durationChronon = (ADateSerializerDeserializer.getChronon(argOut0.getByteArray(), 1) - ADateSerializerDeserializer
- .getChronon(argOut1.getByteArray(), 1)) * GregorianCalendarSystem.CHRONON_OF_DAY;
-
- aDuration.setValue(0, durationChronon);
-
- durationSerde.serialize(aDuration, 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/SubtractDatetimeDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/SubtractDatetimeDescriptor.java
deleted file mode 100644
index b43892d..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/SubtractDatetimeDescriptor.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * 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.ADateTimeSerializerDeserializer;
-import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import edu.uci.ics.asterix.om.base.ADuration;
-import edu.uci.ics.asterix.om.base.AMutableDuration;
-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 SubtractDatetimeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
- private final static long serialVersionUID = 1L;
- public final static FunctionIdentifier FID = AsterixBuiltinFunctions.SUBTRACT_DATETIME;
-
- // allowed input types
- private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
- private final static byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
-
- public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
-
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new SubtractDatetimeDescriptor();
- }
- };
-
- /* (non-Javadoc)
- * @see edu.uci.ics.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
- */
- @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 argOut0 = new ArrayBackedValueStorage();
- private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
- private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
- private ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
-
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ADURATION);
-
- private AMutableDuration aDuration = new AMutableDuration(0, 0);
-
- @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);
- return;
- }
-
- if (argOut0.getByteArray()[0] != SER_DATETIME_TYPE_TAG
- && argOut1.getByteArray()[0] != SER_DATETIME_TYPE_TAG) {
- throw new AlgebricksException(FID.getName()
- + ": expects input type (DATETIME/NULL, DATETIME/NULL) but got ("
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0])
- + ", "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0])
- + ").");
- }
-
- long durationChronon = ADateTimeSerializerDeserializer
- .getChronon(argOut0.getByteArray(), 1)
- - ADateTimeSerializerDeserializer.getChronon(argOut1.getByteArray(), 1);
-
- aDuration.setValue(0, durationChronon);
-
- durationSerde.serialize(aDuration, out);
-
- } catch (HyracksDataException hex) {
- throw new AlgebricksException(hex);
- }
- }
- };
- }
- };
- }
-
- /* (non-Javadoc)
- * @see edu.uci.ics.asterix.om.functions.IFunctionDescriptor#getIdentifier()
- */
- @Override
- public FunctionIdentifier getIdentifier() {
- return FID;
- }
-
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/SubtractTimeDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/SubtractTimeDescriptor.java
deleted file mode 100644
index 24edca6..0000000
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/SubtractTimeDescriptor.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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.ATimeSerializerDeserializer;
-import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import edu.uci.ics.asterix.om.base.ADuration;
-import edu.uci.ics.asterix.om.base.AMutableDuration;
-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 SubtractTimeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
- private final static long serialVersionUID = 1L;
- public final static FunctionIdentifier FID = AsterixBuiltinFunctions.SUBTRACT_TIME;
-
- // allowed input types
- private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
- private final static byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
-
- public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
-
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new SubtractTimeDescriptor();
- }
- };
-
- /* (non-Javadoc)
- * @see edu.uci.ics.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
- */
- @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 argOut0 = new ArrayBackedValueStorage();
- private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
- private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
- private ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
-
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ADURATION);
-
- private AMutableDuration aDuration = new AMutableDuration(0, 0);
-
- @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);
- return;
- }
-
- if (argOut0.getByteArray()[0] != SER_TIME_TYPE_TAG
- && argOut1.getByteArray()[0] != SER_TIME_TYPE_TAG) {
- throw new AlgebricksException(FID.getName()
- + ": expects input type (TIME/NULL, TIME/NULL) but got ("
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0])
- + ", "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0])
- + ").");
- }
-
- int durationChronon = ATimeSerializerDeserializer.getChronon(argOut0.getByteArray(), 1)
- - ATimeSerializerDeserializer.getChronon(argOut1.getByteArray(), 1);
-
- aDuration.setValue(0, durationChronon);
-
- durationSerde.serialize(aDuration, out);
-
- } catch (HyracksDataException hex) {
- throw new AlgebricksException(hex);
- }
- }
- };
- }
- };
- }
-
- /* (non-Javadoc)
- * @see edu.uci.ics.asterix.om.functions.IFunctionDescriptor#getIdentifier()
- */
- @Override
- public FunctionIdentifier getIdentifier() {
- return FID;
- }
-
-}
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 ecea27a..5646aa2 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
@@ -173,6 +173,7 @@
import edu.uci.ics.asterix.runtime.evaluators.functions.NumericRoundDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.NumericRoundHalfToEven2Descriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.NumericRoundHalfToEvenDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.NumericSubDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.NumericSubtractDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.NumericUnaryMinusDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.OpenRecordConstructorDescriptor;
@@ -210,9 +211,6 @@
import edu.uci.ics.asterix.runtime.evaluators.functions.SwitchCaseDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.UnorderedListConstructorDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.WordTokensDescriptor;
-import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.AddDateDurationDescriptor;
-import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.AddDatetimeDurationDescriptor;
-import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.AddTimeDurationDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.AdjustDateTimeForTimeZoneDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.AdjustTimeForTimeZoneDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.CalendarDuartionFromDateDescriptor;
@@ -245,12 +243,6 @@
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalOverlapsDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalStartedByDescriptor;
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.OverlapDescriptor;
-import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.SubtractDateDescriptor;
-import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.SubtractDatetimeDescriptor;
-import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.SubtractTimeDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.TimeFromDatetimeDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.TimeFromUnixTimeInMsDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.YearMonthDurationComparatorDecriptor;
@@ -362,7 +354,7 @@
temp.add(NumericAddDescriptor.FACTORY);
temp.add(NumericDivideDescriptor.FACTORY);
temp.add(NumericMultiplyDescriptor.FACTORY);
- temp.add(NumericSubtractDescriptor.FACTORY);
+ temp.add(NumericSubDescriptor.FACTORY);
temp.add(NumericModuloDescriptor.FACTORY);
temp.add(NumericCaretDescriptor.FACTORY);
temp.add(IsNullDescriptor.FACTORY);
@@ -510,16 +502,10 @@
// Temporal functions
temp.add(DateFromUnixTimeInDaysDescriptor.FACTORY);
temp.add(DateFromDatetimeDescriptor.FACTORY);
- temp.add(AddDateDurationDescriptor.FACTORY);
- temp.add(SubtractDateDescriptor.FACTORY);
temp.add(TimeFromUnixTimeInMsDescriptor.FACTORY);
temp.add(TimeFromDatetimeDescriptor.FACTORY);
- temp.add(SubtractTimeDescriptor.FACTORY);
- temp.add(AddTimeDurationDescriptor.FACTORY);
temp.add(DatetimeFromUnixTimeInMsDescriptor.FACTORY);
temp.add(DatetimeFromDateAndTimeDescriptor.FACTORY);
- temp.add(SubtractDatetimeDescriptor.FACTORY);
- temp.add(AddDatetimeDurationDescriptor.FACTORY);
temp.add(CalendarDurationFromDateTimeDescriptor.FACTORY);
temp.add(CalendarDuartionFromDateDescriptor.FACTORY);
temp.add(AdjustDateTimeForTimeZoneDescriptor.FACTORY);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
index 9271ebf..db3b177 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
@@ -42,7 +42,7 @@
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.APolygonSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ARectangleSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ATimeSerializerDeserializer;
-import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AYearMonthDurationerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AYearMonthDurationSerializerDeserializer;
import edu.uci.ics.asterix.om.base.ABoolean;
import edu.uci.ics.asterix.om.base.ANull;
import edu.uci.ics.asterix.om.types.AOrderedListType;
@@ -375,7 +375,7 @@
private void parseYearMonthDuration(String duration, DataOutput out) throws AsterixException {
try {
- AYearMonthDurationerializerDeserializer.parse(duration, out);
+ AYearMonthDurationSerializerDeserializer.parse(duration, out);
} catch (HyracksDataException e) {
throw new AsterixException(e);
}