http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java index 72e4200..bab00bd 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java @@ -21,8 +21,6 @@ package org.apache.asterix.runtime.evaluators.functions.temporal; import java.io.DataOutput; import org.apache.asterix.dataflow.data.nontagged.serde.ATimeSerializerDeserializer; -import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.base.temporal.ATimeParserFactory; import org.apache.asterix.om.base.temporal.GregorianCalendarSystem; import org.apache.asterix.om.base.temporal.GregorianCalendarSystem.Fields; @@ -30,7 +28,6 @@ import org.apache.asterix.om.functions.AsterixBuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; import org.apache.asterix.om.types.ATypeTag; -import org.apache.asterix.om.types.BuiltinType; import org.apache.asterix.om.types.EnumDeserializer; import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; @@ -38,7 +35,6 @@ import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; import org.apache.hyracks.api.context.IHyracksTaskContext; -import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer; import org.apache.hyracks.data.std.api.IPointable; import org.apache.hyracks.data.std.primitive.UTF8StringPointable; import org.apache.hyracks.data.std.primitive.VoidPointable; @@ -78,11 +74,6 @@ public class AdjustTimeForTimeZoneDescriptor extends AbstractScalarFunctionDynam private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx); private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx); - // possible output types - @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); - private GregorianCalendarSystem calInstance = GregorianCalendarSystem.getInstance(); private final UTF8StringWriter writer = new UTF8StringWriter(); private final UTF8StringPointable utf8Ptr = new UTF8StringPointable(); @@ -100,13 +91,6 @@ public class AdjustTimeForTimeZoneDescriptor extends AbstractScalarFunctionDynam int len1 = argPtr1.getLength(); try { - if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG - || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) { - nullSerde.serialize(ANull.NULL, out); - result.set(resultStorage); - return; - } - if (bytes0[offset0] != ATypeTag.SERIALIZED_TIME_TYPE_TAG) { throw new AlgebricksException( FID.getName() + ": expects type TIME/NULL for parameter 0 but got "
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java index 418ad68..e38da7e 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java @@ -25,7 +25,6 @@ import org.apache.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeser import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.ADuration; import org.apache.asterix.om.base.AMutableDuration; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.base.temporal.DurationArithmeticOperations; import org.apache.asterix.om.base.temporal.GregorianCalendarSystem; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; @@ -80,10 +79,6 @@ public class CalendarDuartionFromDateDescriptor extends AbstractScalarFunctionDy private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx); private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx); - // possible output types - @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); @SuppressWarnings("unchecked") private ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.INSTANCE .getSerializerDeserializer(BuiltinType.ADURATION); @@ -104,13 +99,6 @@ public class CalendarDuartionFromDateDescriptor extends AbstractScalarFunctionDy int offset1 = argPtr1.getStartOffset(); try { - if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG - || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) { - nullSerde.serialize(ANull.NULL, out); - result.set(resultStorage); - return; - } - if (bytes0[offset0] != ATypeTag.SERIALIZED_DATE_TYPE_TAG) { throw new AlgebricksException( FID.getName() + ": expects type DATE/NULL for parameter 0 but got " http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java index dcef6ab..c42865c 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java @@ -25,7 +25,6 @@ import org.apache.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeser import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.ADuration; import org.apache.asterix.om.base.AMutableDuration; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.base.temporal.DurationArithmeticOperations; import org.apache.asterix.om.base.temporal.GregorianCalendarSystem; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; @@ -95,10 +94,6 @@ public class CalendarDurationFromDateTimeDescriptor extends AbstractScalarFuncti private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx); private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx); - // possible output types - @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); @SuppressWarnings("unchecked") private ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.INSTANCE .getSerializerDeserializer(BuiltinType.ADURATION); @@ -119,13 +114,6 @@ public class CalendarDurationFromDateTimeDescriptor extends AbstractScalarFuncti int offset1 = argPtr1.getStartOffset(); try { - if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG - || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) { - nullSerde.serialize(ANull.NULL, out); - result.set(resultStorage); - return; - } - if (bytes0[offset0] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) { throw new AlgebricksException( FID.getName() + ": expects type DATETIME/NULL for parameter 0 but got " http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java index bcdb20f..d4fa0e6 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java @@ -24,7 +24,6 @@ import org.apache.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeser import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.ADate; import org.apache.asterix.om.base.AMutableDate; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.base.temporal.GregorianCalendarSystem; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; @@ -79,10 +78,6 @@ public class DateFromDatetimeDescriptor extends AbstractScalarFunctionDynamicDes .getSerializerDeserializer(BuiltinType.ADATE); private AMutableDate aDate = new AMutableDate(0); - @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); - @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException { resultStorage.reset(); @@ -91,24 +86,19 @@ public class DateFromDatetimeDescriptor extends AbstractScalarFunctionDynamicDes int offset = argPtr.getStartOffset(); try { - if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) { - nullSerde.serialize(ANull.NULL, out); - } else { - if (bytes[offset] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) { - throw new AlgebricksException( - FID.getName() + ": expects input type DATETIME/NULL but got " - + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset])); - } - long datetimeChronon = ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1); - int dateChrononInDays = (int) (datetimeChronon - / GregorianCalendarSystem.CHRONON_OF_DAY); - if (dateChrononInDays < 0 - && datetimeChronon % GregorianCalendarSystem.CHRONON_OF_DAY != 0) { - dateChrononInDays -= 1; - } - aDate.setValue(dateChrononInDays); - dateSerde.serialize(aDate, out); + if (bytes[offset] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) { + throw new AlgebricksException( + FID.getName() + ": expects input type DATETIME/NULL but got " + + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset])); + } + long datetimeChronon = ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1); + int dateChrononInDays = (int) (datetimeChronon / GregorianCalendarSystem.CHRONON_OF_DAY); + if (dateChrononInDays < 0 + && datetimeChronon % GregorianCalendarSystem.CHRONON_OF_DAY != 0) { + dateChrononInDays -= 1; } + aDate.setValue(dateChrononInDays); + dateSerde.serialize(aDate, out); } catch (HyracksDataException hex) { throw new AlgebricksException(hex); } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java index b6f7a2e..5fa57f6 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java @@ -23,11 +23,9 @@ import java.io.DataOutput; import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.ADate; import org.apache.asterix.om.base.AMutableDate; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; -import org.apache.asterix.om.types.ATypeTag; import org.apache.asterix.om.types.BuiltinType; import org.apache.asterix.om.types.hierachy.ATypeHierarchy; import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; @@ -77,22 +75,15 @@ public class DateFromUnixTimeInDaysDescriptor extends AbstractScalarFunctionDyna @SuppressWarnings("unchecked") private ISerializerDeserializer<ADate> dateSerde = AqlSerializerDeserializerProvider.INSTANCE .getSerializerDeserializer(BuiltinType.ADATE); - @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException { resultStorage.reset(); eval.evaluate(tuple, argPtr); try { - if (argPtr.getByteArray()[argPtr.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) { - nullSerde.serialize(ANull.NULL, out); - } else { - aDate.setValue( - ATypeHierarchy.getIntegerValue(argPtr.getByteArray(), argPtr.getStartOffset())); - dateSerde.serialize(aDate, out); - } + aDate.setValue( + ATypeHierarchy.getIntegerValue(argPtr.getByteArray(), argPtr.getStartOffset())); + dateSerde.serialize(aDate, out); } catch (HyracksDataException hex) { throw new AlgebricksException(hex); } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java index ab88265..98f84aa 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java @@ -25,7 +25,6 @@ import org.apache.asterix.dataflow.data.nontagged.serde.ATimeSerializerDeseriali import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.ADateTime; import org.apache.asterix.om.base.AMutableDateTime; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.base.temporal.GregorianCalendarSystem; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; @@ -85,10 +84,6 @@ public class DatetimeFromDateAndTimeDescriptor extends AbstractScalarFunctionDyn .getSerializerDeserializer(BuiltinType.ADATETIME); private AMutableDateTime aDateTime = new AMutableDateTime(0); - @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); - @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException { resultStorage.reset(); @@ -101,27 +96,21 @@ public class DatetimeFromDateAndTimeDescriptor extends AbstractScalarFunctionDyn int offset1 = argPtr1.getStartOffset(); try { - if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG - || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) { - nullSerde.serialize(ANull.NULL, out); - } else { - if (bytes0[offset0] != ATypeTag.SERIALIZED_DATE_TYPE_TAG - && bytes1[offset1] != ATypeTag.SERIALIZED_TIME_TYPE_TAG) { - throw new AlgebricksException(FID.getName() - + ": expects input type (DATE/NULL, TIME/NULL) but got (" - + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + ", " - + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]) - + ")."); - - } - - long datetimeChronon = ADateSerializerDeserializer.getChronon(bytes0, offset0 + 1) - * GregorianCalendarSystem.CHRONON_OF_DAY - + ATimeSerializerDeserializer.getChronon(bytes1, offset1 + 1); - - aDateTime.setValue(datetimeChronon); - datetimeSerde.serialize(aDateTime, out); + if (bytes0[offset0] != ATypeTag.SERIALIZED_DATE_TYPE_TAG + && bytes1[offset1] != ATypeTag.SERIALIZED_TIME_TYPE_TAG) { + throw new AlgebricksException(FID.getName() + + ": expects input type (DATE/NULL, TIME/NULL) but got (" + + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + ", " + + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]) + ")."); + } + + long datetimeChronon = ADateSerializerDeserializer.getChronon(bytes0, offset0 + 1) + * GregorianCalendarSystem.CHRONON_OF_DAY + + ATimeSerializerDeserializer.getChronon(bytes1, offset1 + 1); + + aDateTime.setValue(datetimeChronon); + datetimeSerde.serialize(aDateTime, out); } catch (HyracksDataException hex) { throw new AlgebricksException(hex); } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInMsDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInMsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInMsDescriptor.java index fae8566..d9c0156 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInMsDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInMsDescriptor.java @@ -27,7 +27,6 @@ import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeseriali import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.ADateTime; import org.apache.asterix.om.base.AMutableDateTime; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; @@ -82,9 +81,6 @@ public class DatetimeFromUnixTimeInMsDescriptor extends AbstractScalarFunctionDy @SuppressWarnings("unchecked") private ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE .getSerializerDeserializer(BuiltinType.ADATETIME); - @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); private AMutableDateTime aDatetime = new AMutableDateTime(0); @@ -96,29 +92,24 @@ public class DatetimeFromUnixTimeInMsDescriptor extends AbstractScalarFunctionDy int offset = argPtr.getStartOffset(); try { ATypeTag argPtrTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[offset]]; - if (argPtrTypeTag == ATypeTag.NULL) { - nullSerde.serialize(ANull.NULL, out); - } else { - switch (argPtrTypeTag) { - case INT8: - aDatetime.setValue(AInt8SerializerDeserializer.getByte(bytes, offset + 1)); - break; - case INT16: - aDatetime.setValue(AInt16SerializerDeserializer.getShort(bytes, offset + 1)); - break; - case INT32: - aDatetime.setValue(AInt32SerializerDeserializer.getInt(bytes, offset + 1)); - break; - case INT64: - aDatetime.setValue(AInt64SerializerDeserializer.getLong(bytes, offset + 1)); - break; - default: - throw new AlgebricksException( - FID.getName() + ": expects type INT8/INT16/INT32/INT64/NULL but got " - + argPtrTypeTag); - } - datetimeSerde.serialize(aDatetime, out); + switch (argPtrTypeTag) { + case INT8: + aDatetime.setValue(AInt8SerializerDeserializer.getByte(bytes, offset + 1)); + break; + case INT16: + aDatetime.setValue(AInt16SerializerDeserializer.getShort(bytes, offset + 1)); + break; + case INT32: + aDatetime.setValue(AInt32SerializerDeserializer.getInt(bytes, offset + 1)); + break; + case INT64: + aDatetime.setValue(AInt64SerializerDeserializer.getLong(bytes, offset + 1)); + break; + default: + throw new AlgebricksException(FID.getName() + + ": expects type INT8/INT16/INT32/INT64/NULL but got " + argPtrTypeTag); } + datetimeSerde.serialize(aDatetime, out); } catch (HyracksDataException hex) { throw new AlgebricksException(hex); } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInSecsDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInSecsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInSecsDescriptor.java index 1450ce6..a0258b6 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInSecsDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInSecsDescriptor.java @@ -27,7 +27,6 @@ import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeseriali import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.ADateTime; import org.apache.asterix.om.base.AMutableDateTime; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; @@ -82,9 +81,6 @@ public class DatetimeFromUnixTimeInSecsDescriptor extends AbstractScalarFunction @SuppressWarnings("unchecked") private ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE .getSerializerDeserializer(BuiltinType.ADATETIME); - @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); private AMutableDateTime aDatetime = new AMutableDateTime(0); @@ -100,33 +96,25 @@ public class DatetimeFromUnixTimeInSecsDescriptor extends AbstractScalarFunction ATypeTag argPtrTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[offset]]; - if (argPtrTypeTag == ATypeTag.NULL) { - nullSerde.serialize(ANull.NULL, out); - } else { - switch (argPtrTypeTag) { - case INT8: - aDatetime.setValue( - (AInt8SerializerDeserializer.getByte(bytes, offset + 1) * 1000l)); - break; - case INT16: - aDatetime.setValue( - (AInt16SerializerDeserializer.getShort(bytes, offset + 1) * 1000l)); - break; - case INT32: - aDatetime.setValue( - (AInt32SerializerDeserializer.getInt(bytes, offset + 1) * 1000l)); - break; - case INT64: - aDatetime.setValue( - (AInt64SerializerDeserializer.getLong(bytes, offset + 1) * 1000l)); - break; - default: - throw new AlgebricksException( - FID.getName() + ": expects type INT8/INT16/INT32/INT64/NULL but got " - + argPtrTypeTag); - } - datetimeSerde.serialize(aDatetime, out); + switch (argPtrTypeTag) { + case INT8: + aDatetime.setValue(AInt8SerializerDeserializer.getByte(bytes, offset + 1) * 1000l); + break; + case INT16: + aDatetime + .setValue(AInt16SerializerDeserializer.getShort(bytes, offset + 1) * 1000l); + break; + case INT32: + aDatetime.setValue(AInt32SerializerDeserializer.getInt(bytes, offset + 1) * 1000l); + break; + case INT64: + aDatetime.setValue(AInt64SerializerDeserializer.getLong(bytes, offset + 1) * 1000l); + break; + default: + throw new AlgebricksException(FID.getName() + + ": expects type INT8/INT16/INT32/INT64/NULL but got " + argPtrTypeTag); } + datetimeSerde.serialize(aDatetime, out); } catch (HyracksDataException hex) { throw new AlgebricksException(hex); } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java index d7b5044..e1fe88b 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java @@ -25,7 +25,6 @@ import org.apache.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeser import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.AInt64; import org.apache.asterix.om.base.AMutableInt64; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.base.temporal.GregorianCalendarSystem; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; @@ -83,10 +82,6 @@ public class DayOfWeekDescriptor extends AbstractScalarFunctionDynamicDescriptor .getSerializerDeserializer(BuiltinType.AINT64); private AMutableInt64 aInt64 = new AMutableInt64(0); - @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); - @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException { resultStorage.reset(); @@ -96,46 +91,42 @@ public class DayOfWeekDescriptor extends AbstractScalarFunctionDynamicDescriptor int offset = argPtr.getStartOffset(); try { - if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) { - nullSerde.serialize(ANull.NULL, out); + int daysSinceAnchor; + int reminder = 0; + if (bytes[offset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) { + daysSinceAnchor = (int) (ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1) + / GregorianCalendarSystem.CHRONON_OF_DAY); + reminder = (int) (ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1) + % GregorianCalendarSystem.CHRONON_OF_DAY); + } else if (bytes[offset] == ATypeTag.SERIALIZED_DATE_TYPE_TAG) { + daysSinceAnchor = ADateSerializerDeserializer.getChronon(bytes, offset + 1); } else { - int daysSinceAnchor; - int reminder = 0; - if (bytes[offset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) { - daysSinceAnchor = (int) (ADateTimeSerializerDeserializer.getChronon(bytes, - offset + 1) / GregorianCalendarSystem.CHRONON_OF_DAY); - reminder = (int) (ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1) - % GregorianCalendarSystem.CHRONON_OF_DAY); - } else if (bytes[offset] == ATypeTag.SERIALIZED_DATE_TYPE_TAG) { - daysSinceAnchor = ADateSerializerDeserializer.getChronon(bytes, offset + 1); - } else { - throw new AlgebricksException( - FID.getName() + ": expects input type DATETIME/DATE/NULL but got " - + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset])); - } - - // adjust the day before 1970-01-01 - if (daysSinceAnchor < 0 && reminder != 0) { - daysSinceAnchor -= 1; - } - - // compute the weekday (0-based, and 0 = Sunday). Adjustment is needed as the anchor day is Thursday - int weekday = (daysSinceAnchor + ANCHOR_WEEKDAY) % 7; - - // handle the negative weekday - if (weekday < 0) { - weekday += 7; - } - - // convert from 0-based to 1-based (so 7 = Sunday) - if (weekday == 0) { - weekday = 7; - } - - aInt64.setValue(weekday); - - int64Serde.serialize(aInt64, out); + throw new AlgebricksException( + FID.getName() + ": expects input type DATETIME/DATE/NULL but got " + + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset])); + } + + // adjust the day before 1970-01-01 + if (daysSinceAnchor < 0 && reminder != 0) { + daysSinceAnchor -= 1; + } + + // compute the weekday (0-based, and 0 = Sunday). Adjustment is needed as + // the anchor day is Thursday. + int weekday = (daysSinceAnchor + ANCHOR_WEEKDAY) % 7; + + // handle the negative weekday + if (weekday < 0) { + weekday += 7; } + + // convert from 0-based to 1-based (so 7 = Sunday) + if (weekday == 0) { + weekday = 7; + } + + aInt64.setValue(weekday); + int64Serde.serialize(aInt64, out); } catch (HyracksDataException hex) { throw new AlgebricksException(hex); } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java index b7d170b..2d29c81 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java @@ -23,10 +23,7 @@ import java.io.DataOutput; import org.apache.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer; import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.ABoolean; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; -import org.apache.asterix.om.functions.IFunctionDescriptor; -import org.apache.asterix.om.functions.IFunctionDescriptorFactory; import org.apache.asterix.om.types.ATypeTag; import org.apache.asterix.om.types.BuiltinType; import org.apache.asterix.om.types.EnumDeserializer; @@ -50,26 +47,10 @@ public class DayTimeDurationComparatorDescriptor extends AbstractScalarFunctionD public final static FunctionIdentifier LESS_THAN_FID = AsterixBuiltinFunctions.DAY_TIME_DURATION_LESS_THAN; private final boolean isGreaterThan; - private DayTimeDurationComparatorDescriptor(boolean isGreaterThan) { + protected DayTimeDurationComparatorDescriptor(boolean isGreaterThan) { this.isGreaterThan = isGreaterThan; } - public final static IFunctionDescriptorFactory GREATER_THAN_FACTORY = new IFunctionDescriptorFactory() { - - @Override - public IFunctionDescriptor createFunctionDescriptor() { - return new DayTimeDurationComparatorDescriptor(true); - } - }; - - public final static IFunctionDescriptorFactory LESS_THAN_FACTORY = new IFunctionDescriptorFactory() { - - @Override - public IFunctionDescriptor createFunctionDescriptor() { - return new DayTimeDurationComparatorDescriptor(false); - } - }; - @Override public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) throws AlgebricksException { @@ -88,10 +69,6 @@ public class DayTimeDurationComparatorDescriptor extends AbstractScalarFunctionD private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx); private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx); - // possible output types - @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); @SuppressWarnings("unchecked") private ISerializerDeserializer<ABoolean> boolSerde = AqlSerializerDeserializerProvider.INSTANCE .getSerializerDeserializer(BuiltinType.ABOOLEAN); @@ -108,13 +85,6 @@ public class DayTimeDurationComparatorDescriptor extends AbstractScalarFunctionD int offset1 = argPtr1.getStartOffset(); try { - if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG - || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) { - nullSerde.serialize(ANull.NULL, out); - result.set(resultStorage); - return; - } - if (bytes0[offset0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG || bytes1[offset1] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) { throw new AlgebricksException(getIdentifier().getName() http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationGreaterThanComparatorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationGreaterThanComparatorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationGreaterThanComparatorDescriptor.java new file mode 100644 index 0000000..9480508 --- /dev/null +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationGreaterThanComparatorDescriptor.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 at + * + * 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 org.apache.asterix.runtime.evaluators.functions.temporal; + +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; + +public class DayTimeDurationGreaterThanComparatorDescriptor extends DayTimeDurationComparatorDescriptor { + private static final long serialVersionUID = 1L; + + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new DayTimeDurationGreaterThanComparatorDescriptor(); + } + }; + + protected DayTimeDurationGreaterThanComparatorDescriptor() { + super(true); + } +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationLessThanComparatorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationLessThanComparatorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationLessThanComparatorDescriptor.java new file mode 100644 index 0000000..7304ae9 --- /dev/null +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationLessThanComparatorDescriptor.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 at + * + * 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 org.apache.asterix.runtime.evaluators.functions.temporal; + +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; + +public class DayTimeDurationLessThanComparatorDescriptor extends DayTimeDurationComparatorDescriptor { + private static final long serialVersionUID = 1L; + + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new DayTimeDurationLessThanComparatorDescriptor(); + } + }; + + protected DayTimeDurationLessThanComparatorDescriptor() { + super(false); + } +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java index bd18f0b..0a88684 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java @@ -23,7 +23,6 @@ import java.io.DataOutput; import org.apache.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer; import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.ABoolean; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; @@ -72,10 +71,6 @@ public class DurationEqualDescriptor extends AbstractScalarFunctionDynamicDescri private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx); private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx); - // possible output types - @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); @SuppressWarnings("unchecked") private ISerializerDeserializer<ABoolean> boolSerde = AqlSerializerDeserializerProvider.INSTANCE .getSerializerDeserializer(BuiltinType.ABOOLEAN); @@ -92,13 +87,6 @@ public class DurationEqualDescriptor extends AbstractScalarFunctionDynamicDescri int offset1 = argPtr1.getStartOffset(); try { - if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG - || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) { - nullSerde.serialize(ANull.NULL, out); - result.set(resultStorage); - return; - } - if (bytes0[offset0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG || bytes1[offset1] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) { throw new AlgebricksException(FID.getName() http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java index 28d2b85..0c4042f 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java @@ -24,7 +24,6 @@ import org.apache.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeser import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.ADayTimeDuration; import org.apache.asterix.om.base.AMutableDayTimeDuration; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.base.temporal.GregorianCalendarSystem; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; @@ -74,10 +73,6 @@ public class DurationFromIntervalDescriptor extends AbstractScalarFunctionDynami private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx); @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); - - @SuppressWarnings("unchecked") private ISerializerDeserializer<ADayTimeDuration> dayTimeDurationSerde = AqlSerializerDeserializerProvider.INSTANCE .getSerializerDeserializer(BuiltinType.ADAYTIMEDURATION); @@ -92,11 +87,7 @@ public class DurationFromIntervalDescriptor extends AbstractScalarFunctionDynami int offset = argPtr.getStartOffset(); try { - if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) { - nullSerde.serialize(ANull.NULL, out); - result.set(resultStorage); - return; - } else if (bytes[offset] != ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) { + if (bytes[offset] != ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) { throw new AlgebricksException( FID.getName() + ": expects INTERVAL/NULL as the input but got " + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset])); http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java index b1860bb..480cf8f 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java @@ -27,7 +27,6 @@ import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeseriali import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.ADuration; import org.apache.asterix.om.base.AMutableDuration; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; @@ -75,10 +74,6 @@ public class DurationFromMillisecondsDescriptor extends AbstractScalarFunctionDy private IPointable argPtr0 = new VoidPointable(); private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx); - // possible output types - @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); @SuppressWarnings("unchecked") private ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.INSTANCE .getSerializerDeserializer(BuiltinType.ADURATION); @@ -94,29 +89,24 @@ public class DurationFromMillisecondsDescriptor extends AbstractScalarFunctionDy try { ATypeTag argPtrTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[offset]]; - if (argPtrTypeTag == ATypeTag.NULL) { - nullSerde.serialize(ANull.NULL, out); - } else { - switch (argPtrTypeTag) { - case INT8: - aDuration.setValue(0, AInt8SerializerDeserializer.getByte(bytes, offset + 1)); - break; - case INT16: - aDuration.setValue(0, AInt16SerializerDeserializer.getShort(bytes, offset + 1)); - break; - case INT32: - aDuration.setValue(0, AInt32SerializerDeserializer.getInt(bytes, offset + 1)); - break; - case INT64: - aDuration.setValue(0, AInt64SerializerDeserializer.getLong(bytes, offset + 1)); - break; - default: - throw new AlgebricksException( - FID.getName() + ": expects type INT8/INT16/INT32/INT64/NULL but got " - + argPtrTypeTag); - } - durationSerde.serialize(aDuration, out); + switch (argPtrTypeTag) { + case INT8: + aDuration.setValue(0, AInt8SerializerDeserializer.getByte(bytes, offset + 1)); + break; + case INT16: + aDuration.setValue(0, AInt16SerializerDeserializer.getShort(bytes, offset + 1)); + break; + case INT32: + aDuration.setValue(0, AInt32SerializerDeserializer.getInt(bytes, offset + 1)); + break; + case INT64: + aDuration.setValue(0, AInt64SerializerDeserializer.getLong(bytes, offset + 1)); + break; + default: + throw new AlgebricksException(FID.getName() + + ": expects type INT8/INT16/INT32/INT64/NULL but got " + argPtrTypeTag); } + durationSerde.serialize(aDuration, out); } catch (HyracksDataException hex) { throw new AlgebricksException(hex); } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java index 334607a..5db6294 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java @@ -23,11 +23,9 @@ import java.io.DataOutput; import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.ADuration; import org.apache.asterix.om.base.AMutableDuration; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; -import org.apache.asterix.om.types.ATypeTag; import org.apache.asterix.om.types.BuiltinType; import org.apache.asterix.om.types.hierachy.ATypeHierarchy; import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; @@ -71,10 +69,6 @@ public class DurationFromMonthsDescriptor extends AbstractScalarFunctionDynamicD private IPointable argPtr0 = new VoidPointable(); private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx); - // possible output types - @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); @SuppressWarnings("unchecked") private ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.INSTANCE .getSerializerDeserializer(BuiltinType.ADURATION); @@ -90,11 +84,6 @@ public class DurationFromMonthsDescriptor extends AbstractScalarFunctionDynamicD int offset = argPtr0.getStartOffset(); try { - if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) { - nullSerde.serialize(ANull.NULL, out); - result.set(resultStorage); - return; - } aDuration.setValue(ATypeHierarchy.getIntegerValue(bytes, offset), 0); durationSerde.serialize(aDuration, out); } catch (HyracksDataException hex) { http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java index b75a5b9..cb84fc8 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java @@ -24,7 +24,6 @@ import org.apache.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeser import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.ADayTimeDuration; import org.apache.asterix.om.base.AMutableDayTimeDuration; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; @@ -71,10 +70,6 @@ public class GetDayTimeDurationDescriptor extends AbstractScalarFunctionDynamicD private IPointable argPtr0 = new VoidPointable(); private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx); - // possible output types - @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); @SuppressWarnings("unchecked") private ISerializerDeserializer<ADayTimeDuration> dayTimeDurationSerde = AqlSerializerDeserializerProvider.INSTANCE .getSerializerDeserializer(BuiltinType.ADAYTIMEDURATION); @@ -90,12 +85,6 @@ public class GetDayTimeDurationDescriptor extends AbstractScalarFunctionDynamicD int offset = argPtr0.getStartOffset(); try { - if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) { - nullSerde.serialize(ANull.NULL, out); - result.set(resultStorage); - return; - } - if (bytes[offset] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) { throw new AlgebricksException(FID.getName() + ": expects NULL/DURATION, but got " + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset])); http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java index 9726058..1de1e48 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java @@ -96,10 +96,7 @@ public class GetOverlappingIntervalDescriptor extends AbstractScalarFunctionDyna byte type1 = argPtr1.getTag(); try { - if (type0 == ATypeTag.SERIALIZED_NULL_TYPE_TAG - || type1 == ATypeTag.SERIALIZED_NULL_TYPE_TAG) { - nullSerde.serialize(ANull.NULL, out); - } else if (type0 == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG && type0 == type1) { + if (type0 == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG && type0 == type1) { argPtr0.getValue(interval0); argPtr1.getValue(interval1); byte intervalType0 = interval0.getType(); http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java index d3397c4..d2e4b6e 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java @@ -23,7 +23,6 @@ import java.io.DataOutput; import org.apache.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer; import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.AMutableYearMonthDuration; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.base.AYearMonthDuration; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; @@ -71,10 +70,6 @@ public class GetYearMonthDurationDescriptor extends AbstractScalarFunctionDynami private IPointable argPtr0 = new VoidPointable(); private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx); - // possible output types - @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); @SuppressWarnings("unchecked") private ISerializerDeserializer<AYearMonthDuration> yearMonthDurationSerde = AqlSerializerDeserializerProvider.INSTANCE .getSerializerDeserializer(BuiltinType.AYEARMONTHDURATION); @@ -90,12 +85,6 @@ public class GetYearMonthDurationDescriptor extends AbstractScalarFunctionDynami int offset0 = argPtr0.getStartOffset(); try { - if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) { - nullSerde.serialize(ANull.NULL, out); - result.set(resultStorage); - return; - } - if (bytes0[offset0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) { throw new AlgebricksException(FID.getName() + ": expects NULL/DURATION, but got " + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0])); http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java index 2160910..b584442 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java @@ -28,7 +28,6 @@ import org.apache.asterix.dataflow.data.nontagged.serde.AYearMonthDurationSerial import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.AInterval; import org.apache.asterix.om.base.AMutableInterval; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.base.temporal.DurationArithmeticOperations; import org.apache.asterix.om.base.temporal.GregorianCalendarSystem; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; @@ -86,9 +85,6 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript private final AMutableInterval aInterval = new AMutableInterval(0, 0, (byte) -1); @SuppressWarnings("unchecked") - private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); - @SuppressWarnings("unchecked") private final ISerializerDeserializer<AInterval> intervalSerde = AqlSerializerDeserializerProvider.INSTANCE .getSerializerDeserializer(BuiltinType.AINTERVAL); @@ -98,9 +94,11 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException { resultStorage.reset(); eval0.evaluate(tuple, argPtr0); + eval1.evaluate(tuple, argPtr1); + eval2.evaluate(tuple, argPtr2); + byte[] bytes0 = argPtr0.getByteArray(); int offset0 = argPtr0.getStartOffset(); - ATypeTag type0 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]); long chrononToBin = 0; @@ -115,30 +113,18 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript case DATETIME: chrononToBin = ADateTimeSerializerDeserializer.getChronon(bytes0, offset0 + 1); break; - case NULL: - try { - nullSerde.serialize(ANull.NULL, out); - } catch (HyracksDataException e) { - throw new AlgebricksException(e); - } - result.set(resultStorage); - return; default: throw new AlgebricksException(getIdentifier().getName() + ": the first argument should be DATE/TIME/DATETIME/NULL but got " + type0); - } - eval1.evaluate(tuple, argPtr1); byte[] bytes1 = argPtr1.getByteArray(); int offset1 = argPtr1.getStartOffset(); ATypeTag type1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]); if (type0 != type1) { - if (type0 != ATypeTag.NULL && type1 != ATypeTag.NULL) { - throw new AlgebricksException(getIdentifier().getName() + ": expecting " + type0 - + " for the second argument but got " + type1); - } + throw new AlgebricksException(getIdentifier().getName() + ": expecting " + type0 + + " for the second argument but got " + type1); } long chrononToStart = 0; @@ -153,20 +139,11 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript case DATETIME: chrononToStart = ADateTimeSerializerDeserializer.getChronon(bytes1, offset1 + 1); break; - case NULL: - try { - nullSerde.serialize(ANull.NULL, out); - } catch (HyracksDataException e) { - throw new AlgebricksException(e); - } - result.set(resultStorage); - return; default: throw new AlgebricksException(getIdentifier().getName() + ": expecting " + type0 + " for the second argument but got " + type1); } - eval2.evaluate(tuple, argPtr2); byte[] bytes2 = argPtr2.getByteArray(); int offset2 = argPtr2.getStartOffset(); ATypeTag type2 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes2[offset2]); @@ -205,16 +182,7 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript binIndex = totalChronon / dayTime + ((totalChronon < 0 && totalChronon % dayTime != 0) ? -1 : 0); - break; - case NULL: - try { - nullSerde.serialize(ANull.NULL, out); - } catch (HyracksDataException e) { - throw new AlgebricksException(e); - } - result.set(resultStorage); - return; default: throw new AlgebricksException(getIdentifier().getName() + ": expecting YEARMONTHDURATION/DAYTIMEDURATION for the thrid argument but got " @@ -253,18 +221,9 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript binEndChronon = DurationArithmeticOperations.addDuration(chrononToStart, yearMonth * ((int) binIndex + 1), dayTime * (binIndex + 1), false); break; - case NULL: - try { - nullSerde.serialize(ANull.NULL, out); - } catch (HyracksDataException e) { - throw new AlgebricksException(e); - } - result.set(resultStorage); - return; default: throw new AlgebricksException(getIdentifier().getName() + ": the first argument should be DATE/TIME/DATETIME/NULL but got " + type0); - } try { aInterval.setValue(binStartChronon, binEndChronon, type0.serialize()); http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDecriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDecriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDecriptor.java deleted file mode 100644 index 459652e..0000000 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDecriptor.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 at - * - * 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 org.apache.asterix.runtime.evaluators.functions.temporal; - -import org.apache.asterix.om.functions.AsterixBuiltinFunctions; -import org.apache.asterix.om.functions.IFunctionDescriptor; -import org.apache.asterix.om.functions.IFunctionDescriptorFactory; -import org.apache.asterix.om.pointables.nonvisitor.AIntervalPointable; -import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; -import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; - -public class IntervalEndsDecriptor extends AbstractIntervalLogicFuncDescriptor { - - private final static long serialVersionUID = 1L; - - public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { - - @Override - public IFunctionDescriptor createFunctionDescriptor() { - return new IntervalEndsDecriptor(); - } - }; - - @Override - public FunctionIdentifier getIdentifier() { - return AsterixBuiltinFunctions.INTERVAL_ENDS; - } - - @Override - protected boolean compareIntervals(IntervalLogic il, AIntervalPointable ip1, AIntervalPointable ip2) - throws AlgebricksException { - return il.ends(ip1, ip2); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDescriptor.java new file mode 100644 index 0000000..9571787 --- /dev/null +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDescriptor.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 at + * + * 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 org.apache.asterix.runtime.evaluators.functions.temporal; + +import org.apache.asterix.om.functions.AsterixBuiltinFunctions; +import org.apache.asterix.om.functions.IFunctionDescriptor; +import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.asterix.om.pointables.nonvisitor.AIntervalPointable; +import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; +import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; + +public class IntervalEndsDescriptor extends AbstractIntervalLogicFuncDescriptor { + private static final long serialVersionUID = 1L; + + public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { + + @Override + public IFunctionDescriptor createFunctionDescriptor() { + return new IntervalEndsDescriptor(); + } + }; + + @Override + public FunctionIdentifier getIdentifier() { + return AsterixBuiltinFunctions.INTERVAL_ENDS; + } + + @Override + protected boolean compareIntervals(IntervalLogic il, AIntervalPointable ip1, AIntervalPointable ip2) + throws AlgebricksException { + return il.ends(ip1, ip2); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java index 4b1fedd..ffca207 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java @@ -24,7 +24,6 @@ import org.apache.asterix.dataflow.data.nontagged.serde.ADayTimeDurationSerializ import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider; import org.apache.asterix.om.base.AInt64; import org.apache.asterix.om.base.AMutableInt64; -import org.apache.asterix.om.base.ANull; import org.apache.asterix.om.functions.AsterixBuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; @@ -71,10 +70,6 @@ public class MillisecondsFromDayTimeDurationDescriptor extends AbstractScalarFun private IPointable argPtr0 = new VoidPointable(); private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx); - // possible output types - @SuppressWarnings("unchecked") - private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ANULL); @SuppressWarnings("unchecked") private ISerializerDeserializer<AInt64> int64Serde = AqlSerializerDeserializerProvider.INSTANCE .getSerializerDeserializer(BuiltinType.AINT64); @@ -90,12 +85,6 @@ public class MillisecondsFromDayTimeDurationDescriptor extends AbstractScalarFun int offset = argPtr0.getStartOffset(); try { - if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) { - nullSerde.serialize(ANull.NULL, out); - result.set(resultStorage); - return; - } - if (bytes[offset] != ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG) { throw new AlgebricksException( FID.getName() + ": expects NULL/DAY-TIME-DURATION, but got "
