asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amo...@apache.org
Subject [03/13] incubator-asterixdb git commit: Add Support for Upsert Operation
Date Mon, 01 Feb 2016 08:31:22 GMT
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
index 424d46b..d8d76b6 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
@@ -48,12 +48,6 @@ public class AdjustDateTimeForTimeZoneDescriptor extends AbstractScalarFunctionD
 
     private final static long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = AsterixBuiltinFunctions.ADJUST_DATETIME_FOR_TIMEZONE;
-
-    // allowed input types
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
-    private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
-
     public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
 
         @Override
@@ -99,27 +93,27 @@ public class AdjustDateTimeForTimeZoneDescriptor extends AbstractScalarFunctionD
                         eval1.evaluate(tuple);
 
                         try {
-                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
-                                    || argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                                    || argOut1.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != SER_DATETIME_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
                                 throw new AlgebricksException(FID.getName()
                                         + ": expects type DATETIME/NULL for parameter 0 but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
                             }
 
-                            if (argOut1.getByteArray()[0] != SER_STRING_TYPE_TAG) {
+                            if (argOut1.getByteArray()[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
                                 throw new AlgebricksException(FID.getName()
                                         + ": expects type STRING/NULL for parameter 1 but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
                             }
 
                             utf8Ptr.set(argOut1.getByteArray(), 1, argOut1.getLength() - 1);
-                            int timezone = ATimeParserFactory
-                                    .parseTimezonePart(utf8Ptr.getByteArray(), utf8Ptr.getCharStartOffset());
+                            int timezone = ATimeParserFactory.parseTimezonePart(utf8Ptr.getByteArray(),
+                                    utf8Ptr.getCharStartOffset());
 
                             if (!calInstance.validateTimeZone(timezone)) {
                                 throw new AlgebricksException(FID.getName() + ": wrong format for a time zone string!");
@@ -134,7 +128,7 @@ public class AdjustDateTimeForTimeZoneDescriptor extends AbstractScalarFunctionD
                             calInstance.getExtendStringRepUntilField(chronon, timezone, sbder, Fields.YEAR,
                                     Fields.MILLISECOND, true);
 
-                            out.writeByte(SER_STRING_TYPE_TAG);
+                            out.writeByte(ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                             utf8Writer.writeUTF8(sbder.toString(), out);
                         } catch (Exception e1) {
                             throw new AlgebricksException(e1);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
index 32e16e4..527607e 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
@@ -45,15 +45,8 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 import org.apache.hyracks.util.string.UTF8StringWriter;
 
 public class AdjustTimeForTimeZoneDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private final static long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = AsterixBuiltinFunctions.ADJUST_TIME_FOR_TIMEZONE;
-
-    // allowed input types
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
-    private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
-
     public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
 
         @Override
@@ -98,27 +91,27 @@ public class AdjustTimeForTimeZoneDescriptor extends AbstractScalarFunctionDynam
                         eval1.evaluate(tuple);
 
                         try {
-                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
-                                    || argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                                    || argOut1.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != SER_TIME_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
                                 throw new AlgebricksException(FID.getName()
                                         + ": expects type TIME/NULL for parameter 0 but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
                             }
 
-                            if (argOut1.getByteArray()[0] != SER_STRING_TYPE_TAG) {
+                            if (argOut1.getByteArray()[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
                                 throw new AlgebricksException(FID.getName()
                                         + ": expects type STRING/NULL for parameter 1 but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
                             }
 
                             utf8Ptr.set(argOut1.getByteArray(), 1, argOut1.getLength() - 1);
-                            int timezone = ATimeParserFactory
-                                    .parseTimezonePart(argOut1.getByteArray(), utf8Ptr.getCharStartOffset());
+                            int timezone = ATimeParserFactory.parseTimezonePart(argOut1.getByteArray(),
+                                    utf8Ptr.getCharStartOffset());
 
                             if (!calInstance.validateTimeZone(timezone)) {
                                 throw new AlgebricksException(FID.getName() + ": wrong format for a time zone string!");
@@ -133,7 +126,7 @@ public class AdjustTimeForTimeZoneDescriptor extends AbstractScalarFunctionDynam
                             calInstance.getExtendStringRepUntilField(chronon, timezone, sbder, Fields.HOUR,
                                     Fields.MILLISECOND, true);
 
-                            out.writeByte(SER_STRING_TYPE_TAG);
+                            out.writeByte(ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                             writer.writeUTF8(sbder.toString(), out);
 
                         } catch (Exception e1) {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java
index d161927..5678827 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java
@@ -46,15 +46,8 @@ import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public class CalendarDuartionFromDateDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private final static long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = AsterixBuiltinFunctions.CALENDAR_DURATION_FROM_DATE;
-
-    // allowed input types
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
-    private final static byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
-
     public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
 
         @Override
@@ -104,28 +97,28 @@ public class CalendarDuartionFromDateDescriptor extends AbstractScalarFunctionDy
                         eval1.evaluate(tuple);
 
                         try {
-                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
-                                    || argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                                    || argOut1.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != SER_DATE_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
                                 throw new AlgebricksException(FID.getName()
                                         + ": expects type DATE/NULL for parameter 0 but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
                             }
 
-                            if (argOut1.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
+                            if (argOut1.getByteArray()[0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
                                 throw new AlgebricksException(FID.getName()
                                         + ": expects type DURATION/NULL for parameter 1 but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
                             }
 
-                            int yearMonthDurationInMonths = ADurationSerializerDeserializer.getYearMonth(
-                                    argOut1.getByteArray(), 1);
-                            long dayTimeDurationInMs = ADurationSerializerDeserializer.getDayTime(
-                                    argOut1.getByteArray(), 1);
+                            int yearMonthDurationInMonths = ADurationSerializerDeserializer
+                                    .getYearMonth(argOut1.getByteArray(), 1);
+                            long dayTimeDurationInMs = ADurationSerializerDeserializer
+                                    .getDayTime(argOut1.getByteArray(), 1);
 
                             long startingTimePoint = ADateSerializerDeserializer.getChronon(argOut0.getByteArray(), 1)
                                     * GregorianCalendarSystem.CHRONON_OF_DAY;
@@ -192,7 +185,8 @@ public class CalendarDuartionFromDateDescriptor extends AbstractScalarFunctionDy
                                 if (day < 0) {
                                     boolean isLeapYear = calInstanct.isLeapYear(year1);
                                     // need to "borrow" the days in previous month to make the day positive; when month is 1 (Jan), Dec will be borrowed
-                                    day += (isLeapYear) ? (GregorianCalendarSystem.DAYS_OF_MONTH_LEAP[(12 + month1 - 2) % 12])
+                                    day += (isLeapYear)
+                                            ? (GregorianCalendarSystem.DAYS_OF_MONTH_LEAP[(12 + month1 - 2) % 12])
                                             : (GregorianCalendarSystem.DAYS_OF_MONTH_ORDI[(12 + month1 - 2) % 12]);
                                     month -= 1;
                                 }
@@ -204,17 +198,16 @@ public class CalendarDuartionFromDateDescriptor extends AbstractScalarFunctionDy
 
                                 if (negative) {
                                     aDuration.setValue(-1 * (year * GregorianCalendarSystem.MONTHS_IN_A_YEAR + month),
-                                            -1
-                                                    * (day * GregorianCalendarSystem.CHRONON_OF_DAY + hour
-                                                            * GregorianCalendarSystem.CHRONON_OF_HOUR + min
-                                                            * GregorianCalendarSystem.CHRONON_OF_MINUTE + sec
-                                                            * GregorianCalendarSystem.CHRONON_OF_SECOND + ms));
+                                            -1 * (day * GregorianCalendarSystem.CHRONON_OF_DAY
+                                                    + hour * GregorianCalendarSystem.CHRONON_OF_HOUR
+                                                    + min * GregorianCalendarSystem.CHRONON_OF_MINUTE
+                                                    + sec * GregorianCalendarSystem.CHRONON_OF_SECOND + ms));
                                 } else {
-                                    aDuration.setValue(year * GregorianCalendarSystem.MONTHS_IN_A_YEAR + month, day
-                                            * GregorianCalendarSystem.CHRONON_OF_DAY + hour
-                                            * GregorianCalendarSystem.CHRONON_OF_HOUR + min
-                                            * GregorianCalendarSystem.CHRONON_OF_MINUTE + sec
-                                            * GregorianCalendarSystem.CHRONON_OF_SECOND + ms);
+                                    aDuration.setValue(year * GregorianCalendarSystem.MONTHS_IN_A_YEAR + month,
+                                            day * GregorianCalendarSystem.CHRONON_OF_DAY
+                                                    + hour * GregorianCalendarSystem.CHRONON_OF_HOUR
+                                                    + min * GregorianCalendarSystem.CHRONON_OF_MINUTE
+                                                    + sec * GregorianCalendarSystem.CHRONON_OF_SECOND + ms);
                                 }
                             }
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java
index 54f80b3..037df2e 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java
@@ -62,15 +62,8 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
  * <p/>
  */
 public class CalendarDurationFromDateTimeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private final static long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = AsterixBuiltinFunctions.CALENDAR_DURATION_FROM_DATETIME;
-
-    // allowed input types
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
-    private final static byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
-
     public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
 
         @Override
@@ -118,28 +111,28 @@ public class CalendarDurationFromDateTimeDescriptor extends AbstractScalarFuncti
                         eval1.evaluate(tuple);
 
                         try {
-                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
-                                    || argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                                    || argOut1.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != SER_DATETIME_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
                                 throw new AlgebricksException(FID.getName()
                                         + ": expects type DATETIME/NULL for parameter 0 but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
                             }
 
-                            if (argOut1.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
+                            if (argOut1.getByteArray()[0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
                                 throw new AlgebricksException(FID.getName()
                                         + ": expects type DURATION/NULL for parameter 1 but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
                             }
 
-                            int yearMonthDurationInMonths = ADurationSerializerDeserializer.getYearMonth(
-                                    argOut1.getByteArray(), 1);
-                            long dayTimeDurationInMs = ADurationSerializerDeserializer.getDayTime(
-                                    argOut1.getByteArray(), 1);
+                            int yearMonthDurationInMonths = ADurationSerializerDeserializer
+                                    .getYearMonth(argOut1.getByteArray(), 1);
+                            long dayTimeDurationInMs = ADurationSerializerDeserializer
+                                    .getDayTime(argOut1.getByteArray(), 1);
 
                             long startingTimePoint = ADateTimeSerializerDeserializer.getChronon(argOut0.getByteArray(),
                                     1);
@@ -206,7 +199,8 @@ public class CalendarDurationFromDateTimeDescriptor extends AbstractScalarFuncti
                                 if (day < 0) {
                                     boolean isLeapYear = calInstanct.isLeapYear(year1);
                                     // need to "borrow" the days in previous month to make the day positive; when month is 1 (Jan), Dec will be borrowed
-                                    day += (isLeapYear) ? (GregorianCalendarSystem.DAYS_OF_MONTH_LEAP[(12 + month1 - 2) % 12])
+                                    day += (isLeapYear)
+                                            ? (GregorianCalendarSystem.DAYS_OF_MONTH_LEAP[(12 + month1 - 2) % 12])
                                             : (GregorianCalendarSystem.DAYS_OF_MONTH_ORDI[(12 + month1 - 2) % 12]);
                                     month -= 1;
                                 }
@@ -218,17 +212,16 @@ public class CalendarDurationFromDateTimeDescriptor extends AbstractScalarFuncti
 
                                 if (negative) {
                                     aDuration.setValue(-1 * (year * GregorianCalendarSystem.MONTHS_IN_A_YEAR + month),
-                                            -1
-                                                    * (day * GregorianCalendarSystem.CHRONON_OF_DAY + hour
-                                                            * GregorianCalendarSystem.CHRONON_OF_HOUR + min
-                                                            * GregorianCalendarSystem.CHRONON_OF_MINUTE + sec
-                                                            * GregorianCalendarSystem.CHRONON_OF_SECOND + ms));
+                                            -1 * (day * GregorianCalendarSystem.CHRONON_OF_DAY
+                                                    + hour * GregorianCalendarSystem.CHRONON_OF_HOUR
+                                                    + min * GregorianCalendarSystem.CHRONON_OF_MINUTE
+                                                    + sec * GregorianCalendarSystem.CHRONON_OF_SECOND + ms));
                                 } else {
-                                    aDuration.setValue(year * GregorianCalendarSystem.MONTHS_IN_A_YEAR + month, day
-                                            * GregorianCalendarSystem.CHRONON_OF_DAY + hour
-                                            * GregorianCalendarSystem.CHRONON_OF_HOUR + min
-                                            * GregorianCalendarSystem.CHRONON_OF_MINUTE + sec
-                                            * GregorianCalendarSystem.CHRONON_OF_SECOND + ms);
+                                    aDuration.setValue(year * GregorianCalendarSystem.MONTHS_IN_A_YEAR + month,
+                                            day * GregorianCalendarSystem.CHRONON_OF_DAY
+                                                    + hour * GregorianCalendarSystem.CHRONON_OF_HOUR
+                                                    + min * GregorianCalendarSystem.CHRONON_OF_MINUTE
+                                                    + sec * GregorianCalendarSystem.CHRONON_OF_SECOND + ms);
                                 }
                             }
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java
index c7f2d65..5927620 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java
@@ -44,14 +44,8 @@ import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public class DateFromDatetimeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = AsterixBuiltinFunctions.DATE_FROM_DATETIME;
-
-    // allowed input types
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
-
     public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
 
         @Override
@@ -90,19 +84,19 @@ public class DateFromDatetimeDescriptor extends AbstractScalarFunctionDynamicDes
                         argOut.reset();
                         eval.evaluate(tuple);
                         try {
-                            if (argOut.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                             } else {
-                                if (argOut.getByteArray()[0] != SER_DATETIME_TYPE_TAG) {
+                                if (argOut.getByteArray()[0] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
                                     throw new AlgebricksException(
-                                            FID.getName()
-                                                    + ": expects input type DATETIME/NULL but got "
-                                                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut
-                                                            .getByteArray()[0]));
+                                            FID.getName() + ": expects input type DATETIME/NULL but got "
+                                                    + EnumDeserializer.ATYPETAGDESERIALIZER
+                                                            .deserialize(argOut.getByteArray()[0]));
                                 }
-                                long datetimeChronon = ADateTimeSerializerDeserializer.getChronon(
-                                        argOut.getByteArray(), 1);
-                                int dateChrononInDays = (int) (datetimeChronon / GregorianCalendarSystem.CHRONON_OF_DAY);
+                                long datetimeChronon = ADateTimeSerializerDeserializer.getChronon(argOut.getByteArray(),
+                                        1);
+                                int dateChrononInDays = (int) (datetimeChronon
+                                        / GregorianCalendarSystem.CHRONON_OF_DAY);
                                 if (dateChrononInDays < 0
                                         && datetimeChronon % GregorianCalendarSystem.CHRONON_OF_DAY != 0) {
                                     dateChrononInDays -= 1;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java
index 8a82902..d96ffe9 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java
@@ -45,10 +45,6 @@ public class DateFromUnixTimeInDaysDescriptor extends AbstractScalarFunctionDyna
 
     private final static long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = AsterixBuiltinFunctions.DATE_FROM_UNIX_TIME_IN_DAYS;
-
-    // allowed input types
-    private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-
     public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
 
         @Override
@@ -86,7 +82,7 @@ public class DateFromUnixTimeInDaysDescriptor extends AbstractScalarFunctionDyna
                         argOut.reset();
                         eval.evaluate(tuple);
                         try {
-                            if (argOut.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                             } else {
                                 aDate.setValue(ATypeHierarchy.getIntegerValue(argOut.getByteArray(), 0));

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java
index 02a9fa9..d5f04ab 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java
@@ -45,15 +45,8 @@ import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public class DatetimeFromDateAndTimeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = AsterixBuiltinFunctions.DATETIME_FROM_DATE_TIME;
-
-    // allowed input types
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
-    private final static byte SER_TIME_TYPE_TAG = ATypeTag.TIME.serialize();
-
     public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
 
         @Override
@@ -100,25 +93,23 @@ public class DatetimeFromDateAndTimeDescriptor extends AbstractScalarFunctionDyn
                         eval1.evaluate(tuple);
 
                         try {
-                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
-                                    || argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                                    || argOut1.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                             } else {
-                                if (argOut0.getByteArray()[0] != SER_DATE_TYPE_TAG
-                                        && argOut1.getByteArray()[0] != SER_TIME_TYPE_TAG) {
+                                if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_DATE_TYPE_TAG
+                                        && argOut1.getByteArray()[0] != ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
                                     throw new AlgebricksException(
-                                            FID.getName()
-                                                    + ": expects input type (DATE/NULL, TIME/NULL) but got ("
-                                                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0
-                                                            .getByteArray()[0])
-                                                    + ", "
-                                                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1
-                                                            .getByteArray()[0]) + ").");
+                                            FID.getName() + ": expects input type (DATE/NULL, TIME/NULL) but got ("
+                                                    + EnumDeserializer.ATYPETAGDESERIALIZER
+                                                            .deserialize(argOut0.getByteArray()[0])
+                                                    + ", " + EnumDeserializer.ATYPETAGDESERIALIZER
+                                                            .deserialize(argOut1.getByteArray()[0])
+                                                    + ").");
 
                                 }
 
-                                long datetimeChronon = ADateSerializerDeserializer
-                                        .getChronon(argOut0.getByteArray(), 1)
+                                long datetimeChronon = ADateSerializerDeserializer.getChronon(argOut0.getByteArray(), 1)
                                         * GregorianCalendarSystem.CHRONON_OF_DAY
                                         + ATimeSerializerDeserializer.getChronon(argOut1.getByteArray(), 1);
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java
index a144172..48e4136 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java
@@ -45,15 +45,8 @@ import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public class DayOfWeekDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = AsterixBuiltinFunctions.DAY_OF_WEEK;
-
-    // allowed input types
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_DATETIME_TYPE_TAG = ATypeTag.DATETIME.serialize();
-    private final static byte SER_DATE_TYPE_TAG = ATypeTag.DATE.serialize();
-
     // Fixed week day anchor: Thursday, 1 January 1970
     private final static int ANCHOR_WEEKDAY = 4;
 
@@ -95,24 +88,23 @@ public class DayOfWeekDescriptor extends AbstractScalarFunctionDynamicDescriptor
                         argOut.reset();
                         eval.evaluate(tuple);
                         try {
-                            if (argOut.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                             } else {
                                 int daysSinceAnchor;
                                 int reminder = 0;
-                                if (argOut.getByteArray()[0] == SER_DATETIME_TYPE_TAG) {
+                                if (argOut.getByteArray()[0] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
                                     daysSinceAnchor = (int) (ADateTimeSerializerDeserializer.getChronon(
                                             argOut.getByteArray(), 1) / GregorianCalendarSystem.CHRONON_OF_DAY);
                                     reminder = (int) (ADateTimeSerializerDeserializer.getChronon(argOut.getByteArray(),
                                             1) % GregorianCalendarSystem.CHRONON_OF_DAY);
-                                } else if (argOut.getByteArray()[0] == SER_DATE_TYPE_TAG) {
+                                } else if (argOut.getByteArray()[0] == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
                                     daysSinceAnchor = ADateSerializerDeserializer.getChronon(argOut.getByteArray(), 1);
                                 } else {
                                     throw new AlgebricksException(
-                                            FID.getName()
-                                                    + ": expects input type DATETIME/DATE/NULL but got "
-                                                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut
-                                                            .getByteArray()[0]));
+                                            FID.getName() + ": expects input type DATETIME/DATE/NULL but got "
+                                                    + EnumDeserializer.ATYPETAGDESERIALIZER
+                                                            .deserialize(argOut.getByteArray()[0]));
                                 }
 
                                 // adjust the day before 1970-01-01

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java
index e29f5d2..1a98f3c 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java
@@ -46,11 +46,6 @@ public class DayTimeDurationComparatorDescriptor extends AbstractScalarFunctionD
     private final static long serialVersionUID = 1L;
     public final static FunctionIdentifier GREATER_THAN_FID = AsterixBuiltinFunctions.DAY_TIME_DURATION_GREATER_THAN;
     public final static FunctionIdentifier LESS_THAN_FID = AsterixBuiltinFunctions.DAY_TIME_DURATION_LESS_THAN;
-
-    // allowed input types
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
-
     private final boolean isGreaterThan;
 
     private DayTimeDurationComparatorDescriptor(boolean isGreaterThan) {
@@ -105,29 +100,31 @@ public class DayTimeDurationComparatorDescriptor extends AbstractScalarFunctionD
                         eval1.evaluate(tuple);
 
                         try {
-                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
-                                    || argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                                    || argOut1.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != SER_DURATION_TYPE_TAG
-                                    || argOut1.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
-                                throw new AlgebricksException(getIdentifier().getName()
-                                        + ": expects type NULL/DURATION, NULL/DURATION but got "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0])
-                                        + " and "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
+                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG
+                                    || argOut1.getByteArray()[0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
+                                throw new AlgebricksException(
+                                        getIdentifier().getName()
+                                                + ": expects type NULL/DURATION, NULL/DURATION but got "
+                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(
+                                                        argOut0.getByteArray()[0])
+                                                + " and " + EnumDeserializer.ATYPETAGDESERIALIZER
+                                                        .deserialize(argOut1.getByteArray()[0]));
                             }
 
                             if ((ADurationSerializerDeserializer.getYearMonth(argOut0.getByteArray(), 1) != 0)
                                     || (ADurationSerializerDeserializer.getYearMonth(argOut1.getByteArray(), 1) != 0)) {
-                                throw new AlgebricksException(getIdentifier().getName()
-                                        + ": only year-month durations are allowed.");
+                                throw new AlgebricksException(
+                                        getIdentifier().getName() + ": only year-month durations are allowed.");
                             }
 
-                            if (ADurationSerializerDeserializer.getDayTime(argOut0.getByteArray(), 1) > ADurationSerializerDeserializer
-                                    .getDayTime(argOut1.getByteArray(), 1)) {
+                            if (ADurationSerializerDeserializer.getDayTime(argOut0.getByteArray(),
+                                    1) > ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1)) {
                                 boolSerde.serialize(isGreaterThan ? ABoolean.TRUE : ABoolean.FALSE, out);
                             } else {
                                 boolSerde.serialize(isGreaterThan ? ABoolean.FALSE : ABoolean.TRUE, out);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java
index 1333515..c1493bd 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java
@@ -42,14 +42,8 @@ import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public class DurationEqualDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private final static long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = AsterixBuiltinFunctions.DURATION_EQUAL;
-
-    // allowed input types
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
-
     public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
 
         @Override
@@ -90,25 +84,27 @@ public class DurationEqualDescriptor extends AbstractScalarFunctionDynamicDescri
                         eval1.evaluate(tuple);
 
                         try {
-                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
-                                    || argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                                    || argOut1.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != SER_DURATION_TYPE_TAG
-                                    || argOut1.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
-                                throw new AlgebricksException(FID.getName()
-                                        + ": expects type NULL/DURATION, NULL/DURATION but got "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0])
-                                        + " and "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
+                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG
+                                    || argOut1.getByteArray()[0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
+                                throw new AlgebricksException(
+                                        FID.getName() + ": expects type NULL/DURATION, NULL/DURATION but got "
+                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(
+                                                        argOut0.getByteArray()[0])
+                                                + " and " + EnumDeserializer.ATYPETAGDESERIALIZER
+                                                        .deserialize(argOut1.getByteArray()[0]));
                             }
 
-                            if ((ADurationSerializerDeserializer.getDayTime(argOut0.getByteArray(), 1) == ADurationSerializerDeserializer
-                                    .getDayTime(argOut1.getByteArray(), 1))
-                                    && (ADurationSerializerDeserializer.getYearMonth(argOut0.getByteArray(), 1) == ADurationSerializerDeserializer
-                                            .getYearMonth(argOut1.getByteArray(), 1))) {
+                            if ((ADurationSerializerDeserializer.getDayTime(argOut0.getByteArray(),
+                                    1) == ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1))
+                                    && (ADurationSerializerDeserializer.getYearMonth(argOut0.getByteArray(),
+                                            1) == ADurationSerializerDeserializer.getYearMonth(argOut1.getByteArray(),
+                                                    1))) {
                                 boolSerde.serialize(ABoolean.TRUE, out);
                             } else {
                                 boolSerde.serialize(ABoolean.FALSE, out);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java
index ce00130..b69a257 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java
@@ -44,14 +44,8 @@ import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public class DurationFromIntervalDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = AsterixBuiltinFunctions.DURATION_FROM_INTERVAL;
-
-    // allowed input types
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_INTERVAL_TYPE_TAG = ATypeTag.INTERVAL.serialize();
-
     public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
 
         @Override
@@ -91,10 +85,10 @@ public class DurationFromIntervalDescriptor extends AbstractScalarFunctionDynami
                         eval.evaluate(tuple);
 
                         try {
-                            if (argOut.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                                 return;
-                            } else if (argOut.getByteArray()[0] != SER_INTERVAL_TYPE_TAG) {
+                            } else if (argOut.getByteArray()[0] != ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
                                 throw new AlgebricksException(FID.getName()
                                         + ": expects INTERVAL/NULL as the input but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut.getByteArray()[0]));
@@ -102,10 +96,10 @@ public class DurationFromIntervalDescriptor extends AbstractScalarFunctionDynami
                             long chrononStart = AIntervalSerializerDeserializer.getIntervalStart(argOut.getByteArray(),
                                     1);
                             long chrononEnd = AIntervalSerializerDeserializer.getIntervalEnd(argOut.getByteArray(), 1);
-                            byte intervalTypeTag = AIntervalSerializerDeserializer.getIntervalTimeType(
-                                    argOut.getByteArray(), 1);
+                            byte intervalTypeTag = AIntervalSerializerDeserializer
+                                    .getIntervalTimeType(argOut.getByteArray(), 1);
 
-                            if (intervalTypeTag == ATypeTag.DATE.serialize()) {
+                            if (intervalTypeTag == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
                                 chrononStart *= GregorianCalendarSystem.CHRONON_OF_DAY;
                                 chrononEnd *= GregorianCalendarSystem.CHRONON_OF_DAY;
                             }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java
index f3b4616..f66b56b 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java
@@ -45,10 +45,6 @@ public class DurationFromMonthsDescriptor extends AbstractScalarFunctionDynamicD
 
     private final static long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = AsterixBuiltinFunctions.DURATION_FROM_MONTHS;
-
-    // allowed input types
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-
     public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
 
         @Override
@@ -87,7 +83,7 @@ public class DurationFromMonthsDescriptor extends AbstractScalarFunctionDynamicD
                         eval0.evaluate(tuple);
 
                         try {
-                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                                 return;
                             }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java
index 3f59dbb..2c8ebfd 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java
@@ -43,14 +43,8 @@ import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public class GetDayTimeDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = AsterixBuiltinFunctions.GET_DAY_TIME_DURATION;
-
-    // allowed input types
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
-
     public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
 
         @Override
@@ -89,18 +83,18 @@ public class GetDayTimeDurationDescriptor extends AbstractScalarFunctionDynamicD
                         eval0.evaluate(tuple);
 
                         try {
-                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
                                 throw new AlgebricksException(FID.getName() + ": expects NULL/DURATION, but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
                             }
 
-                            aDayTimeDuration.setMilliseconds(ADurationSerializerDeserializer.getDayTime(
-                                    argOut0.getByteArray(), 1));
+                            aDayTimeDuration.setMilliseconds(
+                                    ADurationSerializerDeserializer.getDayTime(argOut0.getByteArray(), 1));
 
                             dayTimeDurationSerde.serialize(aDayTimeDuration, out);
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java
index 5678e10..8e7f0c6 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java
@@ -43,12 +43,7 @@ import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public class GetOverlappingIntervalDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private static final long serialVersionUID = 1L;
-
-    private static final byte SER_INTERVAL_TYPE_TAG = ATypeTag.INTERVAL.serialize();
-    private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         @Override
         public IFunctionDescriptor createFunctionDescriptor() {
@@ -56,6 +51,7 @@ public class GetOverlappingIntervalDescriptor extends AbstractScalarFunctionDyna
         }
     };
 
+    @Override
     public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
         return new ICopyEvaluatorFactory() {
 
@@ -88,22 +84,21 @@ public class GetOverlappingIntervalDescriptor extends AbstractScalarFunctionDyna
                         eval1.evaluate(tuple);
 
                         try {
-                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
-                                    || argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                                    || argOut1.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
-                            } else if (argOut0.getByteArray()[0] == SER_INTERVAL_TYPE_TAG
+                            } else if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG
                                     && argOut0.getByteArray()[0] == argOut1.getByteArray()[0]) {
-                                byte type0 = AIntervalSerializerDeserializer.getIntervalTimeType(
-                                        argOut0.getByteArray(), 1);
-                                byte type1 = AIntervalSerializerDeserializer.getIntervalTimeType(
-                                        argOut1.getByteArray(), 1);
+                                byte type0 = AIntervalSerializerDeserializer.getIntervalTimeType(argOut0.getByteArray(),
+                                        1);
+                                byte type1 = AIntervalSerializerDeserializer.getIntervalTimeType(argOut1.getByteArray(),
+                                        1);
                                 if (type0 != type1) {
-                                    throw new AlgebricksException(
-                                            getIdentifier().getName()
-                                                    + ": expecting two (nullable) interval values with the same internal time type but got interval of "
-                                                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(type0)
-                                                    + " and interval of "
-                                                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(type1));
+                                    throw new AlgebricksException(getIdentifier().getName()
+                                            + ": expecting two (nullable) interval values with the same internal time type but got interval of "
+                                            + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(type0)
+                                            + " and interval of "
+                                            + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(type1));
                                 }
 
                                 long start0 = AIntervalSerializerDeserializer.getIntervalStart(argOut0.getByteArray(),
@@ -124,11 +119,13 @@ public class GetOverlappingIntervalDescriptor extends AbstractScalarFunctionDyna
                                     nullSerde.serialize(ANull.NULL, out);
                                 }
                             } else {
-                                throw new AlgebricksException(getIdentifier().getName()
-                                        + ": expecting two (nullable) interval values but got "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0])
-                                        + " and "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[1]));
+                                throw new AlgebricksException(
+                                        getIdentifier().getName()
+                                                + ": expecting two (nullable) interval values but got "
+                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(
+                                                        argOut0.getByteArray()[0])
+                                                + " and " + EnumDeserializer.ATYPETAGDESERIALIZER
+                                                        .deserialize(argOut0.getByteArray()[1]));
                             }
                         } catch (HyracksDataException hex) {
                             throw new AlgebricksException(hex);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java
index f788879..84fd408 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java
@@ -43,14 +43,8 @@ import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public class GetYearMonthDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private static final long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = AsterixBuiltinFunctions.GET_YEAR_MONTH_DURATION;
-
-    // allowed input types
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
-
     public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
 
         @Override
@@ -89,18 +83,18 @@ public class GetYearMonthDurationDescriptor extends AbstractScalarFunctionDynami
                         eval0.evaluate(tuple);
 
                         try {
-                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
                                 throw new AlgebricksException(FID.getName() + ": expects NULL/DURATION, but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
                             }
 
-                            aYearMonthDuration.setMonths(ADurationSerializerDeserializer.getYearMonth(
-                                    argOut0.getByteArray(), 1));
+                            aYearMonthDuration
+                                    .setMonths(ADurationSerializerDeserializer.getYearMonth(argOut0.getByteArray(), 1));
 
                             yearMonthDurationSerde.serialize(aYearMonthDuration, out);
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
index ecaf1bd..a16c59a 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
@@ -43,14 +43,8 @@ import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public class MillisecondsFromDayTimeDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private final static long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = AsterixBuiltinFunctions.MILLISECONDS_FROM_DAY_TIME_DURATION;
-
-    // allowed input types
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_DAY_TIME_DURATION_TYPE_TAG = ATypeTag.DAYTIMEDURATION.serialize();
-
     public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
 
         @Override
@@ -89,18 +83,19 @@ public class MillisecondsFromDayTimeDurationDescriptor extends AbstractScalarFun
                         eval0.evaluate(tuple);
 
                         try {
-                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != SER_DAY_TIME_DURATION_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG) {
                                 throw new AlgebricksException(FID.getName()
                                         + ": expects NULL/DAY-TIME-DURATION, but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
                             }
 
-                            aInt64.setValue(ADayTimeDurationSerializerDeserializer.getDayTime(argOut0.getByteArray(), 1));
+                            aInt64.setValue(
+                                    ADayTimeDurationSerializerDeserializer.getDayTime(argOut0.getByteArray(), 1));
 
                             int64Serde.serialize(aInt64, out);
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
index be1f0ee..e7c7863 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
@@ -43,14 +43,8 @@ import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public class MonthsFromYearMonthDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private final static long serialVersionUID = 1L;
     public final static FunctionIdentifier FID = AsterixBuiltinFunctions.MONTHS_FROM_YEAR_MONTH_DURATION;
-
-    // allowed input types
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_YEARMONTHDURATION_TYPE_TAG = ATypeTag.YEARMONTHDURATION.serialize();
-
     public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
 
         @Override
@@ -89,19 +83,19 @@ public class MonthsFromYearMonthDurationDescriptor extends AbstractScalarFunctio
                         eval0.evaluate(tuple);
 
                         try {
-                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != SER_YEARMONTHDURATION_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG) {
                                 throw new AlgebricksException(FID.getName()
                                         + ": expects NULL/YEAR-MONTH-DURATION, but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
                             }
 
-                            aInt64.setValue(AYearMonthDurationSerializerDeserializer.getYearMonth(
-                                    argOut0.getByteArray(), 1));
+                            aInt64.setValue(
+                                    AYearMonthDurationSerializerDeserializer.getYearMonth(argOut0.getByteArray(), 1));
 
                             int64Serde.serialize(aInt64, out);
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java
index 2c05989..917f7c3 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java
@@ -112,8 +112,8 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                         if (type0 == ATypeTag.INTERVAL) {
                             intervalStart = AIntervalSerializerDeserializer.getIntervalStart(argOut0.getByteArray(), 1);
                             intervalEnd = AIntervalSerializerDeserializer.getIntervalEnd(argOut0.getByteArray(), 1);
-                            intervalTypeTag = AIntervalSerializerDeserializer.getIntervalTimeType(
-                                    argOut0.getByteArray(), 1);
+                            intervalTypeTag = AIntervalSerializerDeserializer
+                                    .getIntervalTimeType(argOut0.getByteArray(), 1);
                         } else if (type0 == ATypeTag.NULL) {
                             try {
                                 nullSerde.serialize(ANull.NULL, out);
@@ -133,10 +133,10 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                         ATypeTag type1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]);
 
                         if (intervalTypeTag != type1.serialize()) {
-                            if (intervalTypeTag != ATypeTag.NULL.serialize() && type1 != ATypeTag.NULL)
-                                throw new AlgebricksException(getIdentifier().getName()
-                                        + ": expecting compatible type to " + type0 + "(" + intervalTypeTag
-                                        + ") for the second argument but got " + type1);
+                            if (intervalTypeTag != ATypeTag.SERIALIZED_NULL_TYPE_TAG && type1 != ATypeTag.NULL)
+                                throw new AlgebricksException(
+                                        getIdentifier().getName() + ": expecting compatible type to " + type0 + "("
+                                                + intervalTypeTag + ") for the second argument but got " + type1);
                         }
 
                         long anchorTime = 0;
@@ -159,9 +159,9 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                                 }
                                 return;
                             default:
-                                throw new AlgebricksException(getIdentifier().getName()
-                                        + ": expecting compatible type to " + type0 + "(" + intervalTypeTag
-                                        + ") for the second argument but got " + type1);
+                                throw new AlgebricksException(
+                                        getIdentifier().getName() + ": expecting compatible type to " + type0 + "("
+                                                + intervalTypeTag + ") for the second argument but got " + type1);
                         }
 
                         argOut2.reset();
@@ -174,8 +174,8 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                         long firstBinIndex;
                         switch (type2) {
                             case YEARMONTHDURATION:
-                                yearMonth = AYearMonthDurationSerializerDeserializer.getYearMonth(
-                                        argOut2.getByteArray(), 1);
+                                yearMonth = AYearMonthDurationSerializerDeserializer
+                                        .getYearMonth(argOut2.getByteArray(), 1);
 
                                 int yearStart = GREG_CAL.getYear(anchorTime);
                                 int monthStart = GREG_CAL.getMonthOfYear(anchorTime, yearStart);
@@ -188,13 +188,13 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                                         + ((totalMonths < 0 && totalMonths % yearMonth != 0) ? -1 : 0);
 
                                 if (firstBinIndex > Integer.MAX_VALUE) {
-                                    throw new AlgebricksException(getIdentifier().getName()
-                                            + ": Overflowing time value to be binned!");
+                                    throw new AlgebricksException(
+                                            getIdentifier().getName() + ": Overflowing time value to be binned!");
                                 }
 
                                 if (firstBinIndex < Integer.MIN_VALUE) {
-                                    throw new AlgebricksException(getIdentifier().getName()
-                                            + ": Underflowing time value to be binned!");
+                                    throw new AlgebricksException(
+                                            getIdentifier().getName() + ": Underflowing time value to be binned!");
                                 }
                                 break;
 
@@ -216,10 +216,9 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                                 return;
 
                             default:
-                                throw new AlgebricksException(
-                                        getIdentifier().getName()
-                                                + ": expecting YEARMONTHDURATION/DAYTIMEDURATION for the thrid argument but got "
-                                                + type2);
+                                throw new AlgebricksException(getIdentifier().getName()
+                                        + ": expecting YEARMONTHDURATION/DAYTIMEDURATION for the thrid argument but got "
+                                        + type2);
                         }
 
                         long binStartChronon, binEndChronon;
@@ -228,25 +227,25 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                         listBuilder.reset(intListType);
 
                         try {
-                            if (intervalTypeTag == ATypeTag.DATE.serialize()) {
+                            if (intervalTypeTag == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
 
                                 binOffset = 0;
 
                                 do {
-                                    binStartChronon = DurationArithmeticOperations.addDuration(anchorTime, yearMonth
-                                            * (int) (firstBinIndex + binOffset), dayTime * (firstBinIndex + binOffset),
-                                            false);
-                                    binEndChronon = DurationArithmeticOperations.addDuration(anchorTime, yearMonth
-                                            * ((int) (firstBinIndex + binOffset) + 1), dayTime
-                                            * ((firstBinIndex + binOffset) + 1), false);
-                                    binStartChronon = binStartChronon
-                                            / GregorianCalendarSystem.CHRONON_OF_DAY
-                                            + ((binStartChronon < 0 && binStartChronon
-                                                    % GregorianCalendarSystem.CHRONON_OF_DAY != 0) ? -1 : 0);
-                                    binEndChronon = binEndChronon
-                                            / GregorianCalendarSystem.CHRONON_OF_DAY
-                                            + ((binEndChronon < 0 && binEndChronon
-                                                    % GregorianCalendarSystem.CHRONON_OF_DAY != 0) ? -1 : 0);
+                                    binStartChronon = DurationArithmeticOperations.addDuration(anchorTime,
+                                            yearMonth * (int) (firstBinIndex + binOffset),
+                                            dayTime * (firstBinIndex + binOffset), false);
+                                    binEndChronon = DurationArithmeticOperations.addDuration(anchorTime,
+                                            yearMonth * ((int) (firstBinIndex + binOffset) + 1),
+                                            dayTime * ((firstBinIndex + binOffset) + 1), false);
+                                    binStartChronon = binStartChronon / GregorianCalendarSystem.CHRONON_OF_DAY
+                                            + ((binStartChronon < 0
+                                                    && binStartChronon % GregorianCalendarSystem.CHRONON_OF_DAY != 0)
+                                                            ? -1 : 0);
+                                    binEndChronon = binEndChronon / GregorianCalendarSystem.CHRONON_OF_DAY
+                                            + ((binEndChronon < 0
+                                                    && binEndChronon % GregorianCalendarSystem.CHRONON_OF_DAY != 0) ? -1
+                                                            : 0);
                                     aInterval.setValue(binStartChronon, binEndChronon, intervalTypeTag);
                                     listStorage.reset();
                                     intervalSerde.serialize(aInterval, listStorage.getDataOutput());
@@ -254,7 +253,7 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                                     binOffset++;
                                 } while (binEndChronon < intervalEnd);
 
-                            } else if (intervalTypeTag == ATypeTag.TIME.serialize()) {
+                            } else if (intervalTypeTag == ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
                                 if (yearMonth != 0) {
                                     throw new AlgebricksException(getIdentifier().getName()
                                             + ": cannot create year-month bin for a time value");
@@ -262,53 +261,52 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
 
                                 binOffset = 0;
 
-                                binStartChronon = DurationArithmeticOperations.addDuration(anchorTime, yearMonth
-                                        * (int) (firstBinIndex + binOffset), dayTime * (firstBinIndex + binOffset),
-                                        true);
-                                binEndChronon = DurationArithmeticOperations.addDuration(anchorTime, yearMonth
-                                        * ((int) (firstBinIndex + binOffset) + 1), dayTime
-                                        * ((firstBinIndex + binOffset) + 1), true);
+                                binStartChronon = DurationArithmeticOperations.addDuration(anchorTime,
+                                        yearMonth * (int) (firstBinIndex + binOffset),
+                                        dayTime * (firstBinIndex + binOffset), true);
+                                binEndChronon = DurationArithmeticOperations.addDuration(anchorTime,
+                                        yearMonth * ((int) (firstBinIndex + binOffset) + 1),
+                                        dayTime * ((firstBinIndex + binOffset) + 1), true);
 
                                 if (binStartChronon < 0 || binStartChronon >= GregorianCalendarSystem.CHRONON_OF_DAY) {
                                     // avoid the case where a time bin is before 00:00:00 or no early than 24:00:00
-                                    throw new AlgebricksException(
-                                            getIdentifier().getName()
-                                                    + ": reaches a bin with the end earlier than the start; probably the window is beyond the time scope. Maybe use DATETIME?");
+                                    throw new AlgebricksException(getIdentifier().getName()
+                                            + ": reaches a bin with the end earlier than the start; probably the window is beyond the time scope. Maybe use DATETIME?");
                                 }
 
-                                while (!((binStartChronon < intervalStart && binEndChronon <= intervalStart) || (binStartChronon >= intervalEnd && binEndChronon > intervalEnd))) {
+                                while (!((binStartChronon < intervalStart && binEndChronon <= intervalStart)
+                                        || (binStartChronon >= intervalEnd && binEndChronon > intervalEnd))) {
 
                                     aInterval.setValue(binStartChronon, binEndChronon, intervalTypeTag);
                                     listStorage.reset();
                                     intervalSerde.serialize(aInterval, listStorage.getDataOutput());
                                     listBuilder.addItem(listStorage);
                                     binOffset++;
-                                    binStartChronon = DurationArithmeticOperations.addDuration(anchorTime, yearMonth
-                                            * (int) (firstBinIndex + binOffset), dayTime * (firstBinIndex + binOffset),
-                                            true);
-                                    binEndChronon = DurationArithmeticOperations.addDuration(anchorTime, yearMonth
-                                            * ((int) (firstBinIndex + binOffset) + 1), dayTime
-                                            * ((firstBinIndex + binOffset) + 1), true);
+                                    binStartChronon = DurationArithmeticOperations.addDuration(anchorTime,
+                                            yearMonth * (int) (firstBinIndex + binOffset),
+                                            dayTime * (firstBinIndex + binOffset), true);
+                                    binEndChronon = DurationArithmeticOperations.addDuration(anchorTime,
+                                            yearMonth * ((int) (firstBinIndex + binOffset) + 1),
+                                            dayTime * ((firstBinIndex + binOffset) + 1), true);
 
                                     if (binStartChronon == GregorianCalendarSystem.CHRONON_OF_DAY) {
                                         break;
                                     }
 
                                     if (binEndChronon < binStartChronon) {
-                                        throw new AlgebricksException(
-                                                getIdentifier().getName()
-                                                        + ": reaches a bin with the end earlier than the start; probably the window is beyond the time scope. Maybe use DATETIME?");
+                                        throw new AlgebricksException(getIdentifier().getName()
+                                                + ": reaches a bin with the end earlier than the start; probably the window is beyond the time scope. Maybe use DATETIME?");
                                     }
                                 }
-                            } else if (intervalTypeTag == ATypeTag.DATETIME.serialize()) {
+                            } else if (intervalTypeTag == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
                                 binOffset = 0;
                                 do {
-                                    binStartChronon = DurationArithmeticOperations.addDuration(anchorTime, yearMonth
-                                            * (int) (firstBinIndex + binOffset), dayTime * (firstBinIndex + binOffset),
-                                            false);
-                                    binEndChronon = DurationArithmeticOperations.addDuration(anchorTime, yearMonth
-                                            * ((int) (firstBinIndex + binOffset) + 1), dayTime
-                                            * ((firstBinIndex + binOffset) + 1), false);
+                                    binStartChronon = DurationArithmeticOperations.addDuration(anchorTime,
+                                            yearMonth * (int) (firstBinIndex + binOffset),
+                                            dayTime * (firstBinIndex + binOffset), false);
+                                    binEndChronon = DurationArithmeticOperations.addDuration(anchorTime,
+                                            yearMonth * ((int) (firstBinIndex + binOffset) + 1),
+                                            dayTime * ((firstBinIndex + binOffset) + 1), false);
                                     aInterval.setValue(binStartChronon, binEndChronon, intervalTypeTag);
                                     listStorage.reset();
                                     intervalSerde.serialize(aInterval, listStorage.getDataOutput());



Mime
View raw message