merged r1661:1697 from lsm_stabilization
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_lsm_stabilization_interval_leftover@1698 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/test/resources/runtimets/queries/constructor/interval/interval.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/constructor/interval/interval.3.query.aql
index ebb3d2d..f30fdd7 100644
--- a/asterix-app/src/test/resources/runtimets/queries/constructor/interval/interval.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/constructor/interval/interval.3.query.aql
@@ -1,11 +1,41 @@
use dataverse test;
-let $itv1 := interval-from-date("2010-10-30", "2012-10-21")
-let $itv2 := interval-from-time("03:04:05.678-11:00", "232425267+0200")
-let $itv3 := interval-from-datetime("-1987-11-19T02:43:57.938+08:00", "19991112T124935948-0700")
-let $itv4 := interval-start-from-date("0001-12-27", "P3Y394DT48H398.483S")
-let $itv5 := interval-start-from-time("20:03:20.948", "P60DT48M389.938S")
-let $itv6 := interval-start-from-datetime("-2043-11-19T15:32:39.293", "P439Y3M20DT20H39M58.949S")
+let $itv11 := interval-from-date(date("2010-10-30"), date("2012-10-21"))
+let $itv12 := interval-from-date("2010-10-30", date("2012-10-21"))
+let $itv13 := interval-from-date(date("2010-10-30"), "2012-10-21")
+let $itv14 := interval-from-date("2010-10-30", "2012-10-21")
+let $itv15 := interval-from-date(null, "2012-10-21")
+let $itv16 := interval-from-date("2010-10-30", null)
+let $itv21 := interval-from-time(time("03:04:05.678-11:00"), time("232425267+0200"))
+let $itv22 := interval-from-time("03:04:05.678-11:00", time("232425267+0200"))
+let $itv23 := interval-from-time(time("03:04:05.678-11:00"), "232425267+0200")
+let $itv24 := interval-from-time("03:04:05.678-11:00", "232425267+0200")
+let $itv25 := interval-from-time(null, time("232425267+0200"))
+let $itv26 := interval-from-time(time("03:04:05.678-11:00"), null)
+let $itv31 := interval-from-datetime(datetime("-1987-11-19T02:43:57.938+08:00"), datetime("19991112T124935948-0700"))
+let $itv32 := interval-from-datetime("-1987-11-19T02:43:57.938+08:00", datetime("19991112T124935948-0700"))
+let $itv33 := interval-from-datetime(datetime("-1987-11-19T02:43:57.938+08:00"), "19991112T124935948-0700")
+let $itv34 := interval-from-datetime("-1987-11-19T02:43:57.938+08:00", "19991112T124935948-0700")
+let $itv35 := interval-from-datetime(null, datetime("19991112T124935948-0700"))
+let $itv36 := interval-from-datetime(datetime("-1987-11-19T02:43:57.938+08:00"), null)
+let $itv41 := interval-start-from-date(date("0001-12-27"), duration("P3Y394DT48H398.483S"))
+let $itv42 := interval-start-from-date("0001-12-27", duration("P3Y394DT48H398.483S"))
+let $itv43 := interval-start-from-date(date("0001-12-27"), "P3Y394DT48H398.483S")
+let $itv44 := interval-start-from-date("0001-12-27", "P3Y394DT48H398.483S")
+let $itv45 := interval-start-from-date(null, duration("P3Y394DT48H398.483S"))
+let $itv46 := interval-start-from-date(date("0001-12-27"), null)
+let $itv51 := interval-start-from-time(time("20:03:20.948"), duration("P60DT48M389.938S"))
+let $itv52 := interval-start-from-time("20:03:20.948", duration("P60DT48M389.938S"))
+let $itv53 := interval-start-from-time(time("20:03:20.948"), "P60DT48M389.938S")
+let $itv54 := interval-start-from-time("20:03:20.948", "P60DT48M389.938S")
+let $itv55 := interval-start-from-time(null, duration("P60DT48M389.938S"))
+let $itv56 := interval-start-from-time(time("20:03:20.948"), null)
+let $itv61 := interval-start-from-datetime(datetime("-2043-11-19T15:32:39.293"), duration("P439Y3M20DT20H39M58.949S"))
+let $itv62 := interval-start-from-datetime("-2043-11-19T15:32:39.293", duration("P439Y3M20DT20H39M58.949S"))
+let $itv63 := interval-start-from-datetime(datetime("-2043-11-19T15:32:39.293"), "P439Y3M20DT20H39M58.949S")
+let $itv64 := interval-start-from-datetime("-2043-11-19T15:32:39.293", "P439Y3M20DT20H39M58.949S")
+let $itv65 := interval-start-from-datetime(null, duration("P439Y3M20DT20H39M58.949S"))
+let $itv66 := interval-start-from-datetime(datetime("-2043-11-19T15:32:39.293"), null)
-return {"interval1": $itv1, "interval2": $itv2, "interval3": $itv3, "interval4": $itv4, "interval5": $itv5, "interval6": $itv6}
+return {"interval11": $itv11, "interval12": $itv12, "interval13": $itv13, "interval14": $itv14, "interval15": $itv15, "interval16": $itv16, "interval21": $itv21, "interval22": $itv22, "interval23": $itv23, "interval24": $itv24, "interval25": $itv25, "interval26": $itv26, "interval31": $itv31, "interval32": $itv32, "interval33": $itv33, "interval34": $itv34, "interval35": $itv35, "interval36": $itv36, "interval41": $itv41, "interval42": $itv42, "interval43": $itv43, "interval44": $itv44, "interval45": $itv45, "interval46": $itv46, "interval51": $itv51, "interval52": $itv52, "interval53": $itv53, "interval54": $itv54, "interval55": $itv55, "interval56": $itv56, "interval61": $itv61, "interval62": $itv62, "interval63": $itv63, "interval64": $itv64, "interval65": $itv65, "interval66": $itv66}
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/accessors/accessors.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors/accessors.3.query.aql
index 2586d2a..c41d37d 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temporal/accessors/accessors.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors/accessors.3.query.aql
@@ -9,4 +9,4 @@
let $c7 := string("-0003-01-09T23:12:12.39-07:00")
let $c8 := duration("P3Y73M632DT49H743M3948.94S")
-return {"year1": year($c1), "year2": year($c2), "year3": year($c3), "year4": year($c4), "year5": year($c5), "year6": year($c7), "year7": year($c8), "month1": month($c1), "month2": month($c2), "month3": month($c3), "month4": month($c4), "month5": month($c5), "month6": month($c8), "day1": day($c1), "day2": day($c2), "day3": day($c3), "day4": day($c4), "day5": day($c5), "day6": day($c8), "hour1": hour($c2), "hour2": hour($c5), "hour3": hour($c6), "hour4": hour($c8), "min1": minute($c2), "min2": minute($c5), "min3": minute($c6), "min4": minute($c8), "second1": second($c2), "second2": second($c5), "second3": second($c6), "second4": second($c8), "ms1": millisecond($c2), "ms2": millisecond($c5), "ms3": millisecond($c6), "ms4": millisecond($c8)}
+return {"year1": year($c1), "year2": year($c2), "year3": year($c3), "year4": year($c4), "year5": year($c5), "year6": year($c7), "year7": year($c8), "year-null": year(null), "month1": month($c1), "month2": month($c2), "month3": month($c3), "month4": month($c4), "month5": month($c5), "month6": month($c8), "month-null": month(null), "day1": day($c1), "day2": day($c2), "day3": day($c3), "day4": day($c4), "day5": day($c5), "day6": day($c8), "day-null": day(null), "hour1": hour($c2), "hour2": hour($c5), "hour3": hour($c6), "hour4": hour($c8), "hour-null": hour(null), "min1": minute($c2), "min2": minute($c5), "min3": minute($c6), "min4": minute($c8), "min-null": minute(null), "second1": second($c2), "second2": second($c5), "second3": second($c6), "second4": second($c8), "second-null": second(null), "ms1": millisecond($c2), "ms2": millisecond($c5), "ms3": millisecond($c6), "ms4": millisecond($c8), "ms-null": millisecond(null) }
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval/accessors_interval.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval/accessors_interval.1.ddl.aql
new file mode 100644
index 0000000..e6a3879
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval/accessors_interval.1.ddl.aql
@@ -0,0 +1,2 @@
+drop dataverse test if exists;
+create dataverse test;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval/accessors_interval.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval/accessors_interval.2.update.aql
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval/accessors_interval.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval/accessors_interval.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval/accessors_interval.3.query.aql
new file mode 100644
index 0000000..b703377
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval/accessors_interval.3.query.aql
@@ -0,0 +1,7 @@
+use dataverse test;
+
+let $interval1 := interval-from-date(date("2010-10-30"), "2013-04-01")
+let $interval2 := interval-from-time("08:09:10.234Z", time("203040567+0800"))
+let $interval3 := interval-from-datetime("2009-09-01T00:00:00.000+08:00", datetime-from-date-time(date("2013-04-04"), time("00:00:00.000+08:00")))
+
+return {"start1": get-interval-start($interval1), "end1": get-interval-end($interval1), "start2": get-interval-start($interval2), "end2": get-interval-end($interval2), "start3": get-interval-start($interval3), "end3": get-interval-end($interval3) }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval_null/accessors_interval_null.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval_null/accessors_interval_null.1.ddl.aql
new file mode 100644
index 0000000..e6a3879
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval_null/accessors_interval_null.1.ddl.aql
@@ -0,0 +1,2 @@
+drop dataverse test if exists;
+create dataverse test;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval_null/accessors_interval_null.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval_null/accessors_interval_null.2.update.aql
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval_null/accessors_interval_null.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval_null/accessors_interval_null.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval_null/accessors_interval_null.3.query.aql
new file mode 100644
index 0000000..98bead8
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/accessors_interval_null/accessors_interval_null.3.query.aql
@@ -0,0 +1,3 @@
+use dataverse test;
+
+{"start-null-interval": get-interval-start(null), "end-null-interval": get-interval-end(null) }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/adjust_timezone/adjust_timezone.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/adjust_timezone/adjust_timezone.3.query.aql
index a3959b0..c099d14 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temporal/adjust_timezone/adjust_timezone.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/adjust_timezone/adjust_timezone.3.query.aql
@@ -4,4 +4,4 @@
let $dt1 := datetime("2010-10-23T01:12:13.329Z")
let $s1 := adjust-time-for-timezone($t1, "+0800")
let $s2 := adjust-datetime-for-timezone($dt1, "-0615")
-return { "string1" : $s1, "string2" : $s2 }
\ No newline at end of file
+return { "time" : $s1, "datetime" : $s2, "null1": adjust-time-for-timezone(null, "+0800"), "null2": adjust-time-for-timezone($t1, null), "null3": adjust-datetime-for-timezone(null, "-0800"), "null4": adjust-datetime-for-timezone($dt1, null) }
\ No newline at end of file
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 cbf4b7f..291d296 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
@@ -39,4 +39,4 @@
let $dtt8 := add-date-duration($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 }
+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 93e1366..b748429 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
@@ -1,17 +1,23 @@
use dataverse test;
let $d1 := date-from-unix-time-in-days(15600)
+let $null1 := date-from-unix-time-in-days(null)
let $dt1 := datetime("1327-12-02T23:35:49.938Z")
let $d2 := date-from-datetime($dt1)
+let $null2 := date-from-datetime(null)
let $dt2 := datetime("2012-10-11T02:30:23+03:00")
let $d3 := 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 $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)
-return { "date1" : $d1, "date2" : $d2, "date3" : $d3, "date4" : $d4, "date5" : $d5, "duration1" : $dr3, "duration2" : $dr4, "c1" : $c1, "c2" : $c2 }
\ No newline at end of file
+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 }
\ No newline at end of file
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 6f3dde3..ea6c2a8 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
@@ -1,11 +1,18 @@
use dataverse test;
let $dt1 := datetime-from-unix-time-in-ms(956007429)
+let $null1 := datetime-from-unix-time-in-ms(null)
let $d1 := date("1327-12-02")
let $t1 := time("15:35:49.938-0800")
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))
-return { "datetime1" : $dt1, "datetime2" : $dt2, "datetime3" : $dt3, "duration1" : $dr1, "c1" : $c1 }
+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/interval_functions/interval_functions.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_functions/interval_functions.3.query.aql
index 1c773bc..1eb5f53 100644
--- a/asterix-app/src/test/resources/runtimets/queries/temporal/interval_functions/interval_functions.3.query.aql
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/interval_functions/interval_functions.3.query.aql
@@ -46,4 +46,8 @@
let $blnEndedBy1 := interval-ended-by($itv7, $itv11)
let $blnEndedBy2 := interval-ended-by($itv8, $itv11)
-return { "before1" : $blnBefore1, "before2" : $blnBefore2, "after1" : $blnAfter1, "after2" : $blnAfter2, "meet1" : $blnMeet1, "meet2" : $blnMeet2, "metby1" : $blnMetBy1, "metby2" : $blnMetBy2, "overlaps1" : $blnOverlaps1, "overlaps2" : $blnOverlaps2, "overlapped1" : $blnOverlapped1, "overlapped2" : $blnOverlapped2, "overlap1" : $blnOverlap1, "overlap2" : $blnOverlap2, "starts1" : $blnStarts1, "starts2" : $blnStarts2, "startedby1" : $blnStartedBy1, "startedby2" : $blnStartedBy2, "covers1" : $blnCovers1, "covers2" : $blnCovers2, "coveredby1" : $blnCoveredBy1, "coveredby2" : $blnCoveredBy2, "ends1" : $blnEnds1, "ends2" : $blnEnds2, "endedby1" : $blnEndedBy1, "endedby2" : $blnEndedBy2 }
\ No newline at end of file
+let $null1 := interval-before(null, $itv2)
+let $null2 := interval-covered-by($itv11, null)
+let $null3 := overlap(null, null)
+
+return { "before1" : $blnBefore1, "before2" : $blnBefore2, "after1" : $blnAfter1, "after2" : $blnAfter2, "meet1" : $blnMeet1, "meet2" : $blnMeet2, "metby1" : $blnMetBy1, "metby2" : $blnMetBy2, "overlaps1" : $blnOverlaps1, "overlaps2" : $blnOverlaps2, "overlapped1" : $blnOverlapped1, "overlapped2" : $blnOverlapped2, "overlap1" : $blnOverlap1, "overlap2" : $blnOverlap2, "starts1" : $blnStarts1, "starts2" : $blnStarts2, "startedby1" : $blnStartedBy1, "startedby2" : $blnStartedBy2, "covers1" : $blnCovers1, "covers2" : $blnCovers2, "coveredby1" : $blnCoveredBy1, "coveredby2" : $blnCoveredBy2, "ends1" : $blnEnds1, "ends2" : $blnEnds2, "endedby1" : $blnEndedBy1, "endedby2" : $blnEndedBy2, "null1": $null1, "null2": $null2, "null3": $null3 }
\ No newline at end of file
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 ca25b8b..c042df0 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
@@ -1,20 +1,26 @@
use dataverse test;
let $t1 := time-from-unix-time-in-ms(1560074)
+let $null1 := time-from-unix-time-in-ms(null)
let $dt1 := datetime("1327-12-02T23:35:49.938Z")
let $t2 := time-from-datetime($dt1)
+let $null2 := time-from-datetime(null)
let $dt2 := datetime("2012-10-11T02:30:23+03:00")
let $t3 := 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 $ct := current-time()
let $cd := current-date()
let $cdt := current-datetime()
-return { "time1" : $t1, "time2" : $t2, "time3" : $t3, "time4" : $t4, "time5" : $t5, "duration1" : $dr3, "duration2" : $dr4, "c1" : $c1, "c2" : $c2 }
+return { "time1" : $t1, "time2" : $t2, "time3" : $t3, "time4" : $t4, "time5" : $t5, "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/results/constructor/interval/interval.1.adm b/asterix-app/src/test/resources/runtimets/results/constructor/interval/interval.1.adm
index 893c3ff..c99ade9 100644
--- a/asterix-app/src/test/resources/runtimets/results/constructor/interval/interval.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/constructor/interval/interval.1.adm
@@ -1 +1 @@
-{ "interval1": interval-date("2010-10-30, 2012-10-21"), "interval2": interval-time("14:04:05.678Z, 21:24:25.267Z"), "interval3": interval-datetime("-1987-11-18T18:43:57.938Z, 1999-11-12T19:49:35.948Z"), "interval4": interval-date("0001-12-27, 0006-01-27"), "interval5": interval-time("20:03:20.948Z, 20:57:50.886Z"), "interval6": interval-datetime("-2043-11-19T15:32:39.293Z, -1603-03-12T12:12:38.242Z") }
\ No newline at end of file
+{ "interval11": interval-date("2010-10-30, 2012-10-21"), "interval12": interval-date("2010-10-30, 2012-10-21"), "interval13": interval-date("2010-10-30, 2012-10-21"), "interval14": interval-date("2010-10-30, 2012-10-21"), "interval15": null, "interval16": null, "interval21": interval-time("14:04:05.678Z, 21:24:25.267Z"), "interval22": interval-time("14:04:05.678Z, 21:24:25.267Z"), "interval23": interval-time("14:04:05.678Z, 21:24:25.267Z"), "interval24": interval-time("14:04:05.678Z, 21:24:25.267Z"), "interval25": null, "interval26": null, "interval31": interval-datetime("-1987-11-18T18:43:57.938Z, 1999-11-12T19:49:35.948Z"), "interval32": interval-datetime("-1987-11-18T18:43:57.938Z, 1999-11-12T19:49:35.948Z"), "interval33": interval-datetime("-1987-11-18T18:43:57.938Z, 1999-11-12T19:49:35.948Z"), "interval34": interval-datetime("-1987-11-18T18:43:57.938Z, 1999-11-12T19:49:35.948Z"), "interval35": null, "interval36": null, "interval41": interval-date("0001-12-27, 0006-01-27"), "interval42": interval-date("0001-12-27, 0006-01-27"), "interval43": interval-date("0001-12-27, 0006-01-27"), "interval44": interval-date("0001-12-27, 0006-01-27"), "interval45": null, "interval46": null, "interval51": interval-time("20:03:20.948Z, 20:57:50.886Z"), "interval52": interval-time("20:03:20.948Z, 20:57:50.886Z"), "interval53": interval-time("20:03:20.948Z, 20:57:50.886Z"), "interval54": interval-time("20:03:20.948Z, 20:57:50.886Z"), "interval55": null, "interval56": null, "interval61": interval-datetime("-2043-11-19T15:32:39.293Z, -1603-03-12T12:12:38.242Z"), "interval62": interval-datetime("-2043-11-19T15:32:39.293Z, -1603-03-12T12:12:38.242Z"), "interval63": interval-datetime("-2043-11-19T15:32:39.293Z, -1603-03-12T12:12:38.242Z"), "interval64": interval-datetime("-2043-11-19T15:32:39.293Z, -1603-03-12T12:12:38.242Z"), "interval65": null, "interval66": null }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/accessors/accessors.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/accessors/accessors.1.adm
index 4f36f91..89e471a 100644
--- a/asterix-app/src/test/resources/runtimets/results/temporal/accessors/accessors.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/accessors/accessors.1.adm
@@ -1 +1 @@
-{ "year1": 2010, "year2": 1987, "year3": -1987, "year4": 928, "year5": 1937, "year6": -3, "year7": 9, "month1": 10, "month2": 11, "month3": 11, "month4": 3, "month5": 12, "month6": 1, "day1": 30, "day2": 19, "day3": 19, "day4": 29, "day5": 29, "day6": 634, "hour1": 23, "hour2": 20, "hour3": 5, "hour4": 14, "min1": 49, "min2": 3, "min3": 23, "min4": 28, "second1": 23, "second2": 6, "second3": 34, "second4": 48, "ms1": 938, "ms2": 280, "ms3": 930, "ms4": 94 }
\ No newline at end of file
+{ "year1": 2010, "year2": 1987, "year3": -1987, "year4": 928, "year5": 1937, "year6": -3, "year7": 9, "year-null": null, "month1": 10, "month2": 11, "month3": 11, "month4": 3, "month5": 12, "month6": 1, "month-null": null, "day1": 30, "day2": 19, "day3": 19, "day4": 29, "day5": 29, "day6": 634, "day-null": null, "hour1": 23, "hour2": 20, "hour3": 5, "hour4": 14, "hour-null": null, "min1": 49, "min2": 3, "min3": 23, "min4": 28, "min-null": null, "second1": 23, "second2": 6, "second3": 34, "second4": 48, "second-null": null, "ms1": 938, "ms2": 280, "ms3": 930, "ms4": 94, "ms-null": null }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/accessors_interval/accessors_interval.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/accessors_interval/accessors_interval.1.adm
new file mode 100644
index 0000000..df34c86
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/accessors_interval/accessors_interval.1.adm
@@ -0,0 +1 @@
+{ "start1": date("2010-10-30"), "end1": date("2013-04-01"), "start2": time("08:09:10.234Z"), "end2": time("12:30:40.567Z"), "start3": datetime("2009-08-31T16:00:00.000Z"), "end3": datetime("2013-04-04T16:00:00.000Z") }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/accessors_interval_null/accessors_interval_null.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/accessors_interval_null/accessors_interval_null.1.adm
new file mode 100644
index 0000000..7a50c5f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/accessors_interval_null/accessors_interval_null.1.adm
@@ -0,0 +1 @@
+{ "start-null-interval": null, "end-null-interval": null }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/adjust_timezone/adjust_timezone.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/adjust_timezone/adjust_timezone.1.adm
index 1f80fd9..c51cd50 100644
--- a/asterix-app/src/test/resources/runtimets/results/temporal/adjust_timezone/adjust_timezone.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/adjust_timezone/adjust_timezone.1.adm
@@ -1 +1 @@
-{ "string1": "04:15:10.327+08:00", "string2": "2010-10-22T18:57:13.329-06:15" }
\ No newline at end of file
+{ "time": "04:15:10.327+08:00", "datetime": "2010-10-22T18:57:13.329-06:15", "null1": null, "null2": null, "null3": null, "null4": null }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/calendar_duration/calendar_duration.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/calendar_duration/calendar_duration.1.adm
index 957388f..fd18463 100644
--- a/asterix-app/src/test/resources/runtimets/results/temporal/calendar_duration/calendar_duration.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/calendar_duration/calendar_duration.1.adm
@@ -1 +1 @@
-{ "cduration1": duration("P20Y3M12DT7H48M21.329S"), "c1": true, "cduration2": duration("-P9M6DT4H45M39.328S"), "c2": true, "cduration3": duration("P8Y6M"), "c3": true, "cduration4": duration("-P21Y7M10DT13H9M42.983S"), "c4": true, "cduration5": duration("P20Y3M12DT7H48M21.329S"), "c5": true, "cduration6": duration("-P9M5DT4H45M39.328S"), "c6": true, "cduration7": duration("P8Y6M"), "c7": true, "cduration8": duration("-P21Y7M10DT13H9M42.983S"), "c8": true }
\ No newline at end of file
+{ "cduration1": duration("P20Y3M12DT7H48M21.329S"), "c1": true, "cduration2": duration("-P9M6DT4H45M39.328S"), "c2": true, "cduration3": duration("P8Y6M"), "c3": true, "cduration4": duration("-P21Y7M10DT13H9M42.983S"), "c4": true, "cduration5": duration("P20Y3M12DT7H48M21.329S"), "c5": true, "cduration6": duration("-P9M5DT4H45M39.328S"), "c6": true, "cduration7": duration("P8Y6M"), "c7": true, "cduration8": duration("-P21Y7M10DT13H9M42.983S"), "c8": true, "cduration-null-1": null, "cduration-null-2": null, "cduration-null-3": null, "cduration-null-4": null }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/date_functions/date_functions.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/date_functions/date_functions.1.adm
index a5285d8..811d5e5 100644
--- a/asterix-app/src/test/resources/runtimets/results/temporal/date_functions/date_functions.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/date_functions/date_functions.1.adm
@@ -1 +1 @@
-{ "date1": date("2012-09-17"), "date2": date("1327-12-02"), "date3": date("2012-10-10"), "date4": date("2010-05-17"), "date5": date("1703-08-09"), "duration1": duration("P137216D"), "duration2": duration("-P854D"), "c1": true, "c2": true }
\ No newline at end of file
+{ "date1": date("2012-09-17"), "date2": date("1327-12-02"), "date3": date("2012-10-10"), "date4": date("2010-05-17"), "date5": date("1703-08-09"), "duration1": duration("P137216D"), "duration2": duration("-P854D"), "c1": true, "c2": true, "null1": null, "null2": null, "null3": null, "null4": null, "null5": null, "null6": null }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/datetime_functions/datetime_functions.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/datetime_functions/datetime_functions.1.adm
index 01f3758..4911179 100644
--- a/asterix-app/src/test/resources/runtimets/results/temporal/datetime_functions/datetime_functions.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/datetime_functions/datetime_functions.1.adm
@@ -1 +1 @@
-{ "datetime1": datetime("1970-01-12T01:33:27.429Z"), "datetime2": datetime("1327-12-02T23:35:49.938Z"), "datetime3": datetime("1327-12-02T23:35:49.938Z"), "duration1": duration("-P234526DT1H57M37.491S"), "c1": true }
\ No newline at end of file
+{ "datetime1": datetime("1970-01-12T01:33:27.429Z"), "datetime2": datetime("1327-12-02T23:35:49.938Z"), "datetime3": datetime("1327-12-02T23:35:49.938Z"), "duration1": duration("-P234526DT1H57M37.491S"), "c1": true, "null1": null, "null2": null, "null3": null, "null4": null, "null5": null, "null6": null, "null7": null }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/interval_functions/interval_functions.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/interval_functions/interval_functions.1.adm
index 9f9c9d3..0d86592 100644
--- a/asterix-app/src/test/resources/runtimets/results/temporal/interval_functions/interval_functions.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/interval_functions/interval_functions.1.adm
@@ -1 +1 @@
-{ "before1": true, "before2": false, "after1": true, "after2": false, "meet1": true, "meet2": false, "metby1": true, "metby2": false, "overlaps1": true, "overlaps2": false, "overlapped1": true, "overlapped2": false, "overlap1": true, "overlap2": false, "starts1": true, "starts2": false, "startedby1": true, "startedby2": false, "covers1": true, "covers2": false, "coveredby1": true, "coveredby2": false, "ends1": true, "ends2": false, "endedby1": true, "endedby2": false }
\ No newline at end of file
+{ "before1": true, "before2": false, "after1": true, "after2": false, "meet1": true, "meet2": false, "metby1": true, "metby2": false, "overlaps1": true, "overlaps2": false, "overlapped1": true, "overlapped2": false, "overlap1": true, "overlap2": false, "starts1": true, "starts2": false, "startedby1": true, "startedby2": false, "covers1": true, "covers2": false, "coveredby1": true, "coveredby2": false, "ends1": true, "ends2": false, "endedby1": true, "endedby2": false, "null1": null, "null2": null, "null3": null }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/time_functions/time_functions.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/time_functions/time_functions.1.adm
index 791d652..d98d702 100644
--- a/asterix-app/src/test/resources/runtimets/results/temporal/time_functions/time_functions.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/time_functions/time_functions.1.adm
@@ -1 +1 @@
-{ "time1": time("00:26:00.074Z"), "time2": time("23:35:49.938Z"), "time3": time("23:30:23.000Z"), "time4": time("18:26:00.074Z"), "time5": time("00:11:49.938Z"), "duration1": duration("-PT23H24M"), "duration2": duration("PT18H"), "c1": true, "c2": true }
\ No newline at end of file
+{ "time1": time("00:26:00.074Z"), "time2": time("23:35:49.938Z"), "time3": time("23:30:23.000Z"), "time4": time("18:26:00.074Z"), "time5": time("00:11:49.938Z"), "duration1": duration("-PT23H24M"), "duration2": duration("PT18H"), "c1": true, "c2": true, "null1": null, "null2": null, "null3": null, "null4": null, "null5": null, "null6": null }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index b730b41..980b900 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -4124,12 +4124,22 @@
</compilation-unit>
</test-case>
</test-group>
- <test-group name="temporal">
- <test-case FilePath="temporal">
- <compilation-unit name="accessors">
+ <test-group name="temporal">
+ <test-case FilePath="temporal">
+ <compilation-unit name="accessors">
<output-dir compare="Text">accessors</output-dir>
</compilation-unit>
- </test-case>
+ </test-case>
+ <test-case FilePath="temporal">
+ <compilation-unit name="accessors_interval">
+ <output-dir compare="Text">accessors_interval</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="temporal">
+ <compilation-unit name="accessors_interval_null">
+ <output-dir compare="Text">accessors_interval_null</output-dir>
+ </compilation-unit>
+ </test-case>
<test-case FilePath="temporal">
<compilation-unit name="adjust_timezone">
<output-dir compare="Text">adjust_timezone</output-dir>
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 24649d9..fa3179a 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
@@ -61,6 +61,7 @@
import edu.uci.ics.asterix.om.typecomputer.impl.OptionalAPolygonTypeComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.OptionalARectangleTypeComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.OptionalAStringTypeComputer;
+import edu.uci.ics.asterix.om.typecomputer.impl.OptionalATemporalInstanceTypeComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.OptionalATimeTypeComputer;
import edu.uci.ics.asterix.om.typecomputer.impl.OrderedListConstructorResultType;
import edu.uci.ics.asterix.om.typecomputer.impl.OrderedListOfAInt32TypeComputer;
@@ -459,6 +460,10 @@
"second", 1);
public static final FunctionIdentifier ACCESSOR_TEMPORAL_MILLISEC = new FunctionIdentifier(
FunctionConstants.ASTERIX_NS, "millisecond", 1);
+ public static final FunctionIdentifier ACCESSOR_TEMPORAL_INTERVAL_START = new FunctionIdentifier(
+ FunctionConstants.ASTERIX_NS, "get-interval-start", 1);
+ public static final FunctionIdentifier ACCESSOR_TEMPORAL_INTERVAL_END = new FunctionIdentifier(
+ FunctionConstants.ASTERIX_NS, "get-interval-end", 1);
// Temporal functions
public static final FunctionIdentifier DATE_FROM_UNIX_TIME_IN_DAYS = new FunctionIdentifier(
@@ -774,6 +779,8 @@
add(ACCESSOR_TEMPORAL_MIN, OptionalAInt32TypeComputer.INSTANCE);
add(ACCESSOR_TEMPORAL_SEC, OptionalAInt32TypeComputer.INSTANCE);
add(ACCESSOR_TEMPORAL_MILLISEC, OptionalAInt32TypeComputer.INSTANCE);
+ add(ACCESSOR_TEMPORAL_INTERVAL_START, OptionalATemporalInstanceTypeComputer.INSTANCE);
+ add(ACCESSOR_TEMPORAL_INTERVAL_END, OptionalATemporalInstanceTypeComputer.INSTANCE);
// temporal functions
add(DATE_FROM_UNIX_TIME_IN_DAYS, OptionalADateTypeComputer.INSTANCE);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalATemporalInstanceTypeComputer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalATemporalInstanceTypeComputer.java
new file mode 100644
index 0000000..eda385f
--- /dev/null
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/impl/OptionalATemporalInstanceTypeComputer.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.om.typecomputer.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer;
+import edu.uci.ics.asterix.om.types.AUnionType;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.IAType;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
+
+public class OptionalATemporalInstanceTypeComputer implements IResultTypeComputer {
+
+ public static final OptionalATemporalInstanceTypeComputer INSTANCE = new OptionalATemporalInstanceTypeComputer();
+
+ private OptionalATemporalInstanceTypeComputer() {
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer#computeType(edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression, edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment, edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider)
+ */
+ @Override
+ public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
+ IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ List<IAType> unionList = new ArrayList<IAType>();
+ unionList.add(BuiltinType.ANULL);
+ unionList.add(BuiltinType.ADATE);
+ unionList.add(BuiltinType.ATIME);
+ unionList.add(BuiltinType.ADATETIME);
+ return new AUnionType(unionList, "OptionalTemporalInstance");
+ }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalDayAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalDayAccessor.java
index 05391de..6b7a9d2 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalDayAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalDayAccessor.java
@@ -17,7 +17,6 @@
import java.io.DataOutput;
import java.io.IOException;
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
@@ -26,6 +25,7 @@
import edu.uci.ics.asterix.om.base.AMutableInt32;
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;
@@ -44,7 +44,7 @@
private static final long serialVersionUID = 1L;
- private static final FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "day", 1);
+ private static final FunctionIdentifier FID = AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_DAY;
// allowed input types
private static final byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalHourAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalHourAccessor.java
index eba012f..38e83db 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalHourAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalHourAccessor.java
@@ -17,7 +17,6 @@
import java.io.DataOutput;
import java.io.IOException;
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
@@ -26,6 +25,7 @@
import edu.uci.ics.asterix.om.base.AMutableInt32;
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;
@@ -44,7 +44,7 @@
private static final long serialVersionUID = 1L;
- private static final FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "hour", 1);
+ private static final FunctionIdentifier FID = AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_HOUR;
// allowed input types
private static final byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalEndAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalEndAccessor.java
new file mode 100644
index 0000000..e8ea6d5
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalEndAccessor.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.runtime.evaluators.accessors;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.ADate;
+import edu.uci.ics.asterix.om.base.ADateTime;
+import edu.uci.ics.asterix.om.base.AMutableDate;
+import edu.uci.ics.asterix.om.base.AMutableDateTime;
+import edu.uci.ics.asterix.om.base.AMutableTime;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.base.ATime;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.EnumDeserializer;
+import edu.uci.ics.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class TemporalIntervalEndAccessor extends AbstractScalarFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final FunctionIdentifier FID = AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_INTERVAL_END;
+
+ private static final byte SER_INTERVAL_TYPE_TAG = ATypeTag.INTERVAL.serialize();
+ private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+
+ private static final byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
+ private static final byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
+ private static final byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
+
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new TemporalIntervalEndAccessor();
+ }
+ };
+
+ public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+ return new ICopyEvaluatorFactory() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+ return new ICopyEvaluator() {
+
+ private DataOutput out = output.getDataOutput();
+
+ private ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+
+ private ICopyEvaluator eval = args[0].createEvaluator(argOut);
+
+ // possible output
+ @SuppressWarnings("unchecked")
+ private ISerializerDeserializer<ADate> dateSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ADATE);
+ private AMutableDate aDate = new AMutableDate(0);
+ @SuppressWarnings("unchecked")
+ private ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ADATETIME);
+ private AMutableDateTime aDateTime = new AMutableDateTime(0);
+ @SuppressWarnings("unchecked")
+ private ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ATIME);
+ private AMutableTime aTime = new AMutableTime(0);
+ @SuppressWarnings("unchecked")
+ private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ANULL);
+
+ @Override
+ public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+ argOut.reset();
+ eval.evaluate(tuple);
+ byte[] bytes = argOut.getByteArray();
+
+ try {
+ if (bytes[0] == SER_NULL_TYPE_TAG) {
+ nullSerde.serialize(ANull.NULL, out);
+ return;
+ } else if (bytes[0] == SER_INTERVAL_TYPE_TAG) {
+ byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes, 1);
+ long endTime = AIntervalSerializerDeserializer.getIntervalEnd(bytes, 1);
+ if (timeType == SER_DATE_TYPE_TAG) {
+ aDate.setValue((int) (endTime));
+ dateSerde.serialize(aDate, out);
+ } else if (timeType == SER_TIME_TYPE_TAG) {
+ aTime.setValue((int) (endTime));
+ timeSerde.serialize(aTime, out);
+ } else if (timeType == SER_DATETIME_TYPE_TAG) {
+ aDateTime.setValue(endTime);
+ datetimeSerde.serialize(aDateTime, out);
+ }
+ } else {
+ throw new AlgebricksException(FID.getName() + ": expects NULL/INTERVAL, but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]));
+ }
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
+ }
+ };
+ }
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+ */
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return FID;
+ }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalStartAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalStartAccessor.java
new file mode 100644
index 0000000..ef76934
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalIntervalStartAccessor.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.runtime.evaluators.accessors;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.ADate;
+import edu.uci.ics.asterix.om.base.ADateTime;
+import edu.uci.ics.asterix.om.base.AMutableDate;
+import edu.uci.ics.asterix.om.base.AMutableDateTime;
+import edu.uci.ics.asterix.om.base.AMutableTime;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.base.ATime;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.EnumDeserializer;
+import edu.uci.ics.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class TemporalIntervalStartAccessor extends AbstractScalarFunctionDynamicDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final FunctionIdentifier FID = AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_INTERVAL_START;
+
+ private static final byte SER_INTERVAL_TYPE_TAG = ATypeTag.INTERVAL.serialize();
+ private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+
+ private static final byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
+ private static final byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
+ private static final byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
+
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new TemporalIntervalStartAccessor();
+ }
+ };
+
+ public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+ return new ICopyEvaluatorFactory() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+ return new ICopyEvaluator() {
+
+ private DataOutput out = output.getDataOutput();
+
+ private ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
+
+ private ICopyEvaluator eval = args[0].createEvaluator(argOut);
+
+ // possible output
+ @SuppressWarnings("unchecked")
+ private ISerializerDeserializer<ADate> dateSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ADATE);
+ private AMutableDate aDate = new AMutableDate(0);
+ @SuppressWarnings("unchecked")
+ private ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ADATETIME);
+ private AMutableDateTime aDateTime = new AMutableDateTime(0);
+ @SuppressWarnings("unchecked")
+ private ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ATIME);
+ private AMutableTime aTime = new AMutableTime(0);
+ @SuppressWarnings("unchecked")
+ private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ANULL);
+
+ @Override
+ public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+ argOut.reset();
+ eval.evaluate(tuple);
+ byte[] bytes = argOut.getByteArray();
+
+ try {
+ if (bytes[0] == SER_NULL_TYPE_TAG) {
+ nullSerde.serialize(ANull.NULL, out);
+ return;
+ } else if (bytes[0] == SER_INTERVAL_TYPE_TAG) {
+ byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes, 1);
+ long startTime = AIntervalSerializerDeserializer.getIntervalStart(bytes, 1);
+ if (timeType == SER_DATE_TYPE_TAG) {
+ aDate.setValue((int) (startTime));
+ dateSerde.serialize(aDate, out);
+ } else if (timeType == SER_TIME_TYPE_TAG) {
+ aTime.setValue((int) (startTime));
+ timeSerde.serialize(aTime, out);
+ } else if (timeType == SER_DATETIME_TYPE_TAG) {
+ aDateTime.setValue(startTime);
+ datetimeSerde.serialize(aDateTime, out);
+ }
+ } else {
+ throw new AlgebricksException(FID.getName() + ": expects NULL/INTERVAL, but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]));
+ }
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
+ }
+ };
+ }
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+ */
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return FID;
+ }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java
index ecc1a35..0d6e99b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java
@@ -17,7 +17,6 @@
import java.io.DataOutput;
import java.io.IOException;
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
@@ -26,6 +25,7 @@
import edu.uci.ics.asterix.om.base.AMutableInt32;
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;
@@ -44,7 +44,7 @@
private static final long serialVersionUID = 1L;
- private static final FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "millisecond", 1);
+ private static final FunctionIdentifier FID = AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_MILLISEC;
// allowed input types
private static final byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java
index f436016..b61c843 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java
@@ -17,7 +17,6 @@
import java.io.DataOutput;
import java.io.IOException;
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
@@ -26,6 +25,7 @@
import edu.uci.ics.asterix.om.base.AMutableInt32;
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;
@@ -44,7 +44,7 @@
private static final long serialVersionUID = 1L;
- private static final FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "minute", 1);
+ private static final FunctionIdentifier FID = AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_MIN;
// allowed input types
private static final byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java
index fb68f7d..b18afe3 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java
@@ -17,7 +17,6 @@
import java.io.DataOutput;
import java.io.IOException;
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
@@ -26,6 +25,7 @@
import edu.uci.ics.asterix.om.base.AMutableInt32;
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;
@@ -44,7 +44,7 @@
private static final long serialVersionUID = 1L;
- private static final FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "month", 1);
+ private static final FunctionIdentifier FID = AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_MONTH;
// allowed input types
private static final byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java
index 3b9ee95..8a2f240 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java
@@ -17,7 +17,6 @@
import java.io.DataOutput;
import java.io.IOException;
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
@@ -26,6 +25,7 @@
import edu.uci.ics.asterix.om.base.AMutableInt32;
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;
@@ -44,7 +44,7 @@
private static final long serialVersionUID = 1L;
- private static final FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "second", 1);
+ private static final FunctionIdentifier FID = AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_SEC;
// allowed input types
private static final byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java
index 41dacfd..a940500 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java
@@ -17,7 +17,6 @@
import java.io.DataOutput;
import java.io.IOException;
-import edu.uci.ics.asterix.common.functions.FunctionConstants;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
@@ -26,6 +25,7 @@
import edu.uci.ics.asterix.om.base.AMutableInt32;
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;
@@ -45,7 +45,7 @@
private static final long serialVersionUID = 1L;
- private static final FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "year", 1);
+ private static final FunctionIdentifier FID = AsterixBuiltinFunctions.ACCESSOR_TEMPORAL_YEAR;
// allowed input types
private static final byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java
index 0414874..8daf9a6 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java
@@ -18,6 +18,7 @@
import java.io.IOException;
import edu.uci.ics.asterix.common.functions.FunctionConstants;
+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.AInterval;
import edu.uci.ics.asterix.om.base.AMutableInterval;
@@ -28,6 +29,7 @@
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;
@@ -45,6 +47,7 @@
"interval-from-date", 2);
private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+ private final static byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
public IFunctionDescriptor createFunctionDescriptor() {
@@ -90,34 +93,45 @@
if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
|| argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
nullSerde.serialize(ANull.NULL, out);
- } else if (argOut0.getByteArray()[0] == SER_STRING_TYPE_TAG
- && argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
+ return;
+ }
+ long intervalStart = 0, intervalEnd = 0;
+
+ if (argOut0.getByteArray()[0] == SER_DATE_TYPE_TAG) {
+ intervalStart = ADateSerializerDeserializer.getChronon(argOut0.getByteArray(), 1);
+ } else if (argOut0.getByteArray()[0] == SER_STRING_TYPE_TAG) {
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
-
- // start date
- long intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
+ intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
stringLength) / GregorianCalendarSystem.CHRONON_OF_DAY;
-
- // end date
- stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
- + (argOut1.getByteArray()[2] & 0xff << 0);
-
- long intervalEnd = ADateParserFactory.parseDatePart(argOut1.getByteArray(), 3,
- stringLength) / GregorianCalendarSystem.CHRONON_OF_DAY;
-
- if (intervalEnd < intervalStart) {
- throw new AlgebricksException(
- "Interval end must not be less than the interval start.");
- }
-
- aInterval.setValue(intervalStart, intervalEnd, ATypeTag.DATE.serialize());
- intervalSerde.serialize(aInterval, out);
} else {
- throw new AlgebricksException("Wrong format for interval constructor from dates.");
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/STRING/DATE for the first argument, but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
}
+ if (argOut1.getByteArray()[0] == SER_DATE_TYPE_TAG) {
+ intervalEnd = ADateSerializerDeserializer.getChronon(argOut1.getByteArray(), 1);
+ } else if (argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
+ int stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ + (argOut1.getByteArray()[2] & 0xff << 0);
+ intervalEnd = ADateParserFactory.parseDatePart(argOut1.getByteArray(), 3, stringLength)
+ / GregorianCalendarSystem.CHRONON_OF_DAY;
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/STRING/DATE for the second argument, but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
+ }
+
+ if (intervalEnd < intervalStart) {
+ throw new AlgebricksException(FID.getName()
+ + ": interval end must not be less than the interval start.");
+ }
+
+ aInterval.setValue(intervalStart, intervalEnd, ATypeTag.DATE.serialize());
+ intervalSerde.serialize(aInterval, out);
+
} catch (IOException e1) {
throw new AlgebricksException(errorMessage);
} catch (Exception e2) {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java
index 6b3e2b6..78d2e4a 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java
@@ -18,6 +18,7 @@
import java.io.IOException;
import edu.uci.ics.asterix.common.functions.FunctionConstants;
+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.AInterval;
import edu.uci.ics.asterix.om.base.AMutableInterval;
@@ -28,6 +29,7 @@
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;
@@ -45,6 +47,7 @@
"interval-from-datetime", 2);
private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+ private final static byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
public IFunctionDescriptor createFunctionDescriptor() {
@@ -67,7 +70,7 @@
private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
private ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
- private String errorMessage = "This can not be an instance of interval (from Date)";
+ private String errorMessage = "This can not be an instance of interval (from DateTime)";
//TODO: Where to move and fix these?
private AMutableInterval aInterval = new AMutableInterval(0L, 0L, (byte) 0);
@SuppressWarnings("unchecked")
@@ -90,12 +93,17 @@
if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
|| argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
nullSerde.serialize(ANull.NULL, out);
- } else if (argOut0.getByteArray()[0] == SER_STRING_TYPE_TAG
- && argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
+ return;
+ }
+
+ long intervalStart = 0, intervalEnd = 0;
+
+ if (argOut0.getByteArray()[0] == SER_DATETIME_TYPE_TAG) {
+ intervalStart = ADateTimeSerializerDeserializer.getChronon(argOut0.getByteArray(), 1);
+ } else if (argOut0.getByteArray()[0] == SER_STRING_TYPE_TAG) {
// start datetime
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
-
// get offset for time part: +1 if it is negative (-)
short timeOffset = (short) ((argOut0.getByteArray()[3] == '-') ? 1 : 0);
timeOffset += 8;
@@ -105,18 +113,23 @@
throw new AlgebricksException(errorMessage + ": missing T");
}
}
-
- long intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
- timeOffset);
+ intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3, timeOffset);
intervalStart += ATimeParserFactory.parseTimePart(argOut0.getByteArray(),
3 + timeOffset + 1, stringLength - timeOffset - 1);
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/STRING/DATETIME for the first argument, but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
+ }
- // end datetime
- stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ if (argOut1.getByteArray()[0] == SER_DATETIME_TYPE_TAG) {
+ intervalEnd = ADateTimeSerializerDeserializer.getChronon(argOut1.getByteArray(), 1);
+ } else if (argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
+ // start datetime
+ int stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
-
// get offset for time part: +1 if it is negative (-)
- timeOffset = (short) ((argOut1.getByteArray()[3] == '-') ? 1 : 0);
+ short timeOffset = (short) ((argOut1.getByteArray()[3] == '-') ? 1 : 0);
timeOffset += 8;
if (argOut1.getByteArray()[3 + timeOffset] != 'T') {
timeOffset += 2;
@@ -124,22 +137,22 @@
throw new AlgebricksException(errorMessage + ": missing T");
}
}
-
- long intervalEnd = ADateParserFactory.parseDatePart(argOut1.getByteArray(), 3,
- timeOffset);
+ intervalEnd = ADateParserFactory.parseDatePart(argOut1.getByteArray(), 3, timeOffset);
intervalEnd += ATimeParserFactory.parseTimePart(argOut1.getByteArray(),
3 + timeOffset + 1, stringLength - timeOffset - 1);
-
- if (intervalEnd < intervalStart) {
- throw new AlgebricksException(
- "Interval end must not be less than the interval start.");
- }
-
- aInterval.setValue(intervalStart, intervalEnd, ATypeTag.DATETIME.serialize());
- intervalSerde.serialize(aInterval, out);
} else {
- throw new AlgebricksException("Wrong format for interval constructor from dates.");
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/STRING/DATETIME for the second argument, but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
}
+
+ if (intervalEnd < intervalStart) {
+ throw new AlgebricksException(FID.getName()
+ + ": interval end must not be less than the interval start.");
+ }
+
+ aInterval.setValue(intervalStart, intervalEnd, ATypeTag.DATETIME.serialize());
+ intervalSerde.serialize(aInterval, out);
} catch (IOException e1) {
throw new AlgebricksException(errorMessage);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java
index 042a33b..8816160 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java
@@ -18,6 +18,7 @@
import java.io.IOException;
import edu.uci.ics.asterix.common.functions.FunctionConstants;
+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.AInterval;
import edu.uci.ics.asterix.om.base.AMutableInterval;
@@ -28,6 +29,7 @@
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;
@@ -45,6 +47,7 @@
"interval-from-time", 2);
private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+ private final static byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
public IFunctionDescriptor createFunctionDescriptor() {
@@ -90,39 +93,57 @@
if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
|| argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
nullSerde.serialize(ANull.NULL, out);
- } else if (argOut0.getByteArray()[0] == SER_STRING_TYPE_TAG
- && argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
+ return;
+ }
+
+ long intervalStart = 0, intervalEnd = 0;
+
+ if (argOut0.getByteArray()[0] == SER_TIME_TYPE_TAG) {
+ intervalStart = ATimeSerializerDeserializer.getChronon(argOut0.getByteArray(), 1);
+ } else if (argOut0.getByteArray()[0] == SER_STRING_TYPE_TAG) {
// start date
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
- long intervalStart = ATimeParserFactory.parseTimePart(argOut0.getByteArray(), 3,
+ intervalStart = ATimeParserFactory.parseTimePart(argOut0.getByteArray(), 3,
stringLength);
- if (intervalStart < 0) {
- intervalStart += GregorianCalendarSystem.CHRONON_OF_DAY;
- }
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/STRING/TIME for the first argument, but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
+ }
- // end date
- stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ if (intervalStart < 0) {
+ intervalStart += GregorianCalendarSystem.CHRONON_OF_DAY;
+ }
+
+ if (argOut1.getByteArray()[0] == SER_TIME_TYPE_TAG) {
+ intervalEnd = ATimeSerializerDeserializer.getChronon(argOut1.getByteArray(), 1);
+ } else if (argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
+ // start date
+ int stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
- long intervalEnd = ATimeParserFactory.parseTimePart(argOut1.getByteArray(), 3,
- stringLength);
- if (intervalEnd < 0) {
- intervalEnd += GregorianCalendarSystem.CHRONON_OF_DAY;
- }
+ intervalEnd = ATimeParserFactory.parseTimePart(argOut1.getByteArray(), 3, stringLength);
- if (intervalEnd < intervalStart) {
- throw new AlgebricksException(
- "Interval end must not be less than the interval start.");
- }
-
- aInterval.setValue(intervalStart, intervalEnd, ATypeTag.TIME.serialize());
- intervalSerde.serialize(aInterval, out);
} else {
- throw new AlgebricksException("Wrong format for interval constructor from dates.");
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/STRING/TIME for the second argument, but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
}
+ if (intervalEnd < 0) {
+ intervalEnd += GregorianCalendarSystem.CHRONON_OF_DAY;
+ }
+
+ if (intervalEnd < intervalStart) {
+ throw new AlgebricksException(FID.getName()
+ + ": interval end must not be less than the interval start.");
+ }
+
+ aInterval.setValue(intervalStart, intervalEnd, ATypeTag.TIME.serialize());
+ intervalSerde.serialize(aInterval, out);
+
} catch (IOException e1) {
throw new AlgebricksException(errorMessage);
} catch (Exception e2) {
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 d5a0db9..7ea8e90 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
@@ -18,6 +18,8 @@
import java.io.IOException;
import edu.uci.ics.asterix.common.functions.FunctionConstants;
+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.AInterval;
import edu.uci.ics.asterix.om.base.AMutableDuration;
@@ -31,6 +33,7 @@
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;
@@ -48,6 +51,8 @@
"interval-start-from-date", 2);
private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
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 static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
public IFunctionDescriptor createFunctionDescriptor() {
@@ -94,40 +99,56 @@
if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
|| argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
nullSerde.serialize(ANull.NULL, out);
- } else if (argOut0.getByteArray()[0] == SER_STRING_TYPE_TAG
- && argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
+ return;
+ }
+ long intervalStart = 0, intervalEnd = 0;
+
+ if (argOut0.getByteArray()[0] == SER_DATE_TYPE_TAG) {
+ intervalStart = ADateSerializerDeserializer.getChronon(argOut0.getByteArray(), 1)
+ * GregorianCalendarSystem.CHRONON_OF_DAY;
+ } else if (argOut0.getByteArray()[0] == SER_STRING_TYPE_TAG) {
// start date
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
-
- long intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
+ intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
stringLength);
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/STRING/DATE for the first argument, but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
+ }
+ if (argOut1.getByteArray()[0] == SER_DURATION_TYPE_TAG) {
+ intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
+ ADurationSerializerDeserializer.getYearMonth(argOut1.getByteArray(), 1),
+ ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1));
+ } else if (argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
// duration
- stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ int stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
ADurationParserFactory
.parseDuration(argOut1.getByteArray(), 3, stringLength, aDuration);
-
- long intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
+ intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
aDuration.getMonths(), aDuration.getMilliseconds());
-
- intervalStart = GregorianCalendarSystem.getChrononInDays(intervalStart);
- intervalEnd = GregorianCalendarSystem.getChrononInDays(intervalEnd);
-
- if (intervalEnd < intervalStart) {
- throw new AlgebricksException(
- "Interval end must not be less than the interval start.");
- }
-
- aInterval.setValue(intervalStart, intervalEnd, ATypeTag.DATE.serialize());
- intervalSerde.serialize(aInterval, out);
} else {
- throw new AlgebricksException("Wrong format for interval constructor from dates.");
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/STRING/DURATION for the second argument, but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
}
+ intervalStart = GregorianCalendarSystem.getChrononInDays(intervalStart);
+ intervalEnd = GregorianCalendarSystem.getChrononInDays(intervalEnd);
+
+ if (intervalEnd < intervalStart) {
+ throw new AlgebricksException(FID.getName()
+ + ": interval end must not be less than the interval start.");
+ }
+
+ aInterval.setValue(intervalStart, intervalEnd, ATypeTag.DATE.serialize());
+ intervalSerde.serialize(aInterval, out);
+
} catch (IOException e1) {
throw new AlgebricksException(errorMessage);
} catch (Exception e2) {
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 d821fc3..f16dccb 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
@@ -18,6 +18,8 @@
import java.io.IOException;
import edu.uci.ics.asterix.common.functions.FunctionConstants;
+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.AInterval;
import edu.uci.ics.asterix.om.base.AMutableDuration;
@@ -31,6 +33,7 @@
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;
@@ -48,6 +51,8 @@
"interval-start-from-datetime", 2);
private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
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 static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
public IFunctionDescriptor createFunctionDescriptor() {
@@ -94,10 +99,14 @@
if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
|| argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
nullSerde.serialize(ANull.NULL, out);
- } else if (argOut0.getByteArray()[0] == SER_STRING_TYPE_TAG
- && argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
- // start date
+ return;
+ }
+ long intervalStart = 0, intervalEnd = 0;
+
+ if (argOut0.getByteArray()[0] == SER_DATETIME_TYPE_TAG) {
+ intervalStart = ADateTimeSerializerDeserializer.getChronon(argOut0.getByteArray(), 1);
+ } else if (argOut0.getByteArray()[0] == SER_STRING_TYPE_TAG) {
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
@@ -113,32 +122,44 @@
}
}
- long intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
- timeOffset);
+ intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3, timeOffset);
intervalStart += ATimeParserFactory.parseTimePart(argOut0.getByteArray(),
3 + timeOffset + 1, stringLength - timeOffset - 1);
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/STRING/DATETIME for the first argument but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
+ }
+
+ if (argOut1.getByteArray()[0] == SER_DURATION_TYPE_TAG) {
+ intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
+ ADurationSerializerDeserializer.getYearMonth(argOut1.getByteArray(), 1),
+ ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1));
+ } else if (argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
// duration
- stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ int stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
ADurationParserFactory
.parseDuration(argOut1.getByteArray(), 3, stringLength, aDuration);
- long intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
+ intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
aDuration.getMonths(), aDuration.getMilliseconds());
-
- if (intervalEnd < intervalStart) {
- throw new AlgebricksException(
- "Interval end must not be less than the interval start.");
- }
-
- aInterval.setValue(intervalStart, intervalEnd, ATypeTag.DATETIME.serialize());
- intervalSerde.serialize(aInterval, out);
} else {
- throw new AlgebricksException("Wrong format for interval constructor from dates.");
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/STRING/DURATION for the second argument but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
}
+ if (intervalEnd < intervalStart) {
+ throw new AlgebricksException(FID.getName()
+ + ": interval end must not be less than the interval start.");
+ }
+
+ aInterval.setValue(intervalStart, intervalEnd, ATypeTag.DATETIME.serialize());
+ intervalSerde.serialize(aInterval, out);
+
} catch (IOException e1) {
throw new AlgebricksException(errorMessage);
} catch (Exception e2) {
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 8135598..35bfe17 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
@@ -18,6 +18,8 @@
import java.io.IOException;
import edu.uci.ics.asterix.common.functions.FunctionConstants;
+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.AInterval;
import edu.uci.ics.asterix.om.base.AMutableDuration;
@@ -31,6 +33,7 @@
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;
@@ -48,6 +51,8 @@
"interval-start-from-time", 2);
private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
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 static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
public IFunctionDescriptor createFunctionDescriptor() {
@@ -94,51 +99,71 @@
if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
|| argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
nullSerde.serialize(ANull.NULL, out);
- } else if (argOut0.getByteArray()[0] == SER_STRING_TYPE_TAG
- && argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
- // start time
+ return;
+ }
+ long intervalStart = 0, intervalEnd = 0;
+
+ if (argOut0.getByteArray()[0] == SER_TIME_TYPE_TAG) {
+ intervalStart = ATimeSerializerDeserializer.getChronon(argOut0.getByteArray(), 1);
+ } else if (argOut0.getByteArray()[0] == SER_STRING_TYPE_TAG) {
int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
+ (argOut0.getByteArray()[2] & 0xff << 0);
- int intervalStart = ATimeParserFactory.parseTimePart(argOut0.getByteArray(), 3,
+ intervalStart = ATimeParserFactory.parseTimePart(argOut0.getByteArray(), 3,
stringLength);
+ } else {
+ throw new AlgebricksException(FID.getName()
+ + ": expects NULL/STRING/TIME for the first argument, but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
+ }
- if (intervalStart < 0) {
- intervalStart += GregorianCalendarSystem.CHRONON_OF_DAY;
+ if (intervalStart < 0) {
+ intervalStart += GregorianCalendarSystem.CHRONON_OF_DAY;
+ }
+
+ if (argOut1.getByteArray()[0] == SER_DURATION_TYPE_TAG) {
+
+ if (ADurationSerializerDeserializer.getYearMonth(argOut1.getByteArray(), 1) != 0) {
+ throw new AlgebricksException(FID.getName()
+ + ": cannot add a year-month duration to a time value.");
}
+ intervalEnd = DurationArithmeticOperations.addDuration(intervalStart, 0,
+ ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1));
+
+ } else if (argOut1.getByteArray()[0] == SER_STRING_TYPE_TAG) {
// duration
- stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ int stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
+ (argOut1.getByteArray()[2] & 0xff << 0);
ADurationParserFactory
.parseDuration(argOut1.getByteArray(), 3, stringLength, aDuration);
if (aDuration.getMonths() != 0) {
- throw new AlgebricksException("Cannot add a year-month duration to a time value.");
+ throw new AlgebricksException(FID.getName()
+ + ": cannot add a year-month duration to a time value.");
}
- int intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
+ intervalEnd = DurationArithmeticOperations.addDuration(intervalStart, 0,
aDuration.getMilliseconds());
-
- if (intervalEnd > GregorianCalendarSystem.CHRONON_OF_DAY) {
-
- intervalEnd = intervalEnd - (int) (GregorianCalendarSystem.CHRONON_OF_DAY);
- }
-
- if (intervalEnd < intervalStart) {
- throw new AlgebricksException(
- "Interval end must not be less than the interval start.");
- }
-
- aInterval.setValue(intervalStart, intervalEnd, ATypeTag.TIME.serialize());
- intervalSerde.serialize(aInterval, out);
} else {
throw new AlgebricksException("Wrong format for interval constructor from dates.");
}
+ if (intervalEnd > GregorianCalendarSystem.CHRONON_OF_DAY) {
+ intervalEnd = intervalEnd % (int) (GregorianCalendarSystem.CHRONON_OF_DAY);
+ }
+
+ if (intervalEnd < intervalStart) {
+ throw new AlgebricksException(FID.getName()
+ + ": interval end must not be less than the interval start.");
+ }
+
+ aInterval.setValue(intervalStart, intervalEnd, ATypeTag.TIME.serialize());
+ intervalSerde.serialize(aInterval, out);
+
} catch (IOException e1) {
throw new AlgebricksException(errorMessage);
} catch (Exception e2) {
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 f12ea91..a61208d 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
@@ -69,6 +69,8 @@
import edu.uci.ics.asterix.runtime.aggregates.stream.NonEmptyStreamAggregateDescriptor;
import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalDayAccessor;
import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalHourAccessor;
+import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalIntervalEndAccessor;
+import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalIntervalStartAccessor;
import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalMillisecondAccessor;
import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalMinuteAccessor;
import edu.uci.ics.asterix.runtime.evaluators.accessors.TemporalMonthAccessor;
@@ -464,6 +466,8 @@
temp.add(TemporalMinuteAccessor.FACTORY);
temp.add(TemporalSecondAccessor.FACTORY);
temp.add(TemporalMillisecondAccessor.FACTORY);
+ temp.add(TemporalIntervalStartAccessor.FACTORY);
+ temp.add(TemporalIntervalEndAccessor.FACTORY);
// Temporal functions
temp.add(DateFromUnixTimeInDaysDescriptor.FACTORY);