asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amo...@apache.org
Subject [04/13] incubator-asterixdb git commit: Add Support for Upsert Operation
Date Mon, 01 Feb 2016 08:31:23 GMT
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SimilarityDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SimilarityDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SimilarityDescriptor.java
index 1962a93..e66fceb 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SimilarityDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SimilarityDescriptor.java
@@ -55,14 +55,8 @@ public class SimilarityDescriptor extends AbstractScalarFunctionDynamicDescripto
     private static final long serialVersionUID = 1L;
     private final static FunctionIdentifier FID = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "similarity@7",
             7);
-
-    private final static byte SER_DOUBLE_TYPE_TAG = ATypeTag.DOUBLE.serialize();
-    private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
-    private final static byte SER_INT32_TYPE_TAG = ATypeTag.INT32.serialize();
-    private final static byte SER_ORDEREDLIST_TYPE_TAG = ATypeTag.ORDEREDLIST.serialize();
-    private final static byte SER_UNORDEREDLIST_TYPE_TAG = ATypeTag.UNORDEREDLIST.serialize();
-
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SimilarityDescriptor();
         }
@@ -106,18 +100,18 @@ public class SimilarityDescriptor extends AbstractScalarFunctionDynamicDescripto
                         // similarity threshold
                         inputVal.reset();
                         evalThreshold.evaluate(tuple);
