http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/polygon_01/polygon_01.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/polygon_01/polygon_01.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/polygon_01/polygon_01.3.ast index 86781d6..ece41d9 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/polygon_01/polygon_01.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/polygon_01/polygon_01.3.ast @@ -15,4 +15,13 @@ RecordConstructor [ LiteralExpr [STRING] [-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75] ] ) + ( + LiteralExpr [STRING] [polygon3] + : + FunctionCall test.polygon@1[ + FunctionCall test.polygon@1[ + LiteralExpr [STRING] [-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81] + ] + ] + ) ]
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/rectangle_01/rectangle_01.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/rectangle_01/rectangle_01.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/rectangle_01/rectangle_01.3.ast index da4c509..9632ac0 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/rectangle_01/rectangle_01.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/rectangle_01/rectangle_01.3.ast @@ -15,4 +15,13 @@ RecordConstructor [ LiteralExpr [STRING] [0.1234,-1.00e-10 5.5487,0.48765] ] ) + ( + LiteralExpr [STRING] [rectangle3] + : + FunctionCall test.rectangle@1[ + FunctionCall test.rectangle@1[ + LiteralExpr [STRING] [5.1,11.8 87.6,15.6548] + ] + ] + ) ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/string_01/string_01.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/string_01/string_01.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/string_01/string_01.3.ast index 8b23981..5d4de90 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/string_01/string_01.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/string_01/string_01.3.ast @@ -15,4 +15,58 @@ RecordConstructor [ LiteralExpr [STRING] [false"] ] ) + ( + LiteralExpr [STRING] [string3] + : + FunctionCall test.string@1[ + FunctionCall test.int8@1[ + LiteralExpr [STRING] [8] + ] + ] + ) + ( + LiteralExpr [STRING] [string4] + : + FunctionCall test.string@1[ + FunctionCall test.int16@1[ + LiteralExpr [STRING] [16] + ] + ] + ) + ( + LiteralExpr [STRING] [string5] + : + FunctionCall test.string@1[ + FunctionCall test.int32@1[ + LiteralExpr [STRING] [32] + ] + ] + ) + ( + LiteralExpr [STRING] [string6] + : + FunctionCall test.string@1[ + FunctionCall test.int64@1[ + LiteralExpr [STRING] [64] + ] + ] + ) + ( + LiteralExpr [STRING] [string7] + : + FunctionCall test.string@1[ + FunctionCall test.float@1[ + LiteralExpr [STRING] [1.25] + ] + ] + ) + ( + LiteralExpr [STRING] [string8] + : + FunctionCall test.string@1[ + FunctionCall test.double@1[ + LiteralExpr [STRING] [2.5] + ] + ] + ) ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/time_01/time_01.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/time_01/time_01.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/time_01/time_01.3.ast index c9a018a..6be78b1 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/time_01/time_01.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/time_01/time_01.3.ast @@ -78,4 +78,13 @@ RecordConstructor [ LiteralExpr [STRING] [125900019+0100] ] ) + ( + LiteralExpr [STRING] [time12] + : + FunctionCall test.time@1[ + FunctionCall test.time@1[ + LiteralExpr [STRING] [125900019+0100] + ] + ] + ) ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/uuid_01/uuid_01.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/uuid_01/uuid_01.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/uuid_01/uuid_01.3.ast index e79a445..9b2f4e0 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/uuid_01/uuid_01.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/constructor/uuid_01/uuid_01.3.ast @@ -15,4 +15,13 @@ RecordConstructor [ LiteralExpr [STRING] [8cea25ab-55f8-467e-929d-94888f754832] ] ) + ( + LiteralExpr [STRING] [uuid3] + : + FunctionCall test.uuid@1[ + FunctionCall test.uuid@1[ + LiteralExpr [STRING] [8cea25ab-55f8-467e-929d-94888f754832] + ] + ] + ) ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java index f4fb36a..dbcef6c 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/BuiltinFunctions.java @@ -42,7 +42,6 @@ import org.apache.asterix.om.typecomputer.impl.AInt64TypeComputer; import org.apache.asterix.om.typecomputer.impl.AInt8TypeComputer; import org.apache.asterix.om.typecomputer.impl.AIntervalTypeComputer; import org.apache.asterix.om.typecomputer.impl.ALineTypeComputer; -import org.apache.asterix.om.typecomputer.impl.AMissingTypeComputer; import org.apache.asterix.om.typecomputer.impl.APoint3DTypeComputer; import org.apache.asterix.om.typecomputer.impl.APointTypeComputer; import org.apache.asterix.om.typecomputer.impl.APolygonTypeComputer; @@ -519,8 +518,6 @@ public class BuiltinFunctions { // constructors: public static final FunctionIdentifier BOOLEAN_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "boolean", 1); - public static final FunctionIdentifier NULL_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, - "null", 1); public static final FunctionIdentifier STRING_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "string", 1); public static final FunctionIdentifier BINARY_HEX_CONSTRUCTOR = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, @@ -855,7 +852,7 @@ public class BuiltinFunctions { // and then, Asterix builtin functions addPrivateFunction(CHECK_UNKNOWN, NotUnknownTypeComputer.INSTANCE, true); addPrivateFunction(ANY_COLLECTION_MEMBER, CollectionMemberResultType.INSTANCE, true); - addFunction(BOOLEAN_CONSTRUCTOR, StringBooleanTypeComputer.INSTANCE, true); + addFunction(BOOLEAN_CONSTRUCTOR, ABooleanTypeComputer.INSTANCE, true); addFunction(CARET, NumericAddSubMulDivTypeComputer.INSTANCE, true); addFunction(CIRCLE_CONSTRUCTOR, ACircleTypeComputer.INSTANCE, true); addPrivateFunction(CONCAT_NON_NULL, ConcatNonNullTypeComputer.INSTANCE, true); @@ -906,7 +903,6 @@ public class BuiltinFunctions { addPrivateFunction(LISTIFY, OrderedListConstructorTypeComputer.INSTANCE, true); addPrivateFunction(MAKE_FIELD_INDEX_HANDLE, null, true); addPrivateFunction(MAKE_FIELD_NAME_HANDLE, null, true); - addFunction(NULL_CONSTRUCTOR, AMissingTypeComputer.INSTANCE, true); addPrivateFunction(NUMERIC_UNARY_MINUS, UnaryMinusTypeComputer.INSTANCE, true); addPrivateFunction(NUMERIC_SUBTRACT, NumericAddSubMulDivTypeComputer.INSTANCE, true); @@ -943,6 +939,7 @@ public class BuiltinFunctions { addFunction(FIND_BINARY, AInt64TypeComputer.INSTANCE, true); addFunction(FIND_BINARY_FROM, AInt64TypeComputer.INSTANCE, true); + addFunction(STRING_CONSTRUCTOR, AStringTypeComputer.INSTANCE, true); addFunction(STRING_LIKE, BooleanFunctionTypeComputer.INSTANCE, true); addFunction(STRING_CONTAINS, ABooleanTypeComputer.INSTANCE, true); addFunction(STRING_TO_CODEPOINT, StringToInt64ListTypeComputer.INSTANCE, true); @@ -1068,7 +1065,6 @@ public class BuiltinFunctions { addFunction(GET_CIRCLE_RADIUS_ACCESSOR, ADoubleTypeComputer.INSTANCE, true); addFunction(GET_CIRCLE_CENTER_ACCESSOR, APointTypeComputer.INSTANCE, true); addFunction(GET_POINTS_LINE_RECTANGLE_POLYGON_ACCESSOR, OrderedListOfAPointTypeComputer.INSTANCE, true); - addFunction(STRING_CONSTRUCTOR, AStringTypeComputer.INSTANCE, true); // Binary functions addFunction(BINARY_HEX_CONSTRUCTOR, ABinaryTypeComputer.INSTANCE, true); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AMissingTypeComputer.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AMissingTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AMissingTypeComputer.java deleted file mode 100644 index bf262c3..0000000 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AMissingTypeComputer.java +++ /dev/null @@ -1,42 +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.om.typecomputer.impl; - -import org.apache.asterix.om.typecomputer.base.IResultTypeComputer; -import org.apache.asterix.om.types.BuiltinType; -import org.apache.asterix.om.types.IAType; -import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; -import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression; -import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment; -import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider; - -public class AMissingTypeComputer implements IResultTypeComputer { - - public static final AMissingTypeComputer INSTANCE = new AMissingTypeComputer(); - - private AMissingTypeComputer() { - } - - @Override - public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env, - IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException { - return BuiltinType.AMISSING; - } - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/ATypeTag.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/ATypeTag.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/ATypeTag.java index 4e1f7f6..6889934 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/ATypeTag.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/ATypeTag.java @@ -87,6 +87,7 @@ public enum ATypeTag implements IEnumSerializer { public static final byte SERIALIZED_DURATION_TYPE_TAG = DURATION.serialize(); public static final byte SERIALIZED_DAY_TIME_DURATION_TYPE_TAG = DAYTIMEDURATION.serialize(); public static final byte SERIALIZED_POINT_TYPE_TAG = POINT.serialize(); + public static final byte SERIALIZED_POINT3D_TYPE_TAG = POINT3D.serialize(); public static final byte SERIALIZED_INTERVAL_TYPE_TAG = INTERVAL.serialize(); public static final byte SERIALIZED_CIRCLE_TYPE_TAG = CIRCLE.serialize(); public static final byte SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG = YEARMONTHDURATION.serialize(); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABinaryHexStringConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABinaryHexStringConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABinaryHexStringConstructorDescriptor.java index 04e32b1..720e9bc 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABinaryHexStringConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABinaryHexStringConstructorDescriptor.java @@ -91,9 +91,10 @@ public class ABinaryHexStringConstructorDescriptor extends AbstractScalarFunctio int startOffset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (binary[startOffset] == ATypeTag.SERIALIZED_BINARY_TYPE_TAG) { + byte tt = binary[startOffset]; + if (tt == ATypeTag.SERIALIZED_BINARY_TYPE_TAG) { result.set(inputArg); - } else if (binary[startOffset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { resultStorage.reset(); utf8Ptr.set(inputArg.getByteArray(), startOffset + 1, len - 1); char[] buffer = utf8Ptr.toString().toCharArray(); @@ -101,9 +102,8 @@ public class ABinaryHexStringConstructorDescriptor extends AbstractScalarFunctio byteArrayParser.parse(buffer, 0, buffer.length, out); result.set(resultStorage); } else { - throw new TypeMismatchException(BuiltinFunctions.BINARY_HEX_CONSTRUCTOR, 0, - binary[startOffset], ATypeTag.SERIALIZED_BINARY_TYPE_TAG, - ATypeTag.SERIALIZED_STRING_TYPE_TAG); + throw new TypeMismatchException(BuiltinFunctions.BINARY_HEX_CONSTRUCTOR, 0, tt, + ATypeTag.SERIALIZED_BINARY_TYPE_TAG, ATypeTag.SERIALIZED_STRING_TYPE_TAG); } } catch (IOException e) { throw new InvalidDataFormatException(BuiltinFunctions.BINARY_HEX_CONSTRUCTOR, e, http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java index d737376..5ef78d3 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java @@ -71,35 +71,36 @@ public class ABooleanConstructorDescriptor extends AbstractScalarFunctionDynamic IBinaryComparator utf8BinaryComparator = BinaryComparatorFactoryProvider.UTF8STRING_POINTABLE_INSTANCE.createBinaryComparator(); @SuppressWarnings("unchecked") - private ISerializerDeserializer<ABoolean> booleanSerde = SerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ABOOLEAN); + private ISerializerDeserializer<ABoolean> booleanSerde = + SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ABOOLEAN); @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { try { - resultStorage.reset(); eval.evaluate(tuple, inputArg); byte[] serString = inputArg.getByteArray(); int startOffset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[startOffset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[startOffset]; + if (tt == ATypeTag.SERIALIZED_BOOLEAN_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + resultStorage.reset(); if (utf8BinaryComparator.compare(serString, startOffset + 1, len - 1, TRUE, 0, TRUE.length) == 0) { booleanSerde.serialize(ABoolean.TRUE, out); result.set(resultStorage); - return; } else if (utf8BinaryComparator.compare(serString, startOffset + 1, len - 1, FALSE, 0, FALSE.length) == 0) { booleanSerde.serialize(ABoolean.FALSE, out); result.set(resultStorage); - return; } else { throw new InvalidDataFormatException(getIdentifier(), ATypeTag.SERIALIZED_BOOLEAN_TYPE_TAG); } } else { - throw new TypeMismatchException(getIdentifier(), 0, serString[startOffset], + throw new TypeMismatchException(getIdentifier(), 0, tt, ATypeTag.SERIALIZED_STRING_TYPE_TAG); } } catch (IOException e) { http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java index a4d851a..5b0d250 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java @@ -70,22 +70,24 @@ public class ACircleConstructorDescriptor extends AbstractScalarFunctionDynamicD private final AMutablePoint aPoint = new AMutablePoint(0, 0); private AMutableCircle aCircle = new AMutableCircle(null, 0); @SuppressWarnings("unchecked") - private ISerializerDeserializer<ACircle> circleSerde = SerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ACIRCLE); + private ISerializerDeserializer<ACircle> circleSerde = + SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ACIRCLE); private final UTF8StringPointable utf8Ptr = new UTF8StringPointable(); @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { try { - resultStorage.reset(); eval.evaluate(tuple, inputArg); - byte[] serString = inputArg.getByteArray(); int offset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[offset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[offset]; + if (tt == ATypeTag.SERIALIZED_CIRCLE_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + resultStorage.reset(); utf8Ptr.set(serString, offset + 1, len - 1); String s = utf8Ptr.toString(); int commaIndex = s.indexOf(','); @@ -94,11 +96,11 @@ public class ACircleConstructorDescriptor extends AbstractScalarFunctionDynamicD Double.parseDouble(s.substring(commaIndex + 1, spaceIndex))); aCircle.setValue(aPoint, Double.parseDouble(s.substring(spaceIndex + 1, s.length()))); circleSerde.serialize(aCircle, out); + result.set(resultStorage); } else { - throw new TypeMismatchException(getIdentifier(), 0, serString[offset], + throw new TypeMismatchException(getIdentifier(), 0, tt, ATypeTag.SERIALIZED_STRING_TYPE_TAG); } - result.set(resultStorage); } catch (IOException e) { throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_CIRCLE_TYPE_TAG); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java index cd9d939..eb9b40f 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java @@ -70,8 +70,8 @@ public class ADateConstructorDescriptor extends AbstractScalarFunctionDynamicDes private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx); private AMutableDate aDate = new AMutableDate(0); @SuppressWarnings("unchecked") - private ISerializerDeserializer<ADate> dateSerde = SerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ADATE); + private ISerializerDeserializer<ADate> dateSerde = + SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ADATE); private final UTF8StringPointable utf8Ptr = new UTF8StringPointable(); @@ -84,7 +84,10 @@ public class ADateConstructorDescriptor extends AbstractScalarFunctionDynamicDes int offset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[offset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[offset]; + if (tt == ATypeTag.SERIALIZED_DATE_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { utf8Ptr.set(serString, offset + 1, len - 1); int stringLength = utf8Ptr.getUTF8Length(); @@ -112,11 +115,11 @@ public class ADateConstructorDescriptor extends AbstractScalarFunctionDynamicDes } aDate.setValue((int) (chrononTimeInMs / GregorianCalendarSystem.CHRONON_OF_DAY) - temp); dateSerde.serialize(aDate, out); + result.set(resultStorage); } else { - throw new TypeMismatchException(getIdentifier(), 0, serString[offset], + throw new TypeMismatchException(getIdentifier(), 0, tt, ATypeTag.SERIALIZED_STRING_TYPE_TAG); } - result.set(resultStorage); } catch (IOException e) { throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_DATE_TYPE_TAG); } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java index 3a8a742..f202dbe 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java @@ -69,8 +69,8 @@ public class ADateTimeConstructorDescriptor extends AbstractScalarFunctionDynami private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx); private AMutableDateTime aDateTime = new AMutableDateTime(0L); @SuppressWarnings("unchecked") - private ISerializerDeserializer<ADateTime> datetimeSerde = SerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ADATETIME); + private ISerializerDeserializer<ADateTime> datetimeSerde = + SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ADATETIME); private final UTF8StringPointable utf8Ptr = new UTF8StringPointable(); @Override @@ -82,7 +82,10 @@ public class ADateTimeConstructorDescriptor extends AbstractScalarFunctionDynami int offset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[offset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[offset]; + if (tt == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { utf8Ptr.set(serString, offset + 1, len - 1); int stringLength = utf8Ptr.getUTF8Length(); int startOffset = utf8Ptr.getCharStartOffset(); @@ -104,19 +107,19 @@ public class ADateTimeConstructorDescriptor extends AbstractScalarFunctionDynami } } - long chrononTimeInMs = ADateParserFactory.parseDatePart(serString, startOffset, - timeOffset); + long chrononTimeInMs = + ADateParserFactory.parseDatePart(serString, startOffset, timeOffset); chrononTimeInMs += ATimeParserFactory.parseTimePart(serString, startOffset + timeOffset + 1, stringLength - timeOffset - 1); aDateTime.setValue(chrononTimeInMs); datetimeSerde.serialize(aDateTime, out); + result.set(resultStorage); } else { - throw new TypeMismatchException(getIdentifier(), 0, serString[offset], + throw new TypeMismatchException(getIdentifier(), 0, tt, ATypeTag.SERIALIZED_STRING_TYPE_TAG); } - result.set(resultStorage); } catch (IOException e) { throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_DATETIME_TYPE_TAG); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADayTimeDurationConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADayTimeDurationConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADayTimeDurationConstructorDescriptor.java index c7723ef..0e7cc34 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADayTimeDurationConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADayTimeDurationConstructorDescriptor.java @@ -72,20 +72,23 @@ public class ADayTimeDurationConstructorDescriptor extends AbstractScalarFunctio private AMutableDayTimeDuration aDayTimeDuration = new AMutableDayTimeDuration(0); @SuppressWarnings("unchecked") private ISerializerDeserializer<ADayTimeDuration> dayTimeDurationSerde = - SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer( - BuiltinType.ADAYTIMEDURATION); + SerializerDeserializerProvider.INSTANCE + .getSerializerDeserializer(BuiltinType.ADAYTIMEDURATION); private final UTF8StringPointable utf8Ptr = new UTF8StringPointable(); @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { try { - resultStorage.reset(); eval.evaluate(tuple, inputArg); byte[] serString = inputArg.getByteArray(); int offset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[offset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[offset]; + if (tt == ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + resultStorage.reset(); utf8Ptr.set(serString, offset + 1, len - 1); int stringLength = utf8Ptr.getUTF8Length(); int startOffset = utf8Ptr.getCharStartOffset(); @@ -94,11 +97,11 @@ public class ADayTimeDurationConstructorDescriptor extends AbstractScalarFunctio aDayTimeDuration, ADurationParseOption.DAY_TIME); dayTimeDurationSerde.serialize(aDayTimeDuration, out); + result.set(resultStorage); } else { - throw new TypeMismatchException(getIdentifier(), 0, serString[offset], + throw new TypeMismatchException(getIdentifier(), 0, tt, ATypeTag.SERIALIZED_STRING_TYPE_TAG); } - result.set(resultStorage); } catch (Exception e) { throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADoubleConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADoubleConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADoubleConstructorDescriptor.java index 00dbaae..299a452 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADoubleConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADoubleConstructorDescriptor.java @@ -75,21 +75,24 @@ public class ADoubleConstructorDescriptor extends AbstractScalarFunctionDynamicD BinaryComparatorFactoryProvider.UTF8STRING_POINTABLE_INSTANCE.createBinaryComparator(); private AMutableDouble aDouble = new AMutableDouble(0); @SuppressWarnings("unchecked") - private ISerializerDeserializer<ADouble> doubleSerde = SerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ADOUBLE); + private ISerializerDeserializer<ADouble> doubleSerde = + SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ADOUBLE); private final UTF8StringPointable utf8Ptr = new UTF8StringPointable(); @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { try { - resultStorage.reset(); eval.evaluate(tuple, inputArg); byte[] serString = inputArg.getByteArray(); int offset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[offset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[offset]; + if (tt == ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + resultStorage.reset(); if (utf8BinaryComparator.compare(serString, offset + 1, len - 1, POSITIVE_INF, 0, 5) == 0) { aDouble.setValue(Double.POSITIVE_INFINITY); @@ -104,11 +107,11 @@ public class ADoubleConstructorDescriptor extends AbstractScalarFunctionDynamicD aDouble.setValue(Double.parseDouble(utf8Ptr.toString())); } doubleSerde.serialize(aDouble, out); + result.set(resultStorage); } else { - throw new TypeMismatchException(getIdentifier(), 0, serString[offset], + throw new TypeMismatchException(getIdentifier(), 0, tt, ATypeTag.SERIALIZED_STRING_TYPE_TAG); } - result.set(resultStorage); } catch (IOException e) { throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_DATETIME_TYPE_TAG); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java index 0202b7b..df39306 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java @@ -69,30 +69,33 @@ public class ADurationConstructorDescriptor extends AbstractScalarFunctionDynami private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx); private AMutableDuration aDuration = new AMutableDuration(0, 0); @SuppressWarnings("unchecked") - private ISerializerDeserializer<ADuration> durationSerde = SerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ADURATION); + private ISerializerDeserializer<ADuration> durationSerde = + SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ADURATION); private final UTF8StringPointable utf8Ptr = new UTF8StringPointable(); @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { try { - resultStorage.reset(); eval.evaluate(tuple, inputArg); byte[] serString = inputArg.getByteArray(); int offset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[offset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[offset]; + if (tt == ATypeTag.SERIALIZED_DURATION_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + resultStorage.reset(); utf8Ptr.set(serString, offset + 1, len - 1); int stringLength = utf8Ptr.getUTF8Length(); ADurationParserFactory.parseDuration(serString, utf8Ptr.getCharStartOffset(), stringLength, aDuration, ADurationParseOption.All); durationSerde.serialize(aDuration, out); + result.set(resultStorage); } else { - throw new TypeMismatchException(getIdentifier(), 0, serString[offset], + throw new TypeMismatchException(getIdentifier(), 0, tt, ATypeTag.SERIALIZED_STRING_TYPE_TAG); } - result.set(resultStorage); } catch (IOException e) { throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_DURATION_TYPE_TAG); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AFloatConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AFloatConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AFloatConstructorDescriptor.java index 3b7a6b2..ffc982a 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AFloatConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AFloatConstructorDescriptor.java @@ -71,24 +71,27 @@ public class AFloatConstructorDescriptor extends AbstractScalarFunctionDynamicDe private final byte[] POSITIVE_INF = UTF8StringUtil.writeStringToBytes("INF"); private final byte[] NEGATIVE_INF = UTF8StringUtil.writeStringToBytes("-INF"); private final byte[] NAN = UTF8StringUtil.writeStringToBytes("NaN"); - private IBinaryComparator utf8BinaryComparator = BinaryComparatorFactoryProvider. - UTF8STRING_POINTABLE_INSTANCE.createBinaryComparator(); + private IBinaryComparator utf8BinaryComparator = + BinaryComparatorFactoryProvider.UTF8STRING_POINTABLE_INSTANCE.createBinaryComparator(); private AMutableFloat aFloat = new AMutableFloat(0); @SuppressWarnings("unchecked") - private ISerializerDeserializer<AFloat> floatSerde = SerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.AFLOAT); + private ISerializerDeserializer<AFloat> floatSerde = + SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AFLOAT); private final UTF8StringPointable utf8Ptr = new UTF8StringPointable(); @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { try { - resultStorage.reset(); eval.evaluate(tuple, inputArg); byte[] serString = inputArg.getByteArray(); int offset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[offset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[offset]; + if (tt == ATypeTag.SERIALIZED_FLOAT_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + resultStorage.reset(); if (utf8BinaryComparator.compare(serString, offset + 1, len - 1, POSITIVE_INF, 0, 5) == 0) { aFloat.setValue(Float.POSITIVE_INFINITY); @@ -103,11 +106,11 @@ public class AFloatConstructorDescriptor extends AbstractScalarFunctionDynamicDe aFloat.setValue(Float.parseFloat(utf8Ptr.toString())); } floatSerde.serialize(aFloat, out); + result.set(resultStorage); } else { - throw new TypeMismatchException(getIdentifier(), 0, serString[offset], + throw new TypeMismatchException(getIdentifier(), 0, tt, ATypeTag.SERIALIZED_STRING_TYPE_TAG); } - result.set(resultStorage); } catch (IOException e) { throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_FLOAT_TYPE_TAG); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt16ConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt16ConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt16ConstructorDescriptor.java index 9f7dbc3..9413cb4 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt16ConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt16ConstructorDescriptor.java @@ -71,20 +71,23 @@ public class AInt16ConstructorDescriptor extends AbstractScalarFunctionDynamicDe private boolean positive; private AMutableInt16 aInt16 = new AMutableInt16((short) 0); @SuppressWarnings("unchecked") - private ISerializerDeserializer<AInt16> int16Serde = SerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.AINT16); + private ISerializerDeserializer<AInt16> int16Serde = + SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT16); private final UTF8StringPointable utf8Ptr = new UTF8StringPointable(); @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { try { - resultStorage.reset(); eval.evaluate(tuple, inputArg); byte[] serString = inputArg.getByteArray(); int startOffset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[startOffset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[startOffset]; + if (tt == ATypeTag.SERIALIZED_INT16_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + resultStorage.reset(); utf8Ptr.set(serString, startOffset + 1, len - 1); offset = utf8Ptr.getCharStartOffset(); //accumulating value in negative domain @@ -128,11 +131,11 @@ public class AInt16ConstructorDescriptor extends AbstractScalarFunctionDynamicDe aInt16.setValue(value); int16Serde.serialize(aInt16, out); + result.set(resultStorage); } else { - throw new TypeMismatchException(getIdentifier(), 0, serString[offset], + throw new TypeMismatchException(getIdentifier(), 0, tt, ATypeTag.SERIALIZED_STRING_TYPE_TAG); } - result.set(resultStorage); } catch (IOException e) { throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_INT16_TYPE_TAG); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt32ConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt32ConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt32ConstructorDescriptor.java index bc74b94..985d966 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt32ConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt32ConstructorDescriptor.java @@ -70,20 +70,23 @@ public class AInt32ConstructorDescriptor extends AbstractScalarFunctionDynamicDe private boolean positive; private AMutableInt32 aInt32 = new AMutableInt32(0); @SuppressWarnings("unchecked") - private ISerializerDeserializer<AInt32> int32Serde = SerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.AINT32); + private ISerializerDeserializer<AInt32> int32Serde = + SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT32); private final UTF8StringPointable utf8Ptr = new UTF8StringPointable(); @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { try { - resultStorage.reset(); eval.evaluate(tuple, inputArg); byte[] serString = inputArg.getByteArray(); int startOffset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[startOffset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[startOffset]; + if (tt == ATypeTag.SERIALIZED_INT32_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + resultStorage.reset(); utf8Ptr.set(serString, startOffset + 1, len - 1); offset = utf8Ptr.getCharStartOffset(); //accumulating value in negative domain @@ -127,11 +130,11 @@ public class AInt32ConstructorDescriptor extends AbstractScalarFunctionDynamicDe aInt32.setValue(value); int32Serde.serialize(aInt32, out); + result.set(resultStorage); } else { - throw new TypeMismatchException(getIdentifier(), 0, serString[offset], + throw new TypeMismatchException(getIdentifier(), 0, tt, ATypeTag.SERIALIZED_STRING_TYPE_TAG); } - result.set(resultStorage); } catch (IOException e) { throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_INT32_TYPE_TAG); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt64ConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt64ConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt64ConstructorDescriptor.java index 0870f73..a2dc8b2 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt64ConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt64ConstructorDescriptor.java @@ -31,6 +31,7 @@ import org.apache.asterix.om.types.ATypeTag; import org.apache.asterix.om.types.BuiltinType; import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; import org.apache.asterix.runtime.exceptions.InvalidDataFormatException; +import org.apache.asterix.runtime.exceptions.TypeMismatchException; 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; @@ -77,13 +78,16 @@ public class AInt64ConstructorDescriptor extends AbstractScalarFunctionDynamicDe @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { try { - resultStorage.reset(); eval.evaluate(tuple, inputArg); byte[] serString = inputArg.getByteArray(); int startOffset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[startOffset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[startOffset]; + if (tt == ATypeTag.SERIALIZED_INT64_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + resultStorage.reset(); utf8Ptr.set(serString, startOffset + 1, len - 1); offset = utf8Ptr.getCharStartOffset(); //accumulating value in negative domain @@ -127,11 +131,11 @@ public class AInt64ConstructorDescriptor extends AbstractScalarFunctionDynamicDe aInt64.setValue(value); int64Serde.serialize(aInt64, out); + result.set(resultStorage); } else { - throw new InvalidDataFormatException(getIdentifier(), - ATypeTag.SERIALIZED_INT64_TYPE_TAG); + throw new TypeMismatchException(getIdentifier(), 0, tt, + ATypeTag.SERIALIZED_STRING_TYPE_TAG); } - result.set(resultStorage); } catch (IOException e) { throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_INT64_TYPE_TAG); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt8ConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt8ConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt8ConstructorDescriptor.java index c0d9fd4..e4a9d32 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt8ConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt8ConstructorDescriptor.java @@ -31,6 +31,7 @@ import org.apache.asterix.om.types.ATypeTag; import org.apache.asterix.om.types.BuiltinType; import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; import org.apache.asterix.runtime.exceptions.InvalidDataFormatException; +import org.apache.asterix.runtime.exceptions.TypeMismatchException; 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; @@ -70,20 +71,23 @@ public class AInt8ConstructorDescriptor extends AbstractScalarFunctionDynamicDes private boolean positive; private AMutableInt8 aInt8 = new AMutableInt8((byte) 0); @SuppressWarnings("unchecked") - private ISerializerDeserializer<AInt8> int8Serde = SerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.AINT8); + private ISerializerDeserializer<AInt8> int8Serde = + SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT8); private final UTF8StringPointable utf8Ptr = new UTF8StringPointable(); @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { try { - resultStorage.reset(); eval.evaluate(tuple, inputArg); byte[] serString = inputArg.getByteArray(); int startOffset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[startOffset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[startOffset]; + if (tt == ATypeTag.SERIALIZED_INT8_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + resultStorage.reset(); utf8Ptr.set(serString, startOffset + 1, len - 1); offset = utf8Ptr.getCharStartOffset(); //accumulating value in negative domain @@ -127,11 +131,11 @@ public class AInt8ConstructorDescriptor extends AbstractScalarFunctionDynamicDes aInt8.setValue(value); int8Serde.serialize(aInt8, out); + result.set(resultStorage); } else { - throw new InvalidDataFormatException(getIdentifier(), - ATypeTag.SERIALIZED_INT8_TYPE_TAG); + throw new TypeMismatchException(getIdentifier(), 0, tt, + ATypeTag.SERIALIZED_STRING_TYPE_TAG); } - result.set(resultStorage); } catch (IOException e1) { throw new InvalidDataFormatException(getIdentifier(), e1, ATypeTag.SERIALIZED_INT8_TYPE_TAG); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ALineConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ALineConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ALineConstructorDescriptor.java index 2e8a850..0ef585c 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ALineConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ALineConstructorDescriptor.java @@ -71,20 +71,23 @@ public class ALineConstructorDescriptor extends AbstractScalarFunctionDynamicDes private AMutableLine aLine = new AMutableLine(null, null); private AMutablePoint[] aPoint = { new AMutablePoint(0, 0), new AMutablePoint(0, 0) }; @SuppressWarnings("unchecked") - private ISerializerDeserializer<ALine> lineSerde = SerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.ALINE); + private ISerializerDeserializer<ALine> lineSerde = + SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ALINE); private final UTF8StringPointable utf8Ptr = new UTF8StringPointable(); @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { try { - resultStorage.reset(); eval.evaluate(tuple, inputArg); byte[] serString = inputArg.getByteArray(); int offset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[offset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[offset]; + if (tt == ATypeTag.SERIALIZED_LINE_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + resultStorage.reset(); utf8Ptr.set(serString, offset + 1, len - 1); String s = utf8Ptr.toString(); int commaIndex = s.indexOf(','); @@ -96,11 +99,11 @@ public class ALineConstructorDescriptor extends AbstractScalarFunctionDynamicDes Double.parseDouble(s.substring(commaIndex + 1, s.length()))); aLine.setValue(aPoint[0], aPoint[1]); lineSerde.serialize(aLine, out); + result.set(resultStorage); } else { - throw new TypeMismatchException(getIdentifier(), 0, serString[offset], + throw new TypeMismatchException(getIdentifier(), 0, tt, ATypeTag.SERIALIZED_STRING_TYPE_TAG); } - result.set(resultStorage); } catch (IOException e) { throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ANullConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ANullConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ANullConstructorDescriptor.java deleted file mode 100644 index 2df7d97..0000000 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ANullConstructorDescriptor.java +++ /dev/null @@ -1,114 +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.constructors; - -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.asterix.formats.nontagged.BinaryComparatorFactoryProvider; -import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider; -import org.apache.asterix.om.base.AMissing; -import org.apache.asterix.om.functions.BuiltinFunctions; -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.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; -import org.apache.asterix.runtime.exceptions.InvalidDataFormatException; -import org.apache.asterix.runtime.exceptions.TypeMismatchException; -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.IBinaryComparator; -import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer; -import org.apache.hyracks.api.exceptions.HyracksDataException; -import org.apache.hyracks.data.std.api.IPointable; -import org.apache.hyracks.data.std.primitive.VoidPointable; -import org.apache.hyracks.data.std.util.ArrayBackedValueStorage; -import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference; -import org.apache.hyracks.util.string.UTF8StringUtil; - -public class ANullConstructorDescriptor extends AbstractScalarFunctionDynamicDescriptor { - private static final long serialVersionUID = 1L; - public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { - @Override - public IFunctionDescriptor createFunctionDescriptor() { - return new ANullConstructorDescriptor(); - } - }; - - @Override - public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) { - return new IScalarEvaluatorFactory() { - private static final long serialVersionUID = 1L; - - @Override - public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException { - return new IScalarEvaluator() { - - private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage(); - private DataOutput out = resultStorage.getDataOutput(); - private IPointable inputArg = new VoidPointable(); - private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx); - private final byte[] NULL = UTF8StringUtil.writeStringToBytes("null"); - IBinaryComparator utf8BinaryComparator = - BinaryComparatorFactoryProvider.UTF8STRING_POINTABLE_INSTANCE.createBinaryComparator(); - @SuppressWarnings("unchecked") - private ISerializerDeserializer<AMissing> nullSerde = SerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.AMISSING); - - @Override - public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { - try { - eval.evaluate(tuple, inputArg); - byte[] serString = inputArg.getByteArray(); - int offset = inputArg.getStartOffset(); - int len = inputArg.getLength(); - - if (serString[offset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { - if (utf8BinaryComparator.compare(serString, offset + 1, len - 1, NULL, 0, - NULL.length) == 0) { - resultStorage.reset(); - nullSerde.serialize(AMissing.MISSING, out); - result.set(resultStorage); - return; - } else { - throw new InvalidDataFormatException(getIdentifier(), - ATypeTag.SERIALIZED_NULL_TYPE_TAG); - } - } else { - throw new TypeMismatchException(getIdentifier(), 0, serString[offset], - ATypeTag.SERIALIZED_STRING_TYPE_TAG); - } - } catch (IOException e) { - throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_NULL_TYPE_TAG); - } - } - }; - } - }; - } - - @Override - public FunctionIdentifier getIdentifier() { - return BuiltinFunctions.NULL_CONSTRUCTOR; - } - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APoint3DConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APoint3DConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APoint3DConstructorDescriptor.java index 23cccb7..3415f38 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APoint3DConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APoint3DConstructorDescriptor.java @@ -69,20 +69,23 @@ public class APoint3DConstructorDescriptor extends AbstractScalarFunctionDynamic private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx); private AMutablePoint3D aPoint3D = new AMutablePoint3D(0, 0, 0); @SuppressWarnings("unchecked") - private ISerializerDeserializer<APoint3D> point3DSerde = SerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.APOINT3D); + private ISerializerDeserializer<APoint3D> point3DSerde = + SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.APOINT3D); private final UTF8StringPointable utf8Ptr = new UTF8StringPointable(); @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { try { - resultStorage.reset(); eval.evaluate(tuple, inputArg); byte[] serString = inputArg.getByteArray(); int offset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[offset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[offset]; + if (tt == ATypeTag.SERIALIZED_POINT3D_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + resultStorage.reset(); utf8Ptr.set(serString, offset + 1, len - 1); String s = utf8Ptr.toString(); int firstCommaIndex = s.indexOf(','); @@ -91,14 +94,14 @@ public class APoint3DConstructorDescriptor extends AbstractScalarFunctionDynamic Double.parseDouble(s.substring(firstCommaIndex + 1, secondCommaIndex)), Double.parseDouble(s.substring(secondCommaIndex + 1, s.length()))); point3DSerde.serialize(aPoint3D, out); + result.set(resultStorage); } else { - throw new TypeMismatchException(getIdentifier(), 0, serString[offset], + throw new TypeMismatchException(getIdentifier(), 0, tt, ATypeTag.SERIALIZED_STRING_TYPE_TAG); } - result.set(resultStorage); } catch (IOException e) { throw new InvalidDataFormatException(getIdentifier(), e, - ATypeTag.SERIALIZED_POINT_TYPE_TAG); + ATypeTag.SERIALIZED_POINT3D_TYPE_TAG); } } }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APointConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APointConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APointConstructorDescriptor.java index 739d084..24045b9 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APointConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APointConstructorDescriptor.java @@ -68,31 +68,33 @@ public class APointConstructorDescriptor extends AbstractScalarFunctionDynamicDe private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx); private AMutablePoint aPoint = new AMutablePoint(0, 0); @SuppressWarnings("unchecked") - private ISerializerDeserializer<APoint> pointSerde = SerializerDeserializerProvider.INSTANCE - .getSerializerDeserializer(BuiltinType.APOINT); + private ISerializerDeserializer<APoint> pointSerde = + SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.APOINT); private final UTF8StringPointable utf8Ptr = new UTF8StringPointable(); @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { - try { - resultStorage.reset(); eval.evaluate(tuple, inputArg); byte[] serString = inputArg.getByteArray(); int offset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[offset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[offset]; + if (tt == ATypeTag.SERIALIZED_POINT_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + resultStorage.reset(); utf8Ptr.set(serString, offset + 1, len - 1); String s = utf8Ptr.toString(); aPoint.setValue(Double.parseDouble(s.substring(0, s.indexOf(','))), Double.parseDouble(s.substring(s.indexOf(',') + 1, s.length()))); pointSerde.serialize(aPoint, out); + result.set(resultStorage); } else { - throw new TypeMismatchException(getIdentifier(), 0, serString[offset], + throw new TypeMismatchException(getIdentifier(), 0, tt, ATypeTag.SERIALIZED_STRING_TYPE_TAG); } - result.set(resultStorage); } catch (IOException e) { throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_POINT_TYPE_TAG); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APolygonConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APolygonConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APolygonConstructorDescriptor.java index e43c550..eb139b0 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APolygonConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APolygonConstructorDescriptor.java @@ -72,13 +72,16 @@ public class APolygonConstructorDescriptor extends AbstractScalarFunctionDynamic @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { try { - resultStorage.reset(); eval.evaluate(tuple, inputArg); byte[] serString = inputArg.getByteArray(); int offset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[offset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[offset]; + if (tt == ATypeTag.SERIALIZED_POLYGON_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + resultStorage.reset(); utf8Ptr.set(serString, offset + 1, len - 1); String s = utf8Ptr.toString(); String[] points = WS.split(s.trim()); @@ -93,11 +96,11 @@ public class APolygonConstructorDescriptor extends AbstractScalarFunctionDynamic APointSerializerDeserializer.serialize(Double.parseDouble(point[0]), Double.parseDouble(point[1]), out); } + result.set(resultStorage); } else { - throw new TypeMismatchException(getIdentifier(), 0, serString[offset], + throw new TypeMismatchException(getIdentifier(), 0, tt, ATypeTag.SERIALIZED_STRING_TYPE_TAG); } - result.set(resultStorage); } catch (IOException e) { throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_POLYGON_TYPE_TAG); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ARectangleConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ARectangleConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ARectangleConstructorDescriptor.java index ef03dc2..ccaf7b8 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ARectangleConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ARectangleConstructorDescriptor.java @@ -77,13 +77,16 @@ public class ARectangleConstructorDescriptor extends AbstractScalarFunctionDynam @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { try { - resultStorage.reset(); eval.evaluate(tuple, inputArg); byte[] serString = inputArg.getByteArray(); int offset = inputArg.getStartOffset(); int len = inputArg.getLength(); - if (serString[offset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + byte tt = serString[offset]; + if (tt == ATypeTag.SERIALIZED_RECTANGLE_TYPE_TAG) { + result.set(inputArg); + } else if (tt == ATypeTag.SERIALIZED_STRING_TYPE_TAG) { + resultStorage.reset(); utf8Ptr.set(serString, offset + 1, len - 1); String s = utf8Ptr.toString(); int commaIndex = s.indexOf(','); @@ -102,11 +105,11 @@ public class ARectangleConstructorDescriptor extends AbstractScalarFunctionDynam ATypeTag.SERIALIZED_RECTANGLE_TYPE_TAG); } rectangle2DSerde.serialize(aRectangle, out); + result.set(resultStorage); } else { - throw new TypeMismatchException(getIdentifier(), 0, serString[offset], + throw new TypeMismatchException(getIdentifier(), 0, tt, ATypeTag.SERIALIZED_STRING_TYPE_TAG); } - result.set(resultStorage); } catch (IOException e) { throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_RECTANGLE_TYPE_TAG); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/fe00b1af/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AStringConstructorDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AStringConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AStringConstructorDescriptor.java index 681ff16..3c59c4c 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AStringConstructorDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AStringConstructorDescriptor.java @@ -76,8 +76,6 @@ public class AStringConstructorDescriptor extends AbstractScalarFunctionDynamicD @Override public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException { try { - resultStorage.reset(); - baaos.reset(); eval.evaluate(tuple, inputArg); byte[] serString = inputArg.getByteArray(); int offset = inputArg.getStartOffset(); @@ -87,6 +85,8 @@ public class AStringConstructorDescriptor extends AbstractScalarFunctionDynamicD if (tt == ATypeTag.STRING) { result.set(inputArg); } else { + resultStorage.reset(); + baaos.reset(); builder.reset(baaos, len); int startOffset = offset + 1; switch (tt) {