-                        if (inputVal.getByteArray()[0] != SER_DOUBLE_TYPE_TAG) {
+                        if (inputVal.getByteArray()[0] != ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG) {
                             throw new AlgebricksException(FID.getName()
                                     + ": expects type DOUBLE for the first argument but got "
                                     + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(inputVal.getByteArray()[0]));
                         }
-                        float similarityThreshold = (float) ADoubleSerializerDeserializer.getDouble(
-                                inputVal.getByteArray(), 1);
+                        float similarityThreshold = (float) ADoubleSerializerDeserializer
+                                .getDouble(inputVal.getByteArray(), 1);
 
                         // similarity name
                         inputVal.reset();
                         evalSimilarity.evaluate(tuple);
-                        if (inputVal.getByteArray()[0] != SER_STRING_TYPE_TAG) {
+                        if (inputVal.getByteArray()[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
                             throw new AlgebricksException(FID.getName()
                                     + ": expects type STRING for the second argument but got "
                                     + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(inputVal.getByteArray()[0]));
@@ -127,7 +121,7 @@ public class SimilarityDescriptor extends AbstractScalarFunctionDynamicDescripto
 
                         inputVal.reset();
                         evalLen1.evaluate(tuple);
-                        if (inputVal.getByteArray()[0] != SER_INT32_TYPE_TAG) {
+                        if (inputVal.getByteArray()[0] != ATypeTag.SERIALIZED_INT32_TYPE_TAG) {
                             throw new AlgebricksException(FID.getName()
                                     + ": expects type INT32 for the thrid argument but got "
                                     + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(inputVal.getByteArray()[0]));
@@ -136,7 +130,7 @@ public class SimilarityDescriptor extends AbstractScalarFunctionDynamicDescripto
 
                         inputVal.reset();
                         evalLen2.evaluate(tuple);
-                        if (inputVal.getByteArray()[0] != SER_INT32_TYPE_TAG) {
+                        if (inputVal.getByteArray()[0] != ATypeTag.SERIALIZED_INT32_TYPE_TAG) {
                             throw new AlgebricksException(FID.getName()
                                     + ": expects type INT32 for the fourth argument but got "
                                     + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(inputVal.getByteArray()[0]));
@@ -157,15 +151,16 @@ public class SimilarityDescriptor extends AbstractScalarFunctionDynamicDescripto
                             evalTokens1.evaluate(tuple);
 
                             byte[] serList = inputVal.getByteArray();
-                            if (serList[0] != SER_ORDEREDLIST_TYPE_TAG && serList[0] != SER_UNORDEREDLIST_TYPE_TAG) {
+                            if (serList[0] != ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG
+                                    && serList[0] != ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG) {
                                 throw new AlgebricksException(FID.getName() + ": not defined for values of type"
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serList[0]));
                             }
 
                             int lengthTokens1;
-                            if (serList[0] == SER_ORDEREDLIST_TYPE_TAG) {
-                                lengthTokens1 = AOrderedListSerializerDeserializer.getNumberOfItems(inputVal
-                                        .getByteArray());
+                            if (serList[0] == ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG) {
+                                lengthTokens1 = AOrderedListSerializerDeserializer
+                                        .getNumberOfItems(inputVal.getByteArray());
                                 // read tokens
                                 for (i = 0; i < lengthTokens1; i++) {
                                     int itemOffset;
@@ -177,8 +172,8 @@ public class SimilarityDescriptor extends AbstractScalarFunctionDynamicDescripto
                                     tokens1.add(IntegerPointable.getInteger(serList, itemOffset));
                                 }
                             } else {
-                                lengthTokens1 = AUnorderedListSerializerDeserializer.getNumberOfItems(inputVal
-                                        .getByteArray());
+                                lengthTokens1 = AUnorderedListSerializerDeserializer
+                                        .getNumberOfItems(inputVal.getByteArray());
                                 // read tokens
                                 for (i = 0; i < lengthTokens1; i++) {
                                     int itemOffset;
@@ -201,15 +196,16 @@ public class SimilarityDescriptor extends AbstractScalarFunctionDynamicDescripto
                             evalTokens2.evaluate(tuple);
 
                             serList = inputVal.getByteArray();
-                            if (serList[0] != SER_ORDEREDLIST_TYPE_TAG && serList[0] != SER_UNORDEREDLIST_TYPE_TAG) {
+                            if (serList[0] != ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG
+                                    && serList[0] != ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG) {
                                 throw new AlgebricksException(FID.getName() + ": not defined for values of type"
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serList[0]));
                             }
 
                             int lengthTokens2;
-                            if (serList[0] == SER_ORDEREDLIST_TYPE_TAG) {
-                                lengthTokens2 = AOrderedListSerializerDeserializer.getNumberOfItems(inputVal
-                                        .getByteArray());
+                            if (serList[0] == ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG) {
+                                lengthTokens2 = AOrderedListSerializerDeserializer
+                                        .getNumberOfItems(inputVal.getByteArray());
                                 // read tokens
                                 for (i = 0; i < lengthTokens2; i++) {
                                     int itemOffset;
@@ -221,8 +217,8 @@ public class SimilarityDescriptor extends AbstractScalarFunctionDynamicDescripto
                                     tokens2.add(IntegerPointable.getInteger(serList, itemOffset));
                                 }
                             } else {
-                                lengthTokens2 = AUnorderedListSerializerDeserializer.getNumberOfItems(inputVal
-                                        .getByteArray());
+                                lengthTokens2 = AUnorderedListSerializerDeserializer
+                                        .getNumberOfItems(inputVal.getByteArray());
                                 // read tokens
                                 for (i = 0; i < lengthTokens2; i++) {
                                     int itemOffset;
@@ -249,8 +245,8 @@ public class SimilarityDescriptor extends AbstractScalarFunctionDynamicDescripto
                             //
                             SimilarityMetric.getPartialIntersectSize(tokens1.get(), 0, tokens1.length(), tokens2.get(),
                                     0, tokens2.length(), tokenPrefix, parInter);
-                            if (similarityFilters.passPositionFilter(parInter.intersectSize, parInter.posXStop,
-                                    length1, parInter.posYStop, length2)) {
+                            if (similarityFilters.passPositionFilter(parInter.intersectSize, parInter.posXStop, length1,
+                                    parInter.posYStop, length2)) {
 
                                 //
                                 // -- - suffix filter - --

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialAreaDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialAreaDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialAreaDescriptor.java
index 12e2cb0..a3ad867 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialAreaDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialAreaDescriptor.java
@@ -51,6 +51,7 @@ public class SpatialAreaDescriptor extends AbstractScalarFunctionDynamicDescript
 
     private static final long serialVersionUID = 1L;
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SpatialAreaDescriptor();
         }
@@ -92,14 +93,14 @@ public class SpatialAreaDescriptor extends AbstractScalarFunctionDynamicDescript
                                                 + ": polygon must have at least 3 points");
                                     }
                                     area = Math.abs(SpatialUtils.polygonArea(argOut.getByteArray(), numOfPoints));
-                                    out.writeByte(ATypeTag.DOUBLE.serialize());
+                                    out.writeByte(ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG);
                                     out.writeDouble(area);
                                     break;
                                 case CIRCLE:
                                     double radius = ADoubleSerializerDeserializer.getDouble(argOut.getByteArray(),
                                             ACircleSerializerDeserializer.getRadiusOffset());
                                     area = SpatialUtils.pi() * radius * radius;
-                                    out.writeByte(ATypeTag.DOUBLE.serialize());
+                                    out.writeByte(ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG);
                                     out.writeDouble(area);
                                     break;
                                 case RECTANGLE:
@@ -117,7 +118,7 @@ public class SpatialAreaDescriptor extends AbstractScalarFunctionDynamicDescript
                                             ARectangleSerializerDeserializer
                                                     .getUpperRightCoordinateOffset(Coordinate.Y));
                                     area = (x2 - x1) * (y2 - y1);
-                                    out.writeByte(ATypeTag.DOUBLE.serialize());
+                                    out.writeByte(ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG);
                                     out.writeDouble(area);
                                     break;
                                 case NULL:

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialDistanceDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialDistanceDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialDistanceDescriptor.java
index ad86c64..70adde4 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialDistanceDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialDistanceDescriptor.java
@@ -48,6 +48,7 @@ public class SpatialDistanceDescriptor extends AbstractScalarFunctionDynamicDesc
 
     private static final long serialVersionUID = 1L;
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SpatialDistanceDescriptor();
         }
@@ -97,10 +98,9 @@ public class SpatialDistanceDescriptor extends AbstractScalarFunctionDynamicDesc
                                             APointSerializerDeserializer.getCoordinateOffset(Coordinate.Y));
                                     distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
                                 } else {
-                                    throw new NotImplementedException(
-                                            AsterixBuiltinFunctions.SPATIAL_DISTANCE.getName()
-                                                    + ": does not support the type: " + tag1
-                                                    + "; it is only implemented for POINT.");
+                                    throw new NotImplementedException(AsterixBuiltinFunctions.SPATIAL_DISTANCE.getName()
+                                            + ": does not support the type: " + tag1
+                                            + "; it is only implemented for POINT.");
                                 }
                             } else if (tag0 == ATypeTag.NULL || tag1 == ATypeTag.NULL) {
                                 nullSerde.serialize(ANull.NULL, out);
@@ -109,7 +109,7 @@ public class SpatialDistanceDescriptor extends AbstractScalarFunctionDynamicDesc
                                         + ": does not support the type: " + tag1
                                         + "; it is only implemented for POINT.");
                             }
-                            out.writeByte(ATypeTag.DOUBLE.serialize());
+                            out.writeByte(ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG);
                             out.writeDouble(distance);
                         } catch (HyracksDataException hde) {
                             throw new AlgebricksException(hde);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringConcatDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringConcatDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringConcatDescriptor.java
index b3feba7..52734b2 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringConcatDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringConcatDescriptor.java
@@ -45,11 +45,8 @@ import org.apache.hyracks.util.string.UTF8StringUtil;
 public class StringConcatDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     private static final long serialVersionUID = 1L;
-
-    private static final byte SER_ORDEREDLIST_TYPE_TAG = ATypeTag.ORDEREDLIST.serialize();
-    private static final byte SER_UNORDEREDLIST_TYPE_TAG = ATypeTag.UNORDEREDLIST.serialize();
-
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
         public IFunctionDescriptor createFunctionDescriptor() {
             return new StringConcatDescriptor();
         }
@@ -81,8 +78,8 @@ public class StringConcatDescriptor extends AbstractScalarFunctionDynamicDescrip
                             outInputList.reset();
                             evalList.evaluate(tuple);
                             byte[] listBytes = outInputList.getByteArray();
-                            if (listBytes[0] != SER_ORDEREDLIST_TYPE_TAG
-                                    && listBytes[0] != SER_UNORDEREDLIST_TYPE_TAG) {
+                            if (listBytes[0] != ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG
+                                    && listBytes[0] != ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG) {
                                 throw new AlgebricksException(AsterixBuiltinFunctions.STRING_CONCAT.getName()
                                         + ": expects input type ORDEREDLIST/UNORDEREDLIST, but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(listBytes[0]));
@@ -113,7 +110,7 @@ public class StringConcatDescriptor extends AbstractScalarFunctionDynamicDescrip
                                     }
                                     utf8Len += UTF8StringUtil.getUTFLength(listBytes, itemOffset);
                                 }
-                                out.writeByte(ATypeTag.STRING.serialize());
+                                out.writeByte(ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                                 int cbytes = UTF8StringUtil.encodeUTF8Length(utf8Len, tempLengthArray, 0);
                                 out.write(tempLengthArray, 0, cbytes);
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringJoinDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringJoinDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringJoinDescriptor.java
index 650beb0..866d6c4 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringJoinDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringJoinDescriptor.java
@@ -42,13 +42,11 @@ public class StringJoinDescriptor extends AbstractScalarFunctionDynamicDescripto
 
     private static final long serialVersionUID = 1L;
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
         public IFunctionDescriptor createFunctionDescriptor() {
             return new StringJoinDescriptor();
         }
     };
-    private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
-    private final static byte SER_ORDEREDLIST_TYPE_TAG = ATypeTag.ORDEREDLIST.serialize();
-    private final byte stringTypeTag = ATypeTag.STRING.serialize();
 
     @Override
     public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) {
@@ -79,14 +77,14 @@ public class StringJoinDescriptor extends AbstractScalarFunctionDynamicDescripto
                             outInputSep.reset();
                             evalSep.evaluate(tuple);
                             byte[] serSep = outInputSep.getByteArray();
-                            if (serOrderedList[0] != SER_ORDEREDLIST_TYPE_TAG
-                                    && serOrderedList[1] != SER_STRING_TYPE_TAG) {
+                            if (serOrderedList[0] != ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG
+                                    && serOrderedList[1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
                                 throw new AlgebricksException(AsterixBuiltinFunctions.STRING_JOIN.getName()
                                         + ": expects input type ORDEREDLIST but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serOrderedList[0]));
                             }
 
-                            if (serSep[0] != SER_STRING_TYPE_TAG) {
+                            if (serSep[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
                                 throw new AlgebricksException(AsterixBuiltinFunctions.STRING_JOIN.getName()
                                         + ": expects STRING type for the seperator but got "
                                         + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serSep[0]));
@@ -100,8 +98,8 @@ public class StringJoinDescriptor extends AbstractScalarFunctionDynamicDescripto
                                 int sep_meta_len = UTF8StringUtil.getNumBytesToStoreLength(sep_len);
 
                                 for (int i = 0; i < size; i++) {
-                                    int itemOffset = AOrderedListSerializerDeserializer
-                                            .getItemOffset(serOrderedList, i);
+                                    int itemOffset = AOrderedListSerializerDeserializer.getItemOffset(serOrderedList,
+                                            i);
 
                                     int currentSize = UTF8StringUtil.getUTFLength(serOrderedList, itemOffset);
                                     if (i != size - 1 && currentSize != 0) {
@@ -109,12 +107,12 @@ public class StringJoinDescriptor extends AbstractScalarFunctionDynamicDescripto
                                     }
                                     utf_8_len += currentSize;
                                 }
-                                out.writeByte(stringTypeTag);
+                                out.writeByte(ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                                 int length = UTF8StringUtil.encodeUTF8Length(utf_8_len, tempLengthArray, 0);
                                 out.write(tempLengthArray, 0, length);
                                 for (int i = 0; i < size; i++) {
-                                    int itemOffset = AOrderedListSerializerDeserializer
-                                            .getItemOffset(serOrderedList, i);
+                                    int itemOffset = AOrderedListSerializerDeserializer.getItemOffset(serOrderedList,
+                                            i);
                                     utf_8_len = UTF8StringUtil.getUTFLength(serOrderedList, itemOffset);
                                     out.write(serOrderedList,
                                             itemOffset + UTF8StringUtil.getNumBytesToStoreLength(utf_8_len), utf_8_len);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringLengthDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringLengthDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringLengthDescriptor.java
index 47ecb5b..5a6c1a0 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringLengthDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringLengthDescriptor.java
@@ -43,7 +43,6 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 import org.apache.hyracks.util.string.UTF8StringUtil;
 
 public class StringLengthDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private static final long serialVersionUID = 1L;
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         @Override
@@ -51,8 +50,6 @@ public class StringLengthDescriptor extends AbstractScalarFunctionDynamicDescrip
             return new StringLengthDescriptor();
         }
     };
-    private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
 
     @Override
     public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) {
@@ -80,11 +77,11 @@ public class StringLengthDescriptor extends AbstractScalarFunctionDynamicDescrip
                             outInput.reset();
                             eval.evaluate(tuple);
                             byte[] serString = outInput.getByteArray();
-                            if (serString[0] == SER_STRING_TYPE_TAG) {
+                            if (serString[0] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
                                 int len = UTF8StringUtil.getUTFLength(outInput.getByteArray(), 1);
                                 result.setValue(len);
                                 int64Serde.serialize(result, out);
-                            } else if (serString[0] == SER_NULL_TYPE_TAG)
+                            } else if (serString[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG)
                                 nullSerde.serialize(ANull.NULL, out);
                             else {
                                 throw new AlgebricksException(AsterixBuiltinFunctions.STRING_LENGTH.getName()

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringLowerCaseDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringLowerCaseDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringLowerCaseDescriptor.java
index 66212f7..7ae1e89 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringLowerCaseDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringLowerCaseDescriptor.java
@@ -46,12 +46,11 @@ public class StringLowerCaseDescriptor extends AbstractScalarFunctionDynamicDesc
     private static final long serialVersionUID = 1L;
 
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
         public IFunctionDescriptor createFunctionDescriptor() {
             return new StringLowerCaseDescriptor();
         }
     };
-    private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
 
     @Override
     public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) {
@@ -70,8 +69,6 @@ public class StringLowerCaseDescriptor extends AbstractScalarFunctionDynamicDesc
                     private final UTF8StringBuilder builder = new UTF8StringBuilder();
                     private final UTF8StringPointable string = new UTF8StringPointable();
 
-                    private final byte stt = ATypeTag.STRING.serialize();
-
                     @SuppressWarnings("unchecked")
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
                             .getSerializerDeserializer(BuiltinType.ANULL);
@@ -84,14 +81,14 @@ public class StringLowerCaseDescriptor extends AbstractScalarFunctionDynamicDesc
                             eval.evaluate(tuple);
                             byte[] serString = outInput.getByteArray();
 
-                            if (serString[0] == SER_STRING_TYPE_TAG) {
+                            if (serString[0] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
                                 string.set(serString, 1, serString.length);
                                 array.reset();
                                 UTF8StringPointable.lowercase(string, builder, array);
 
-                                out.writeByte(stt);
+                                out.writeByte(ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                                 out.write(array.getByteArray(), 0, array.getLength());
-                            } else if (serString[0] == SER_NULL_TYPE_TAG)
+                            } else if (serString[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG)
                                 nullSerde.serialize(ANull.NULL, out);
                             else
                                 throw new AlgebricksException(AsterixBuiltinFunctions.STRING_LOWERCASE.getName()

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringToCodePointDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringToCodePointDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringToCodePointDescriptor.java
index 654e0b6..f75b8e3 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringToCodePointDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringToCodePointDescriptor.java
@@ -48,11 +48,11 @@ public class StringToCodePointDescriptor extends AbstractScalarFunctionDynamicDe
     private static final long serialVersionUID = 1L;
 
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
         public IFunctionDescriptor createFunctionDescriptor() {
             return new StringToCodePointDescriptor();
         }
     };
-    private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
 
     @Override
     public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) {
@@ -62,8 +62,7 @@ public class StringToCodePointDescriptor extends AbstractScalarFunctionDynamicDe
             @Override
             public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
                 return new ICopyEvaluator() {
-                    protected final DataOutput out = output.getDataOutput();
-                    ;
+                    protected final DataOutput out = output.getDataOutput();;
                     protected final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
                     protected final ICopyEvaluator stringEval = args[0].createEvaluator(argOut);
                     protected final AOrderedListType intListType = new AOrderedListType(BuiltinType.AINT64, null);
@@ -83,7 +82,7 @@ public class StringToCodePointDescriptor extends AbstractScalarFunctionDynamicDe
                             stringEval.evaluate(tuple);
                             byte[] serString = argOut.getByteArray();
 
-                            if (serString[0] == SER_STRING_TYPE_TAG) {
+                            if (serString[0] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
                                 byte[] bytes = argOut.getByteArray();
                                 int len = UTF8StringUtil.getUTFLength(bytes, 1);
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringUpperCaseDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringUpperCaseDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringUpperCaseDescriptor.java
index fc32dfd..02e495f 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringUpperCaseDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringUpperCaseDescriptor.java
@@ -46,12 +46,11 @@ public class StringUpperCaseDescriptor extends AbstractScalarFunctionDynamicDesc
     private static final long serialVersionUID = 1L;
 
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
         public IFunctionDescriptor createFunctionDescriptor() {
             return new StringUpperCaseDescriptor();
         }
     };
-    private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
 
     @Override
     public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) {
@@ -66,7 +65,7 @@ public class StringUpperCaseDescriptor extends AbstractScalarFunctionDynamicDesc
                     private ArrayBackedValueStorage outInput = new ArrayBackedValueStorage();
                     private ICopyEvaluator eval = args[0].createEvaluator(outInput);
 
-                    private final byte stt = ATypeTag.STRING.serialize();
+                    private final byte stt = ATypeTag.SERIALIZED_STRING_TYPE_TAG;
 
                     private final GrowableArray array = new GrowableArray();
                     private final UTF8StringBuilder builder = new UTF8StringBuilder();
@@ -84,14 +83,14 @@ public class StringUpperCaseDescriptor extends AbstractScalarFunctionDynamicDesc
                             eval.evaluate(tuple);
                             byte[] serString = outInput.getByteArray();
 
-                            if (serString[0] == SER_STRING_TYPE_TAG) {
+                            if (serString[0] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
                                 string.set(serString, 1, serString.length);
                                 array.reset();
                                 UTF8StringPointable.uppercase(string, builder, array);
 
                                 out.writeByte(stt);
                                 out.write(array.getByteArray(), 0, array.getLength());
-                            } else if (serString[0] == SER_NULL_TYPE_TAG)
+                            } else if (serString[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG)
                                 nullSerde.serialize(ANull.NULL, out);
                             else
                                 throw new AlgebricksException(AsterixBuiltinFunctions.STRING_UPPERCASE.getName()

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java
index f843051..a3076ce 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java
@@ -41,13 +41,9 @@ import org.apache.hyracks.data.std.util.UTF8StringBuilder;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public class Substring2Descriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private static final long serialVersionUID = 1L;
-
-    // allowed input types
-    private static final byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
-
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
         public IFunctionDescriptor createFunctionDescriptor() {
             return new Substring2Descriptor();
         }
@@ -66,7 +62,6 @@ public class Substring2Descriptor extends AbstractScalarFunctionDynamicDescripto
                     private ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
                     private ICopyEvaluator evalString = args[0].createEvaluator(argOut);
                     private ICopyEvaluator evalStart = args[1].createEvaluator(argOut);
-                    private final byte stt = ATypeTag.STRING.serialize();
 
                     private final GrowableArray array = new GrowableArray();
                     private final UTF8StringBuilder builder = new UTF8StringBuilder();
@@ -87,7 +82,7 @@ public class Substring2Descriptor extends AbstractScalarFunctionDynamicDescripto
                         evalString.evaluate(tuple);
 
                         byte[] bytes = argOut.getByteArray();
-                        if (bytes[0] != SER_STRING_TYPE_TAG) {
+                        if (bytes[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
                             throw new AlgebricksException(AsterixBuiltinFunctions.SUBSTRING2.getName()
                                     + ": expects type STRING for the first argument but got "
                                     + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut.getByteArray()[0]));
@@ -104,7 +99,7 @@ public class Substring2Descriptor extends AbstractScalarFunctionDynamicDescripto
                         }
 
                         try {
-                            out.writeByte(stt);
+                            out.writeByte(ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                             out.write(array.getByteArray(), 0, array.getLength());
                         } catch (IOException e) {
                             throw new AlgebricksException(e);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringAfterDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringAfterDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringAfterDescriptor.java
index ff84986..78f5a66 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringAfterDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringAfterDescriptor.java
@@ -39,14 +39,9 @@ import org.apache.hyracks.data.std.util.UTF8StringBuilder;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public class SubstringAfterDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private static final long serialVersionUID = 1L;
-
-    // allowed input types
-    private static final byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
-    private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SubstringAfterDescriptor();
         }
@@ -66,8 +61,6 @@ public class SubstringAfterDescriptor extends AbstractScalarFunctionDynamicDescr
                     private ArrayBackedValueStorage array1 = new ArrayBackedValueStorage();
                     private ICopyEvaluator evalString = args[0].createEvaluator(array0);
                     private ICopyEvaluator evalPattern = args[1].createEvaluator(array1);
-                    private final byte stt = ATypeTag.STRING.serialize();
-
                     private final GrowableArray array = new GrowableArray();
                     private final UTF8StringBuilder builder = new UTF8StringBuilder();
                     private final UTF8StringPointable stringPtr = new UTF8StringPointable();
@@ -83,8 +76,10 @@ public class SubstringAfterDescriptor extends AbstractScalarFunctionDynamicDescr
                         evalPattern.evaluate(tuple);
                         byte[] pattern = array1.getByteArray();
 
-                        if ((src[0] != SER_STRING_TYPE_TAG && src[0] != SER_NULL_TYPE_TAG)
-                                || (pattern[0] != SER_STRING_TYPE_TAG && pattern[0] != SER_NULL_TYPE_TAG)) {
+                        if ((src[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+                                && src[0] != ATypeTag.SERIALIZED_NULL_TYPE_TAG)
+                                || (pattern[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+                                        && pattern[0] != ATypeTag.SERIALIZED_NULL_TYPE_TAG)) {
                             throw new AlgebricksException(AsterixBuiltinFunctions.SUBSTRING_AFTER.getName()
                                     + ": expects input type (STRING/NULL, STRING/NULL) but got ("
                                     + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(src[0]) + ", "
@@ -96,7 +91,7 @@ public class SubstringAfterDescriptor extends AbstractScalarFunctionDynamicDescr
                         array.reset();
                         try {
                             UTF8StringPointable.substrAfter(stringPtr, patternPtr, builder, array);
-                            out.writeByte(stt);
+                            out.writeByte(ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                             out.write(array.getByteArray(), 0, array.getLength());
                         } catch (IOException e) {
                             throw new AlgebricksException(e);
@@ -105,11 +100,11 @@ public class SubstringAfterDescriptor extends AbstractScalarFunctionDynamicDescr
                     }
                 }
 
-                        ;
+                ;
             }
         }
 
-                ;
+        ;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringBeforeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringBeforeDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringBeforeDescriptor.java
index 3871ed7..dd9a91a 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringBeforeDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringBeforeDescriptor.java
@@ -39,14 +39,9 @@ import org.apache.hyracks.data.std.util.UTF8StringBuilder;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public class SubstringBeforeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private static final long serialVersionUID = 1L;
-
-    // allowed input types
-    private static final byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
-    private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SubstringBeforeDescriptor();
         }
@@ -60,14 +55,11 @@ public class SubstringBeforeDescriptor extends AbstractScalarFunctionDynamicDesc
             @Override
             public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
                 return new ICopyEvaluator() {
-
                     private DataOutput out = output.getDataOutput();
                     private ArrayBackedValueStorage array0 = new ArrayBackedValueStorage();
                     private ArrayBackedValueStorage array1 = new ArrayBackedValueStorage();
                     private ICopyEvaluator evalString = args[0].createEvaluator(array0);
                     private ICopyEvaluator evalPattern = args[1].createEvaluator(array1);
-                    private final byte stt = ATypeTag.STRING.serialize();
-
                     private final GrowableArray array = new GrowableArray();
                     private final UTF8StringBuilder builder = new UTF8StringBuilder();
                     private final UTF8StringPointable stringPtr = new UTF8StringPointable();
@@ -83,8 +75,10 @@ public class SubstringBeforeDescriptor extends AbstractScalarFunctionDynamicDesc
                         evalPattern.evaluate(tuple);
                         byte[] pattern = array1.getByteArray();
 
-                        if ((src[0] != SER_STRING_TYPE_TAG && src[0] != SER_NULL_TYPE_TAG)
-                                || (pattern[0] != SER_STRING_TYPE_TAG && pattern[0] != SER_NULL_TYPE_TAG)) {
+                        if ((src[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+                                && src[0] != ATypeTag.SERIALIZED_NULL_TYPE_TAG)
+                                || (pattern[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+                                        && pattern[0] != ATypeTag.SERIALIZED_NULL_TYPE_TAG)) {
                             throw new AlgebricksException(AsterixBuiltinFunctions.SUBSTRING_BEFORE.getName()
                                     + ": expects input type (STRING/NULL, STRING/NULL) but got ("
                                     + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(src[0]) + ", "
@@ -96,7 +90,7 @@ public class SubstringBeforeDescriptor extends AbstractScalarFunctionDynamicDesc
                         array.reset();
                         try {
                             UTF8StringPointable.substrBefore(stringPtr, patternPtr, builder, array);
-                            out.writeByte(stt);
+                            out.writeByte(ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                             out.write(array.getByteArray(), 0, array.getLength());
                         } catch (IOException e) {
                             throw new AlgebricksException(e);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java
index 42d64b3..07b3b64 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java
@@ -47,6 +47,7 @@ public class SubstringDescriptor extends AbstractScalarFunctionDynamicDescriptor
     private static final long serialVersionUID = 1L;
 
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
         public IFunctionDescriptor createFunctionDescriptor() {
             return new SubstringDescriptor();
         }
@@ -66,7 +67,6 @@ public class SubstringDescriptor extends AbstractScalarFunctionDynamicDescriptor
                     private final ICopyEvaluator evalString = args[0].createEvaluator(argOut);
                     private final ICopyEvaluator evalStart = args[1].createEvaluator(argOut);
                     private final ICopyEvaluator evalLen = args[2].createEvaluator(argOut);
-                    private final byte stt = ATypeTag.STRING.serialize();
 
                     private final GrowableArray array = new GrowableArray();
                     private final UTF8StringBuilder builder = new UTF8StringBuilder();
@@ -91,7 +91,7 @@ public class SubstringDescriptor extends AbstractScalarFunctionDynamicDescriptor
                                 start = argOut.getByteArray()[1] - 1;
                                 break;
                             case INT16:
-                                start = (int) ShortPointable.getShort(argOut.getByteArray(), 1) - 1;
+                                start = ShortPointable.getShort(argOut.getByteArray(), 1) - 1;
                                 break;
                             case FLOAT:
                                 start = (int) FloatPointable.getFloat(argOut.getByteArray(), 1) - 1;
@@ -122,7 +122,7 @@ public class SubstringDescriptor extends AbstractScalarFunctionDynamicDescriptor
                                 len = argOut.getByteArray()[1];
                                 break;
                             case INT16:
-                                len = (int) ShortPointable.getShort(argOut.getByteArray(), 1);
+                                len = ShortPointable.getShort(argOut.getByteArray(), 1);
                                 break;
                             case FLOAT:
                                 len = (int) FloatPointable.getFloat(argOut.getByteArray(), 1);
@@ -159,7 +159,7 @@ public class SubstringDescriptor extends AbstractScalarFunctionDynamicDescriptor
                         }
 
                         try {
-                            out.writeByte(stt);
+                            out.writeByte(ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                             out.write(array.getByteArray(), 0, array.getLength());
                         } catch (IOException e) {
                             throw new AlgebricksException(e);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java
index e6de4ce..37b414b 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java
@@ -44,7 +44,6 @@ import org.apache.hyracks.util.string.UTF8StringWriter;
 
 public class PrintBinaryDescriptor extends AbstractScalarFunctionDynamicDescriptor {
     private static final long serialVersionUID = 1L;
-    private static final byte SER_STRING_BYTE = ATypeTag.STRING.serialize();
 
     @Override
     public FunctionIdentifier getIdentifier() {
@@ -101,7 +100,7 @@ public class PrintBinaryDescriptor extends AbstractScalarFunctionDynamicDescript
                                 throw new AlgebricksException(getIdentifier().getName()
                                         + ": expects format indicator of \"hex\" or \"base64\" in the 2nd argument");
                             }
-                            dataOutput.writeByte(SER_STRING_BYTE);
+                            dataOutput.writeByte(ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                             writer.writeUTF8(stringBuilder.toString(), dataOutput);
                         } catch (HyracksDataException e) {
                             throw new AlgebricksException(e);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java
index da42249..7bc6aef 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java
@@ -50,8 +50,6 @@ public class FieldAccessByIndexEvalFactory implements ICopyEvaluatorFactory {
     private ICopyEvaluatorFactory fieldIndexEvalFactory;
     private int nullBitmapSize;
     private ARecordType recordType;
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_RECORD_TYPE_TAG = ATypeTag.RECORD.serialize();
 
     public FieldAccessByIndexEvalFactory(ICopyEvaluatorFactory recordEvalFactory,
             ICopyEvaluatorFactory fieldIndexEvalFactory, ARecordType recordType) {
@@ -59,11 +57,11 @@ public class FieldAccessByIndexEvalFactory implements ICopyEvaluatorFactory {
         this.fieldIndexEvalFactory = fieldIndexEvalFactory;
         this.recordType = recordType;
         this.nullBitmapSize = ARecordType.computeNullBitmapSize(recordType);
-
     }
 
     @Override
     public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+
         return new ICopyEvaluator() {
 
             private DataOutput out = output.getDataOutput();
@@ -81,36 +79,41 @@ public class FieldAccessByIndexEvalFactory implements ICopyEvaluatorFactory {
             private IAType fieldValueType;
             private ATypeTag fieldValueTypeTag = ATypeTag.NULL;
 
+            /*
+             * outInput0: the record
+             * outInput1: the index
+             *
+             * This method outputs into IDataOutputProvider output [field type tag (1 byte)][the field data]
+             */
             @Override
             public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
                 try {
                     outInput0.reset();
                     eval0.evaluate(tuple);
-                    outInput1.reset();
-                    eval1.evaluate(tuple);
                     byte[] serRecord = outInput0.getByteArray();
 
-                    if (serRecord[0] == SER_NULL_TYPE_TAG) {
+                    if (serRecord[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                         nullSerde.serialize(ANull.NULL, out);
                         return;
                     }
 
-                    if (serRecord[0] != SER_RECORD_TYPE_TAG) {
+                    if (serRecord[0] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
                         throw new AlgebricksException("Field accessor is not defined for values of type "
                                 + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serRecord[0]));
                     }
-
+                    outInput1.reset();
+                    eval1.evaluate(tuple);
                     fieldIndex = IntegerPointable.getInteger(outInput1.getByteArray(), 1);
+                    fieldValueType = recordType.getFieldTypes()[fieldIndex];
                     fieldValueOffset = ARecordSerializerDeserializer.getFieldOffsetById(serRecord, fieldIndex,
                             nullBitmapSize, recordType.isOpen());
 
                     if (fieldValueOffset == 0) {
                         // the field is null, we checked the null bit map
-                        out.writeByte(SER_NULL_TYPE_TAG);
+                        out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
                         return;
                     }
 
-                    fieldValueType = recordType.getFieldTypes()[fieldIndex];
                     if (fieldValueType.getTypeTag().equals(ATypeTag.UNION)) {
                         if (((AUnionType) fieldValueType).isNullableType()) {
                             fieldValueTypeTag = ((AUnionType) fieldValueType).getNullableType().getTypeTag();
@@ -137,5 +140,4 @@ public class FieldAccessByIndexEvalFactory implements ICopyEvaluatorFactory {
             }
         };
     }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java
index cb33da1..66bedf0 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java
@@ -45,9 +45,6 @@ public class FieldAccessByNameEvalFactory implements ICopyEvaluatorFactory {
     private ICopyEvaluatorFactory recordEvalFactory;
     private ICopyEvaluatorFactory fldNameEvalFactory;
 
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_RECORD_TYPE_TAG = ATypeTag.RECORD.serialize();
-
     public FieldAccessByNameEvalFactory(ICopyEvaluatorFactory recordEvalFactory,
             ICopyEvaluatorFactory fldNameEvalFactory) {
         this.recordEvalFactory = recordEvalFactory;
@@ -81,12 +78,12 @@ public class FieldAccessByNameEvalFactory implements ICopyEvaluatorFactory {
                     eval1.evaluate(tuple);
                     byte[] serRecord = outInput0.getByteArray();
 
-                    if (serRecord[0] == SER_NULL_TYPE_TAG) {
+                    if (serRecord[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                         nullSerde.serialize(ANull.NULL, out);
                         return;
                     }
 
-                    if (serRecord[0] != SER_RECORD_TYPE_TAG) {
+                    if (serRecord[0] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
                         throw new AlgebricksException(AsterixBuiltinFunctions.FIELD_ACCESS_BY_NAME.getName()
                                 + ": expects input type NULL or RECORD, but got "
                                 + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serRecord[0]));
@@ -95,7 +92,7 @@ public class FieldAccessByNameEvalFactory implements ICopyEvaluatorFactory {
                     byte[] serFldName = outInput1.getByteArray();
                     fieldValueOffset = ARecordSerializerDeserializer.getFieldOffsetByName(serRecord, serFldName);
                     if (fieldValueOffset < 0) {
-                        out.writeByte(ATypeTag.NULL.serialize());
+                        out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
                         return;
                     }
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessUtil.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessUtil.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessUtil.java
index a442ef4..f9bb6fc 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessUtil.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessUtil.java
@@ -46,10 +46,6 @@ import org.apache.hyracks.data.std.util.ByteArrayAccessibleOutputStream;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public class FieldAccessUtil {
-
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final static byte SER_RECORD_TYPE_TAG = ATypeTag.RECORD.serialize();
-
     @SuppressWarnings("unchecked")
     private static ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
             .getSerializerDeserializer(BuiltinType.ANULL);
@@ -72,7 +68,7 @@ public class FieldAccessUtil {
     }
 
     public static boolean checkType(byte tagId, DataOutput out) throws AlgebricksException {
-        if (tagId == SER_NULL_TYPE_TAG) {
+        if (tagId == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
             try {
                 nullSerde.serialize(ANull.NULL, out);
             } catch (HyracksDataException e) {
@@ -81,7 +77,7 @@ public class FieldAccessUtil {
             return true;
         }
 
-        if (tagId != SER_RECORD_TYPE_TAG) {
+        if (tagId != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
             throw new AlgebricksException("Field accessor is not defined for values of type "
                     + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(tagId));
         }
@@ -118,7 +114,7 @@ public class FieldAccessUtil {
                 if (subType.getTypeTag().equals(ATypeTag.UNION)) {
                     //enforced SubType
                     subType = ((AUnionType) subType).getNullableType();
-                    if (subType.getTypeTag().serialize() != SER_RECORD_TYPE_TAG) {
+                    if (subType.getTypeTag().serialize() != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
                         throw new AlgebricksException("Field accessor is not defined for values of type " + subTypeTag);
                     }
                     if (subType.getTypeTag() == ATypeTag.RECORD) {
@@ -135,7 +131,7 @@ public class FieldAccessUtil {
                         nullBitmapSize, ((ARecordType) subType).isOpen());
                 if (subFieldOffset == 0) {
                     // the field is null, we checked the null bit map
-                    out.writeByte(SER_NULL_TYPE_TAG);
+                    out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
                     return;
                 }
                 subType = ((ARecordType) subType).getFieldTypes()[subFieldIndex];
@@ -177,7 +173,7 @@ public class FieldAccessUtil {
                 subFieldOffset = ARecordSerializerDeserializer.getFieldOffsetByName(subRecord,
                         abvsFields[i].getByteArray());
                 if (subFieldOffset < 0) {
-                    out.writeByte(SER_NULL_TYPE_TAG);
+                    out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
                     return;
                 }
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldValueEvalFactory.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldValueEvalFactory.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldValueEvalFactory.java
index 8cabee1..501c743 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldValueEvalFactory.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldValueEvalFactory.java
@@ -44,8 +44,6 @@ public class GetRecordFieldValueEvalFactory implements ICopyEvaluatorFactory {
     private ICopyEvaluatorFactory fldNameEvalFactory;
     private final ARecordType recordType;
 
-    private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
-
     public GetRecordFieldValueEvalFactory(ICopyEvaluatorFactory recordEvalFactory,
             ICopyEvaluatorFactory fldNameEvalFactory, ARecordType recordType) {
         this.recordEvalFactory = recordEvalFactory;
@@ -89,7 +87,7 @@ public class GetRecordFieldValueEvalFactory implements ICopyEvaluatorFactory {
                     eval1.evaluate(tuple);
 
                     byte[] serFldName = outInput1.getByteArray();
-                    if (serFldName[0] != SER_STRING_TYPE_TAG) {
+                    if (serFldName[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
                         nullSerde.serialize(ANull.NULL, out);
                         return;
                     }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldsEvalFactory.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldsEvalFactory.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldsEvalFactory.java
index d8bafc0..d3f7a79 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldsEvalFactory.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldsEvalFactory.java
@@ -39,15 +39,10 @@ import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public class GetRecordFieldsEvalFactory implements ICopyEvaluatorFactory {
-
     private static final long serialVersionUID = 1L;
-
     private ICopyEvaluatorFactory recordEvalFactory;
     private final ARecordType recordType;
 
-    private final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private final byte SER_RECORD_TYPE_TAG = ATypeTag.RECORD.serialize();
-
     public GetRecordFieldsEvalFactory(ICopyEvaluatorFactory recordEvalFactory, ARecordType recordType) {
         this.recordEvalFactory = recordEvalFactory;
         this.recordType = recordType;
@@ -74,7 +69,7 @@ public class GetRecordFieldsEvalFactory implements ICopyEvaluatorFactory {
                 outInput0.reset();
                 eval0.evaluate(tuple);
 
-                if (outInput0.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                if (outInput0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                     try {
                         nullSerde.serialize(ANull.NULL, out);
                     } catch (HyracksDataException e) {
@@ -82,7 +77,7 @@ public class GetRecordFieldsEvalFactory implements ICopyEvaluatorFactory {
                     }
                 }
 
-                if (outInput0.getByteArray()[0] != SER_RECORD_TYPE_TAG) {
+                if (outInput0.getByteArray()[0] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
                     throw new AlgebricksException("Field accessor is not defined for values of type "
                             + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(outInput0.getByteArray()[0]));
                 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
index c26daca..d9323a5 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
@@ -62,6 +62,7 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 public class RecordAddFieldsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
         public IFunctionDescriptor createFunctionDescriptor() {
             return new RecordAddFieldsDescriptor();
         }
@@ -87,10 +88,6 @@ public class RecordAddFieldsDescriptor extends AbstractScalarFunctionDynamicDesc
         return new ICopyEvaluatorFactory() {
 
             private static final long serialVersionUID = 1L;
-            private final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-            private final byte SER_ORDERED_TYPE_TAG = ATypeTag.ORDEREDLIST.serialize();
-            private final byte SER_RECORD_TYPE_TAG = ATypeTag.RECORD.serialize();
-
             @SuppressWarnings("unchecked")
             private final ISerializerDeserializer<ANull> nullSerDe = AqlSerializerDeserializerProvider.INSTANCE
                     .getSerializerDeserializer(BuiltinType.ANULL);
@@ -145,8 +142,8 @@ public class RecordAddFieldsDescriptor extends AbstractScalarFunctionDynamicDesc
                         eval0.evaluate(tuple);
                         eval1.evaluate(tuple);
 
-                        if (abvs0.getByteArray()[0] == SER_NULL_TYPE_TAG
-                                || abvs1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                        if (abvs0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                                || abvs1.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                             try {
                                 nullSerDe.serialize(ANull.NULL, output.getDataOutput());
                             } catch (HyracksDataException e) {
@@ -156,14 +153,14 @@ public class RecordAddFieldsDescriptor extends AbstractScalarFunctionDynamicDesc
                         }
 
                         // Make sure we get a valid record
-                        if (abvs0.getByteArray()[0] != SER_RECORD_TYPE_TAG) {
+                        if (abvs0.getByteArray()[0] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
                             throw new AlgebricksException("Expected an ordederlist of type " + inRecType + " but "
                                     + "got "
                                     + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(abvs0.getByteArray()[0]));
                         }
 
                         // Make sure we get a valid list
-                        if (abvs1.getByteArray()[0] != SER_ORDERED_TYPE_TAG) {
+                        if (abvs1.getByteArray()[0] != ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG) {
                             throw new AlgebricksException("Expected an ordederlist of type " + inListType + " but "
                                     + "got "
                                     + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(abvs1.getByteArray()[0]));

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
index 2c1a335..afd6fc1 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
@@ -64,12 +64,12 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 public class RecordMergeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
 
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
         public IFunctionDescriptor createFunctionDescriptor() {
             return new RecordMergeDescriptor();
         }
     };
     private static final long serialVersionUID = 1L;
-    private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
     private ARecordType outRecType;
     private ARecordType inRecType0;
     private ARecordType inRecType1;
@@ -119,8 +119,8 @@ public class RecordMergeDescriptor extends AbstractScalarFunctionDynamicDescript
                         eval0.evaluate(tuple);
                         eval1.evaluate(tuple);
 
-                        if (abvs0.getByteArray()[0] == SER_NULL_TYPE_TAG
-                                || abvs1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                        if (abvs0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                                || abvs1.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                             try {
                                 nullSerDe.serialize(ANull.NULL, output.getDataOutput());
                             } catch (HyracksDataException e) {
@@ -146,7 +146,7 @@ public class RecordMergeDescriptor extends AbstractScalarFunctionDynamicDescript
 
                     private void mergeFields(ARecordType combinedType, ARecordVisitablePointable leftRecord,
                             ARecordVisitablePointable rightRecord, boolean openFromParent, int nestedLevel)
-                            throws IOException, AsterixException, AlgebricksException {
+                                    throws IOException, AsterixException, AlgebricksException {
                         if (rbStack.size() < (nestedLevel + 1)) {
                             rbStack.add(new RecordBuilder());
                         }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsDescriptor.java
index 0add4f0..ae752f9 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsDescriptor.java
@@ -23,7 +23,6 @@ import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 import org.apache.asterix.om.types.AOrderedListType;
 import org.apache.asterix.om.types.ARecordType;
-import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.IAType;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -31,19 +30,15 @@ import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
 
 public class RecordRemoveFieldsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private static final long serialVersionUID = 1L;
-
-    private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private static final byte SER_ORDEREDLIST_TYPE_TAG = ATypeTag.ORDEREDLIST.serialize();
-
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+        @Override
         public IFunctionDescriptor createFunctionDescriptor() {
             return new RecordRemoveFieldsDescriptor();
         }
     };
 
-    private  RecordRemoveFieldsDescriptor() {
+    private RecordRemoveFieldsDescriptor() {
     }
 
     private ARecordType outputRecordType;
@@ -56,6 +51,7 @@ public class RecordRemoveFieldsDescriptor extends AbstractScalarFunctionDynamicD
         inputListType = (AOrderedListType) inListType;
     }
 
+    @Override
     public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
         return new RecordRemoveFieldsEvalFactory(args[0], args[1], outputRecordType, inputRecType, inputListType);
     }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsEvalFactory.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsEvalFactory.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsEvalFactory.java
index a74f055..441f91f 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsEvalFactory.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsEvalFactory.java
@@ -53,10 +53,6 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 class RecordRemoveFieldsEvalFactory implements ICopyEvaluatorFactory {
     private static final long serialVersionUID = 1L;
-
-    private static final byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-    private static final byte SER_ORDEREDLIST_TYPE_TAG = ATypeTag.ORDEREDLIST.serialize();
-    private static final byte SER_RECORD_TYPE_TAG = ATypeTag.RECORD.serialize();
     @SuppressWarnings("unchecked")
     private final ISerializerDeserializer<ANull> nullSerDe = AqlSerializerDeserializerProvider.INSTANCE
             .getSerializerDeserializer(BuiltinType.ANULL);
@@ -95,7 +91,6 @@ class RecordRemoveFieldsEvalFactory implements ICopyEvaluatorFactory {
             private final ArrayBackedValueStorage tabvs = new ArrayBackedValueStorage();
             private final Deque<IVisitablePointable> recordPath = new ArrayDeque<>();
 
-
             @Override
             public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
                 outInput0.reset();
@@ -104,7 +99,7 @@ class RecordRemoveFieldsEvalFactory implements ICopyEvaluatorFactory {
                 eval0.evaluate(tuple);
                 eval1.evaluate(tuple);
 
-                if (outInput0.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                if (outInput0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                     try {
                         nullSerDe.serialize(ANull.NULL, output.getDataOutput());
                     } catch (HyracksDataException e) {
@@ -113,13 +108,13 @@ class RecordRemoveFieldsEvalFactory implements ICopyEvaluatorFactory {
                     return;
                 }
 
-                if (outInput0.getByteArray()[0] != SER_RECORD_TYPE_TAG) {
+                if (outInput0.getByteArray()[0] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
                     throw new AlgebricksException(AsterixBuiltinFunctions.REMOVE_FIELDS.getName()
                             + ": expects input type " + inputRecType + ", but got "
                             + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(outInput0.getByteArray()[0]));
                 }
 
-                if (outInput1.getByteArray()[0] != SER_ORDEREDLIST_TYPE_TAG) {
+                if (outInput1.getByteArray()[0] != ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG) {
                     throw new AlgebricksException(AsterixBuiltinFunctions.REMOVE_FIELDS.getName()
                             + ": expects input type " + inputListType + ", but got "
                             + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(outInput1.getByteArray()[0]));
@@ -142,8 +137,8 @@ class RecordRemoveFieldsEvalFactory implements ICopyEvaluatorFactory {
             }
 
             private void processRecord(ARecordType requiredType, ARecordVisitablePointable srp,
-                    AListVisitablePointable inputList, int nestedLevel) throws IOException, AsterixException,
-                    AlgebricksException {
+                    AListVisitablePointable inputList, int nestedLevel)
+                            throws IOException, AsterixException, AlgebricksException {
                 if (rbStack.size() < (nestedLevel + 1)) {
                     rbStack.add(new RecordBuilder());
                 }
@@ -173,8 +168,8 @@ class RecordRemoveFieldsEvalFactory implements ICopyEvaluatorFactory {
 
             private void addKeptFieldToSubRecord(ARecordType requiredType, IVisitablePointable fieldNamePointable,
                     IVisitablePointable fieldValuePointable, IVisitablePointable fieldTypePointable,
-                    AListVisitablePointable inputList, int nestedLevel) throws IOException, AsterixException,
-                    AlgebricksException {
+                    AListVisitablePointable inputList, int nestedLevel)
+                            throws IOException, AsterixException, AlgebricksException {
 
                 runtimeRecordTypeInfo.reset(requiredType);
                 int pos = runtimeRecordTypeInfo.getFieldIndex(fieldNamePointable.getByteArray(),
@@ -191,7 +186,8 @@ class RecordRemoveFieldsEvalFactory implements ICopyEvaluatorFactory {
                     }
                 } else { // Open field
                     if (PointableHelper.sameType(ATypeTag.RECORD, fieldTypePointable)) {
-                        processRecord(null, (ARecordVisitablePointable) fieldValuePointable, inputList, nestedLevel + 1);
+                        processRecord(null, (ARecordVisitablePointable) fieldValuePointable, inputList,
+                                nestedLevel + 1);
                         tabvs.reset();
                         rbStack.get(nestedLevel + 1).write(tabvs.getDataOutput(), true);
                         rbStack.get(nestedLevel).addField(fieldNamePointable, tabvs);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/5dc958ce/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AbstractIntervalLogicFuncDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AbstractIntervalLogicFuncDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AbstractIntervalLogicFuncDescriptor.java
index 4c5a748..da00cd2 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AbstractIntervalLogicFuncDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AbstractIntervalLogicFuncDescriptor.java
@@ -38,13 +38,8 @@ import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
 public abstract class AbstractIntervalLogicFuncDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
     private final static long serialVersionUID = 1L;
 
-    // allowed input types
-    private final static byte SER_INTERVAL_TYPE_TAG = ATypeTag.INTERVAL.serialize();
-    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
-
     /* (non-Javadoc)
      * @see org.apache.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
      */
@@ -81,24 +76,27 @@ public abstract class AbstractIntervalLogicFuncDescriptor extends AbstractScalar
                         eval1.evaluate(tuple);
 
                         try {
-                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
-                                    || argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                                    || argOut1.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != SER_INTERVAL_TYPE_TAG
-                                    || argOut1.getByteArray()[0] != SER_INTERVAL_TYPE_TAG) {
-                                throw new AlgebricksException(getIdentifier().getName()
-                                        + ": expects input type (INTERVAL, INTERVAL) but got ("
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0])
-                                        + ", "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0])
-                                        + ")");
+                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG
+                                    || argOut1.getByteArray()[0] != ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+                                throw new AlgebricksException(
+                                        getIdentifier().getName()
+                                                + ": expects input type (INTERVAL, INTERVAL) but got ("
+                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(
+                                                        argOut0.getByteArray()[0])
+                                                + ", " + EnumDeserializer.ATYPETAGDESERIALIZER
+                                                        .deserialize(argOut1.getByteArray()[0])
+                                                + ")");
                             }
 
-                            if (AIntervalSerializerDeserializer.getIntervalTimeType(argOut0.getByteArray(), 1) != AIntervalSerializerDeserializer
-                                    .getIntervalTimeType(argOut1.getByteArray(), 1)) {
+                            if (AIntervalSerializerDeserializer.getIntervalTimeType(argOut0.getByteArray(),
+                                    1) != AIntervalSerializerDeserializer.getIntervalTimeType(argOut1.getByteArray(),
+                                            1)) {
                                 throw new AlgebricksException(getIdentifier().getName()
                                         + ": failed to compare intervals with different internal time type.");
                             }
@@ -107,8 +105,8 @@ public abstract class AbstractIntervalLogicFuncDescriptor extends AbstractScalar
                                     AIntervalSerializerDeserializer.getIntervalStart(argOut0.getByteArray(), 1),
                                     AIntervalSerializerDeserializer.getIntervalEnd(argOut0.getByteArray(), 1),
                                     AIntervalSerializerDeserializer.getIntervalStart(argOut1.getByteArray(), 1),
-                                    AIntervalSerializerDeserializer.getIntervalEnd(argOut1.getByteArray(), 1))) ? ABoolean.TRUE
-                                    : ABoolean.FALSE;
+                                    AIntervalSerializerDeserializer.getIntervalEnd(argOut1.getByteArray(), 1)))
+                                            ? ABoolean.TRUE : ABoolean.FALSE;
 
                             booleanSerde.serialize(res, out);
 


Mime
View raw message