asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject [19/24] incubator-asterixdb git commit: Move to non-copy-based evaluator interfaces for all function implementations, including: - scalar functions, - aggregate functions, - running aggregate functions, - unnesting functions
Date Sat, 13 Feb 2016 02:15:48 GMT
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndDatetimeAccessor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndDatetimeAccessor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndDatetimeAccessor.java
index e610363..925d88d 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndDatetimeAccessor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndDatetimeAccessor.java
@@ -35,10 +35,12 @@ import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.data.std.api.IDataOutputProvider;
+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;
 
@@ -56,20 +58,19 @@ public class TemporalIntervalEndDatetimeAccessor extends AbstractScalarFunctionD
     };
 
     @Override
-    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
-        return new ICopyEvaluatorFactory() {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+            throws AlgebricksException {
+        return new IScalarEvaluatorFactory() {
 
             private static final long serialVersionUID = 1L;
 
             @Override
-            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
-                return new ICopyEvaluator() {
-
-                    private final DataOutput out = output.getDataOutput();
-
-                    private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
-
-                    private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
+                    private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private final DataOutput out = resultStorage.getDataOutput();
+                    private final IPointable argPtr = new VoidPointable();
+                    private final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
 
                     // possible output
                     @SuppressWarnings("unchecked")
@@ -81,18 +82,21 @@ public class TemporalIntervalEndDatetimeAccessor extends AbstractScalarFunctionD
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut.reset();
-                        eval.evaluate(tuple);
-                        byte[] bytes = argOut.getByteArray();
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        eval.evaluate(tuple, argPtr);
+                        byte[] bytes = argPtr.getByteArray();
+                        int startOffset = argPtr.getStartOffset();
 
+                        resultStorage.reset();
                         try {
-                            if (bytes[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
-                                byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes, 1);
-                                long endTime = AIntervalSerializerDeserializer.getIntervalEnd(bytes, 1);
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+                                byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes,
+                                        startOffset + 1);
+                                long endTime = AIntervalSerializerDeserializer.getIntervalEnd(bytes, startOffset + 1);
                                 if (timeType == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
                                     aDateTime.setValue(endTime);
                                     datetimeSerde.serialize(aDateTime, out);
@@ -102,13 +106,14 @@ public class TemporalIntervalEndDatetimeAccessor extends AbstractScalarFunctionD
                                             + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(timeType) + ")");
                                 }
                             } else {
-                                throw new AlgebricksException(
-                                        FID.getName() + ": expects NULL/INTERVAL(of DATETIME), but got "
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]));
+                                throw new AlgebricksException(FID.getName()
+                                        + ": expects NULL/INTERVAL(of DATETIME), but got "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[startOffset]));
                             }
                         } catch (IOException e) {
                             throw new AlgebricksException(e);
                         }
+                        result.set(resultStorage);
                     }
                 };
             }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndTimeAccessor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndTimeAccessor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndTimeAccessor.java
index dc5ff7e..a393846 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndTimeAccessor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndTimeAccessor.java
@@ -35,10 +35,12 @@ import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.data.std.api.IDataOutputProvider;
+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;
 
@@ -54,20 +56,19 @@ public class TemporalIntervalEndTimeAccessor extends AbstractScalarFunctionDynam
     };
 
     @Override
-    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
-        return new ICopyEvaluatorFactory() {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+            throws AlgebricksException {
+        return new IScalarEvaluatorFactory() {
 
             private static final long serialVersionUID = 1L;
 
             @Override
-            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
-                return new ICopyEvaluator() {
-
-                    private final DataOutput out = output.getDataOutput();
-
-                    private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
-
-                    private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
+                    private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private final DataOutput out = resultStorage.getDataOutput();
+                    private final IPointable argPtr = new VoidPointable();
+                    private final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
 
                     // possible output
                     @SuppressWarnings("unchecked")
@@ -79,18 +80,21 @@ public class TemporalIntervalEndTimeAccessor extends AbstractScalarFunctionDynam
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut.reset();
-                        eval.evaluate(tuple);
-                        byte[] bytes = argOut.getByteArray();
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        eval.evaluate(tuple, argPtr);
+                        byte[] bytes = argPtr.getByteArray();
+                        int startOffset = argPtr.getStartOffset();
 
+                        resultStorage.reset();
                         try {
-                            if (bytes[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
-                                byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes, 1);
-                                long endTime = AIntervalSerializerDeserializer.getIntervalEnd(bytes, 1);
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+                                byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes,
+                                        startOffset + 1);
+                                long endTime = AIntervalSerializerDeserializer.getIntervalEnd(bytes, startOffset + 1);
                                 if (timeType == ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
                                     aTime.setValue((int) (endTime));
                                     timeSerde.serialize(aTime, out);
@@ -100,13 +104,14 @@ public class TemporalIntervalEndTimeAccessor extends AbstractScalarFunctionDynam
                                             + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(timeType) + ")");
                                 }
                             } else {
-                                throw new AlgebricksException(
-                                        FID.getName() + ": expects NULL/INTERVAL(of TIME), but got "
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]));
+                                throw new AlgebricksException(FID.getName()
+                                        + ": expects NULL/INTERVAL(of TIME), but got "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[startOffset]));
                             }
                         } catch (IOException e) {
                             throw new AlgebricksException(e);
                         }
+                        result.set(resultStorage);
                     }
                 };
             }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartAccessor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartAccessor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartAccessor.java
index 3c2440b..ef391b2 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartAccessor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartAccessor.java
@@ -39,10 +39,12 @@ import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.data.std.api.IDataOutputProvider;
+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;
 
@@ -59,20 +61,18 @@ public class TemporalIntervalStartAccessor extends AbstractScalarFunctionDynamic
     };
 
     @Override
-    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
-        return new ICopyEvaluatorFactory() {
-
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+            throws AlgebricksException {
+        return new IScalarEvaluatorFactory() {
             private static final long serialVersionUID = 1L;
 
             @Override
-            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
-                return new ICopyEvaluator() {
-
-                    private final DataOutput out = output.getDataOutput();
-
-                    private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
-
-                    private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
+                    private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private final DataOutput out = resultStorage.getDataOutput();
+                    private final IPointable argPtr = new VoidPointable();
+                    private final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
 
                     // possible output
                     @SuppressWarnings("unchecked")
@@ -92,18 +92,22 @@ public class TemporalIntervalStartAccessor extends AbstractScalarFunctionDynamic
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut.reset();
-                        eval.evaluate(tuple);
-                        byte[] bytes = argOut.getByteArray();
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        eval.evaluate(tuple, argPtr);
+                        byte[] bytes = argPtr.getByteArray();
+                        int startOffset = argPtr.getStartOffset();
 
+                        resultStorage.reset();
                         try {
-                            if (bytes[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
-                                byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes, 1);
-                                long startTime = AIntervalSerializerDeserializer.getIntervalStart(bytes, 1);
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+                                byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes,
+                                        startOffset + 1);
+                                long startTime = AIntervalSerializerDeserializer.getIntervalStart(bytes,
+                                        startOffset + 1);
                                 if (timeType == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
                                     aDate.setValue((int) (startTime));
                                     dateSerde.serialize(aDate, out);
@@ -116,11 +120,12 @@ public class TemporalIntervalStartAccessor extends AbstractScalarFunctionDynamic
                                 }
                             } else {
                                 throw new AlgebricksException(FID.getName() + ": expects NULL/INTERVAL, but got "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]));
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[startOffset]));
                             }
                         } catch (IOException e) {
                             throw new AlgebricksException(e);
                         }
+                        result.set(resultStorage);
                     }
                 };
             }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDateAccessor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDateAccessor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDateAccessor.java
index ff2a92b..e2d8883 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDateAccessor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDateAccessor.java
@@ -35,10 +35,12 @@ import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.data.std.api.IDataOutputProvider;
+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;
 
@@ -55,20 +57,18 @@ public class TemporalIntervalStartDateAccessor extends AbstractScalarFunctionDyn
     };
 
     @Override
-    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
-        return new ICopyEvaluatorFactory() {
-
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+            throws AlgebricksException {
+        return new IScalarEvaluatorFactory() {
             private static final long serialVersionUID = 1L;
 
             @Override
-            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
-                return new ICopyEvaluator() {
-
-                    private final DataOutput out = output.getDataOutput();
-
-                    private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
-
-                    private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
+                    private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private final DataOutput out = resultStorage.getDataOutput();
+                    private final IPointable argPtr = new VoidPointable();
+                    private final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
 
                     // possible output
                     @SuppressWarnings("unchecked")
@@ -80,18 +80,22 @@ public class TemporalIntervalStartDateAccessor extends AbstractScalarFunctionDyn
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut.reset();
-                        eval.evaluate(tuple);
-                        byte[] bytes = argOut.getByteArray();
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        eval.evaluate(tuple, argPtr);
+                        byte[] bytes = argPtr.getByteArray();
+                        int startOffset = argPtr.getStartOffset();
 
+                        resultStorage.reset();
                         try {
-                            if (bytes[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
-                                byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes, 1);
-                                long startTime = AIntervalSerializerDeserializer.getIntervalStart(bytes, 1);
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+                                byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes,
+                                        startOffset + 1);
+                                long startTime = AIntervalSerializerDeserializer.getIntervalStart(bytes,
+                                        startOffset + 1);
                                 if (timeType == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
                                     aDate.setValue((int) (startTime));
                                     dateSerde.serialize(aDate, out);
@@ -101,13 +105,14 @@ public class TemporalIntervalStartDateAccessor extends AbstractScalarFunctionDyn
                                             + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(timeType) + ")");
                                 }
                             } else {
-                                throw new AlgebricksException(
-                                        FID.getName() + ": expects NULL/INTERVAL(of DATE), but got "
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]));
+                                throw new AlgebricksException(FID.getName()
+                                        + ": expects NULL/INTERVAL(of DATE), but got "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[startOffset]));
                             }
                         } catch (IOException e) {
                             throw new AlgebricksException(e);
                         }
+                        result.set(resultStorage);
                     }
                 };
             }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDatetimeAccessor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDatetimeAccessor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDatetimeAccessor.java
index c88b8f0..b3a89c1 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDatetimeAccessor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDatetimeAccessor.java
@@ -35,10 +35,12 @@ import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.data.std.api.IDataOutputProvider;
+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;
 
@@ -54,20 +56,19 @@ public class TemporalIntervalStartDatetimeAccessor extends AbstractScalarFunctio
     };
 
     @Override
-    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
-        return new ICopyEvaluatorFactory() {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+            throws AlgebricksException {
+        return new IScalarEvaluatorFactory() {
 
             private static final long serialVersionUID = 1L;
 
             @Override
-            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
-                return new ICopyEvaluator() {
-
-                    private final DataOutput out = output.getDataOutput();
-
-                    private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
-
-                    private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
+                    private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private final DataOutput out = resultStorage.getDataOutput();
+                    private final IPointable argPtr = new VoidPointable();
+                    private final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
 
                     // possible output
                     @SuppressWarnings("unchecked")
@@ -79,18 +80,22 @@ public class TemporalIntervalStartDatetimeAccessor extends AbstractScalarFunctio
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut.reset();
-                        eval.evaluate(tuple);
-                        byte[] bytes = argOut.getByteArray();
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        eval.evaluate(tuple, argPtr);
+                        byte[] bytes = argPtr.getByteArray();
+                        int startOffset = argPtr.getStartOffset();
 
+                        resultStorage.reset();
                         try {
-                            if (bytes[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
-                                byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes, 1);
-                                long startTime = AIntervalSerializerDeserializer.getIntervalStart(bytes, 1);
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+                                byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes,
+                                        startOffset + 1);
+                                long startTime = AIntervalSerializerDeserializer.getIntervalStart(bytes,
+                                        startOffset + 1);
                                 if (timeType == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
                                     aDateTime.setValue(startTime);
                                     datetimeSerde.serialize(aDateTime, out);
@@ -100,13 +105,14 @@ public class TemporalIntervalStartDatetimeAccessor extends AbstractScalarFunctio
                                             + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(timeType) + ")");
                                 }
                             } else {
-                                throw new AlgebricksException(
-                                        FID.getName() + ": expects NULL/INTERVAL(of DATETIME), but got "
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]));
+                                throw new AlgebricksException(FID.getName()
+                                        + ": expects NULL/INTERVAL(of DATETIME), but got "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[startOffset]));
                             }
                         } catch (IOException e) {
                             throw new AlgebricksException(e);
                         }
+                        result.set(resultStorage);
                     }
                 };
             }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartTimeAccessor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartTimeAccessor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartTimeAccessor.java
index 8308d1f..12ee1f0 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartTimeAccessor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartTimeAccessor.java
@@ -35,10 +35,12 @@ import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.data.std.api.IDataOutputProvider;
+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;
 
@@ -55,20 +57,18 @@ public class TemporalIntervalStartTimeAccessor extends AbstractScalarFunctionDyn
     };
 
     @Override
-    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
-        return new ICopyEvaluatorFactory() {
-
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+            throws AlgebricksException {
+        return new IScalarEvaluatorFactory() {
             private static final long serialVersionUID = 1L;
 
             @Override
-            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
-                return new ICopyEvaluator() {
-
-                    private final DataOutput out = output.getDataOutput();
-
-                    private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
-
-                    private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
+                    private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private final DataOutput out = resultStorage.getDataOutput();
+                    private final IPointable argPtr = new VoidPointable();
+                    private final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
 
                     // possible output
                     @SuppressWarnings("unchecked")
@@ -80,33 +80,39 @@ public class TemporalIntervalStartTimeAccessor extends AbstractScalarFunctionDyn
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut.reset();
-                        eval.evaluate(tuple);
-                        byte[] bytes = argOut.getByteArray();
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        eval.evaluate(tuple, argPtr);
+                        byte[] bytes = argPtr.getByteArray();
+                        int startOffset = argPtr.getStartOffset();
 
+                        resultStorage.reset();
                         try {
-                            if (bytes[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
-                                byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes, 1);
-                                long startTime = AIntervalSerializerDeserializer.getIntervalStart(bytes, 1);
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+                                byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes,
+                                        startOffset + 1);
+                                long startTime = AIntervalSerializerDeserializer.getIntervalStart(bytes,
+                                        startOffset + 1);
                                 if (timeType == ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
                                     aTime.setValue((int) (startTime));
                                     timeSerde.serialize(aTime, out);
                                 } else {
                                     throw new AlgebricksException(FID.getName()
                                             + ": expects NULL/INTERVAL(of TIME), but got INTERVAL(of "
-                                            + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]) + ")");
+                                            + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[startOffset])
+                                            + ")");
                                 }
                             } else {
                                 throw new AlgebricksException(FID.getName() + ": expects NULL/INTERVAL, but got "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[0]));
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[startOffset]));
                             }
                         } catch (IOException e) {
                             throw new AlgebricksException(e);
                         }
+                        result.set(resultStorage);
                     }
                 };
             }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java
index a20e541..a0bef32 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java
@@ -38,10 +38,12 @@ import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.data.std.api.IDataOutputProvider;
+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;
 
@@ -61,20 +63,19 @@ public class TemporalMillisecondAccessor extends AbstractScalarFunctionDynamicDe
      * @see org.apache.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
      */
     @Override
-    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
-        return new ICopyEvaluatorFactory() {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+            throws AlgebricksException {
+        return new IScalarEvaluatorFactory() {
 
             private static final long serialVersionUID = 1L;
 
             @Override
-            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
-                return new ICopyEvaluator() {
-
-                    private final DataOutput out = output.getDataOutput();
-
-                    private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
-
-                    private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
+                    private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private final DataOutput out = resultStorage.getDataOutput();
+                    private final IPointable argPtr = new VoidPointable();
+                    private final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
 
                     private final GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
 
@@ -88,47 +89,48 @@ public class TemporalMillisecondAccessor extends AbstractScalarFunctionDynamicDe
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut.reset();
-                        eval.evaluate(tuple);
-                        byte[] bytes = argOut.getByteArray();
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        eval.evaluate(tuple, argPtr);
+                        byte[] bytes = argPtr.getByteArray();
+                        int startOffset = argPtr.getStartOffset();
 
+                        resultStorage.reset();
                         try {
-
-                            if (bytes[0] == ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
-                                aMutableInt64.setValue(calSystem
-                                        .getDurationMillisecond(ADurationSerializerDeserializer.getDayTime(bytes, 1)));
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
+                                aMutableInt64.setValue(calSystem.getDurationMillisecond(
+                                        ADurationSerializerDeserializer.getDayTime(bytes, startOffset + 1)));
                                 intSerde.serialize(aMutableInt64, out);
+                                result.set(resultStorage);
                                 return;
                             }
-
-                            if (bytes[0] == ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG) {
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG) {
                                 aMutableInt64.setValue(calSystem.getDurationMillisecond(
-                                        ADayTimeDurationSerializerDeserializer.getDayTime(bytes, 1)));
+                                        ADayTimeDurationSerializerDeserializer.getDayTime(bytes, startOffset + 1)));
                                 intSerde.serialize(aMutableInt64, out);
+                                result.set(resultStorage);
                                 return;
                             }
 
                             long chrononTimeInMs = 0;
-                            if (bytes[0] == ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
-                                chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, 1);
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
-                                chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, 1);
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
+                                chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, startOffset + 1);
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
+                                chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, startOffset + 1);
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
                             } else {
-                                throw new AlgebricksException("Inapplicable input type: " + bytes[0]);
+                                throw new AlgebricksException("Inapplicable input type: " + bytes[startOffset]);
                             }
 
                             int ms = calSystem.getMillisOfSec(chrononTimeInMs);
-
                             aMutableInt64.setValue(ms);
                             intSerde.serialize(aMutableInt64, out);
-
                         } catch (IOException e) {
                             throw new AlgebricksException(e);
                         }
+                        result.set(resultStorage);
                     }
                 };
             }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java
index 07e7c2d..cdd0f8a 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java
@@ -38,10 +38,12 @@ import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.data.std.api.IDataOutputProvider;
+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;
 
@@ -64,20 +66,19 @@ public class TemporalMinuteAccessor extends AbstractScalarFunctionDynamicDescrip
      * @see org.apache.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
      */
     @Override
-    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
-        return new ICopyEvaluatorFactory() {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+            throws AlgebricksException {
+        return new IScalarEvaluatorFactory() {
 
             private static final long serialVersionUID = 1L;
 
             @Override
-            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
-                return new ICopyEvaluator() {
-
-                    private final DataOutput out = output.getDataOutput();
-
-                    private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
-
-                    private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
+                    private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private final DataOutput out = resultStorage.getDataOutput();
+                    private final IPointable argPtr = new VoidPointable();
+                    private final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
 
                     private final GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
 
@@ -91,47 +92,48 @@ public class TemporalMinuteAccessor extends AbstractScalarFunctionDynamicDescrip
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut.reset();
-                        eval.evaluate(tuple);
-                        byte[] bytes = argOut.getByteArray();
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        eval.evaluate(tuple, argPtr);
+                        byte[] bytes = argPtr.getByteArray();
+                        int startOffset = argPtr.getStartOffset();
 
+                        resultStorage.reset();
                         try {
-
-                            if (bytes[0] == ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
-                                aMutableInt64.setValue(calSystem
-                                        .getDurationMinute(ADurationSerializerDeserializer.getDayTime(bytes, 1)));
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
+                                aMutableInt64.setValue(calSystem.getDurationMinute(
+                                        ADurationSerializerDeserializer.getDayTime(bytes, startOffset + 1)));
                                 intSerde.serialize(aMutableInt64, out);
+                                result.set(resultStorage);
                                 return;
                             }
-
-                            if (bytes[0] == ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG) {
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG) {
                                 aMutableInt64.setValue(calSystem.getDurationMinute(
-                                        ADayTimeDurationSerializerDeserializer.getDayTime(bytes, 1)));
+                                        ADayTimeDurationSerializerDeserializer.getDayTime(bytes, startOffset + 1)));
                                 intSerde.serialize(aMutableInt64, out);
+                                result.set(resultStorage);
                                 return;
                             }
 
                             long chrononTimeInMs = 0;
-                            if (bytes[0] == ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
-                                chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, 1);
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
-                                chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, 1);
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
+                                chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, startOffset + 1);
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
+                                chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, startOffset + 1);
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
                             } else {
-                                throw new AlgebricksException("Inapplicable input type: " + bytes[0]);
+                                throw new AlgebricksException("Inapplicable input type: " + bytes[startOffset]);
                             }
 
                             int min = calSystem.getMinOfHour(chrononTimeInMs);
-
                             aMutableInt64.setValue(min);
                             intSerde.serialize(aMutableInt64, out);
-
                         } catch (IOException e) {
                             throw new AlgebricksException(e);
                         }
+                        result.set(resultStorage);
                     }
                 };
             }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java
index 5d721c4..4a27e82 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java
@@ -38,10 +38,12 @@ import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.data.std.api.IDataOutputProvider;
+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;
 
@@ -61,20 +63,19 @@ public class TemporalMonthAccessor extends AbstractScalarFunctionDynamicDescript
      * @see org.apache.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
      */
     @Override
-    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
-        return new ICopyEvaluatorFactory() {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+            throws AlgebricksException {
+        return new IScalarEvaluatorFactory() {
 
             private static final long serialVersionUID = 1L;
 
             @Override
-            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
-                return new ICopyEvaluator() {
-
-                    private final DataOutput out = output.getDataOutput();
-
-                    private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
-
-                    private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
+                    private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private final DataOutput out = resultStorage.getDataOutput();
+                    private final IPointable argPtr = new VoidPointable();
+                    private final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
 
                     private final GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
 
@@ -88,38 +89,40 @@ public class TemporalMonthAccessor extends AbstractScalarFunctionDynamicDescript
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut.reset();
-                        eval.evaluate(tuple);
-                        byte[] bytes = argOut.getByteArray();
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        eval.evaluate(tuple, argPtr);
+                        byte[] bytes = argPtr.getByteArray();
+                        int startOffset = argPtr.getStartOffset();
 
+                        resultStorage.reset();
                         try {
-
-                            if (bytes[0] == ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
-                                aMutableInt64.setValue(calSystem
-                                        .getDurationMonth(ADurationSerializerDeserializer.getYearMonth(bytes, 1)));
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
+                                aMutableInt64.setValue(calSystem.getDurationMonth(
+                                        ADurationSerializerDeserializer.getYearMonth(bytes, startOffset + 1)));
                                 intSerde.serialize(aMutableInt64, out);
+                                result.set(resultStorage);
                                 return;
                             }
-
-                            if (bytes[0] == ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG) {
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG) {
                                 aMutableInt64.setValue(calSystem.getDurationMonth(
-                                        AYearMonthDurationSerializerDeserializer.getYearMonth(bytes, 1)));
+                                        AYearMonthDurationSerializerDeserializer.getYearMonth(bytes, startOffset + 1)));
                                 intSerde.serialize(aMutableInt64, out);
+                                result.set(resultStorage);
                                 return;
                             }
 
                             long chrononTimeInMs = 0;
-                            if (bytes[0] == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
-                                chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, 1)
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
+                                chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, startOffset + 1)
                                         * GregorianCalendarSystem.CHRONON_OF_DAY;
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
-                                chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, 1);
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
+                                chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, startOffset + 1);
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
                             } else {
-                                throw new AlgebricksException("Inapplicable input type: " + bytes[0]);
+                                throw new AlgebricksException("Inapplicable input type: " + bytes[startOffset]);
                             }
 
                             int year = calSystem.getYear(chrononTimeInMs);
@@ -127,10 +130,10 @@ public class TemporalMonthAccessor extends AbstractScalarFunctionDynamicDescript
 
                             aMutableInt64.setValue(month);
                             intSerde.serialize(aMutableInt64, out);
-
                         } catch (IOException e) {
                             throw new AlgebricksException(e);
                         }
+                        result.set(resultStorage);
                     }
                 };
             }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java
index 49db89d..6abe7a3 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java
@@ -38,10 +38,12 @@ import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.data.std.api.IDataOutputProvider;
+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;
 
@@ -61,20 +63,19 @@ public class TemporalSecondAccessor extends AbstractScalarFunctionDynamicDescrip
      * @see org.apache.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
      */
     @Override
-    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
-        return new ICopyEvaluatorFactory() {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+            throws AlgebricksException {
+        return new IScalarEvaluatorFactory() {
 
             private static final long serialVersionUID = 1L;
 
             @Override
-            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
-                return new ICopyEvaluator() {
-
-                    private final DataOutput out = output.getDataOutput();
-
-                    private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
-
-                    private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
+                    private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private final DataOutput out = resultStorage.getDataOutput();
+                    private final IPointable argPtr = new VoidPointable();
+                    private final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
 
                     private final GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
 
@@ -88,47 +89,50 @@ public class TemporalSecondAccessor extends AbstractScalarFunctionDynamicDescrip
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut.reset();
-                        eval.evaluate(tuple);
-                        byte[] bytes = argOut.getByteArray();
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        eval.evaluate(tuple, argPtr);
+                        byte[] bytes = argPtr.getByteArray();
+                        int startOffset = argPtr.getStartOffset();
 
+                        resultStorage.reset();
                         try {
-
-                            if (bytes[0] == ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
-                                aMutableInt64.setValue(calSystem
-                                        .getDurationSecond(ADurationSerializerDeserializer.getDayTime(bytes, 1)));
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
+                                aMutableInt64.setValue(calSystem.getDurationSecond(
+                                        ADurationSerializerDeserializer.getDayTime(bytes, startOffset + 1)));
                                 intSerde.serialize(aMutableInt64, out);
+                                result.set(resultStorage);
                                 return;
                             }
 
-                            if (bytes[0] == ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG) {
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG) {
                                 aMutableInt64.setValue(calSystem.getDurationSecond(
-                                        ADayTimeDurationSerializerDeserializer.getDayTime(bytes, 1)));
+                                        ADayTimeDurationSerializerDeserializer.getDayTime(bytes, startOffset + 1)));
                                 intSerde.serialize(aMutableInt64, out);
+                                result.set(resultStorage);
                                 return;
                             }
 
                             long chrononTimeInMs = 0;
-                            if (bytes[0] == ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
-                                chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, 1);
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
-                                chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, 1);
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
+                                chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, startOffset + 1);
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
+                                chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, startOffset + 1);
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
                             } else {
-                                throw new AlgebricksException("Inapplicable input type: " + bytes[0]);
+                                throw new AlgebricksException("Inapplicable input type: " + bytes[startOffset]);
                             }
 
                             int sec = calSystem.getSecOfMin(chrononTimeInMs);
 
                             aMutableInt64.setValue(sec);
                             intSerde.serialize(aMutableInt64, out);
-
                         } catch (IOException e) {
                             throw new AlgebricksException(e);
                         }
+                        result.set(resultStorage);
                     }
                 };
             }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java
index 928d6ea..ccf54c6 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java
@@ -38,11 +38,13 @@ import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.data.std.api.IDataOutputProvider;
+import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
+import org.apache.hyracks.data.std.primitive.VoidPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.data.std.util.UTF8StringCharacterIterator;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
@@ -59,20 +61,19 @@ public class TemporalYearAccessor extends AbstractScalarFunctionDynamicDescripto
     };
 
     @Override
-    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
-        return new ICopyEvaluatorFactory() {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+            throws AlgebricksException {
+        return new IScalarEvaluatorFactory() {
 
             private static final long serialVersionUID = 1L;
 
             @Override
-            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
-                return new ICopyEvaluator() {
-
-                    private final DataOutput out = output.getDataOutput();
-
-                    private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
-
-                    private final ICopyEvaluator eval = args[0].createEvaluator(argOut);
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
+                    private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private final DataOutput out = resultStorage.getDataOutput();
+                    private final IPointable argPtr = new VoidPointable();
+                    private final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
 
                     private final GregorianCalendarSystem calSystem = GregorianCalendarSystem.getInstance();
 
@@ -89,39 +90,42 @@ public class TemporalYearAccessor extends AbstractScalarFunctionDynamicDescripto
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut.reset();
-                        eval.evaluate(tuple);
-                        byte[] bytes = argOut.getByteArray();
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        eval.evaluate(tuple, argPtr);
+                        byte[] bytes = argPtr.getByteArray();
+                        int startOffset = argPtr.getStartOffset();
+                        int len = argPtr.getLength();
 
+                        resultStorage.reset();
                         try {
-
-                            if (bytes[0] == ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
-                                aMutableInt64.setValue(calSystem
-                                        .getDurationYear(ADurationSerializerDeserializer.getYearMonth(bytes, 1)));
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
+                                aMutableInt64.setValue(calSystem.getDurationYear(
+                                        ADurationSerializerDeserializer.getYearMonth(bytes, startOffset + 1)));
                                 intSerde.serialize(aMutableInt64, out);
+                                result.set(resultStorage);
                                 return;
                             }
-
-                            if (bytes[0] == ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG) {
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG) {
                                 aMutableInt64.setValue(calSystem.getDurationYear(
-                                        AYearMonthDurationSerializerDeserializer.getYearMonth(bytes, 1)));
+                                        AYearMonthDurationSerializerDeserializer.getYearMonth(bytes, startOffset + 1)));
                                 intSerde.serialize(aMutableInt64, out);
+                                result.set(resultStorage);
                                 return;
                             }
 
                             long chrononTimeInMs = 0;
-                            if (bytes[0] == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
-                                chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, 1)
+                            if (bytes[startOffset] == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
+                                chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, startOffset + 1)
                                         * GregorianCalendarSystem.CHRONON_OF_DAY;
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
-                                chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, 1);
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
+                                chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, startOffset + 1);
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
-                            } else if (bytes[0] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+                            } else if (bytes[startOffset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
                                 int year;
-                                strExprPtr.set(bytes, 1, bytes.length);
+                                strExprPtr.set(bytes, startOffset + 1, len - 1);
                                 strIter.reset(strExprPtr);
                                 char firstChar = strIter.next();
                                 if (firstChar == '-') {
@@ -134,16 +138,17 @@ public class TemporalYearAccessor extends AbstractScalarFunctionDynamicDescripto
                                 }
                                 aMutableInt64.setValue(year);
                                 intSerde.serialize(aMutableInt64, out);
+                                result.set(resultStorage);
                                 return;
                             } else {
-                                throw new AlgebricksException("Inapplicable input type: " + bytes[0]);
+                                throw new AlgebricksException("Inapplicable input type: " + bytes[startOffset]);
                             }
 
                             int year = calSystem.getYear(chrononTimeInMs);
 
                             aMutableInt64.setValue(year);
                             intSerde.serialize(aMutableInt64, out);
-
+                            result.set(resultStorage);
                         } catch (IOException e) {
                             throw new AlgebricksException(e);
                         }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/AccessibleByteArrayEval.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/AccessibleByteArrayEval.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/AccessibleByteArrayEval.java
index 92a5d4e..f621241 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/AccessibleByteArrayEval.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/AccessibleByteArrayEval.java
@@ -20,27 +20,19 @@ package org.apache.asterix.runtime.evaluators.common;
 
 import java.io.DataOutput;
 import java.io.DataOutputStream;
-import java.io.IOException;
 
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.util.ByteArrayAccessibleOutputStream;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
-public class AccessibleByteArrayEval implements ICopyEvaluator {
+public class AccessibleByteArrayEval implements IScalarEvaluator {
 
-    private DataOutput out;
     private ByteArrayAccessibleOutputStream baaos;
     private DataOutput dataOutput;
 
-    public AccessibleByteArrayEval(DataOutput out) {
-        this.out = out;
-        this.baaos = new ByteArrayAccessibleOutputStream();
-        this.dataOutput = new DataOutputStream(baaos);
-    }
-
-    public AccessibleByteArrayEval(DataOutput out, ByteArrayAccessibleOutputStream baaos) {
-        this.out = out;
+    public AccessibleByteArrayEval(ByteArrayAccessibleOutputStream baaos) {
         this.baaos = baaos;
         this.dataOutput = new DataOutputStream(baaos);
     }
@@ -50,16 +42,8 @@ public class AccessibleByteArrayEval implements ICopyEvaluator {
     }
 
     @Override
-    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-        try {
-            out.write(baaos.getByteArray(), 0, baaos.size());
-        } catch (IOException e) {
-            throw new AlgebricksException(e);
-        }
-    }
-
-    public void setBaaos(ByteArrayAccessibleOutputStream baaos) {
-        this.baaos = baaos;
+    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+        result.set(baaos.getByteArray(), 0, baaos.size());
     }
 
     public ByteArrayAccessibleOutputStream getBaaos() {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
index ed8ce03..6ebb684 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
@@ -20,78 +20,75 @@
 package org.apache.asterix.runtime.evaluators.common;
 
 import java.io.DataOutput;
-import java.io.IOException;
 
 import org.apache.asterix.builders.IARecordBuilder;
 import org.apache.asterix.builders.RecordBuilder;
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+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.exceptions.HyracksDataException;
-import org.apache.hyracks.data.std.api.IDataOutputProvider;
+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;
 
-public class ClosedRecordConstructorEvalFactory implements ICopyEvaluatorFactory {
+public class ClosedRecordConstructorEvalFactory implements IScalarEvaluatorFactory {
 
     private static final long serialVersionUID = 1L;
 
-    private ICopyEvaluatorFactory[] args;
+    private IScalarEvaluatorFactory[] args;
     private ARecordType recType;
 
-    public ClosedRecordConstructorEvalFactory(ICopyEvaluatorFactory[] args, ARecordType recType) {
+    public ClosedRecordConstructorEvalFactory(IScalarEvaluatorFactory[] args, ARecordType recType) {
         this.args = args;
         this.recType = recType;
     }
 
     @Override
-    public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+    public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
         int n = args.length / 2;
-        ICopyEvaluator[] evalFields = new ICopyEvaluator[n];
-        ArrayBackedValueStorage fieldValueBuffer = new ArrayBackedValueStorage();
+        IScalarEvaluator[] evalFields = new IScalarEvaluator[n];
         for (int i = 0; i < n; i++) {
-            evalFields[i] = args[2 * i + 1].createEvaluator(fieldValueBuffer);
+            evalFields[i] = args[2 * i + 1].createScalarEvaluator(ctx);
         }
-        DataOutput out = output.getDataOutput();
-        return new ClosedRecordConstructorEval(recType, evalFields, fieldValueBuffer, out);
+        return new ClosedRecordConstructorEval(recType, evalFields);
     }
 
-    public static class ClosedRecordConstructorEval implements ICopyEvaluator {
-
-        private ICopyEvaluator[] evalFields;
-        private DataOutput out;
-        private IARecordBuilder recBuilder = new RecordBuilder();
-        private ARecordType recType;
-        private ArrayBackedValueStorage fieldValueBuffer = new ArrayBackedValueStorage();
+    public static class ClosedRecordConstructorEval implements IScalarEvaluator {
+        private IScalarEvaluator[] evalFields;
+        private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+        private final DataOutput out = resultStorage.getDataOutput();
+        private final IARecordBuilder recBuilder = new RecordBuilder();
+        private final ARecordType recType;
+        private final IPointable fieldValuePointable = new VoidPointable();
         private boolean first = true;
 
-        public ClosedRecordConstructorEval(ARecordType recType, ICopyEvaluator[] evalFields,
-                ArrayBackedValueStorage fieldValueBuffer, DataOutput out) {
+        public ClosedRecordConstructorEval(ARecordType recType, IScalarEvaluator[] evalFields) {
             this.evalFields = evalFields;
-            this.fieldValueBuffer = fieldValueBuffer;
-            this.out = out;
             this.recType = recType;
         }
 
         @Override
-        public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+        public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
             try {
+                resultStorage.reset();
                 if (first) {
                     first = false;
                     recBuilder.reset(this.recType);
                 }
                 recBuilder.init();
                 for (int i = 0; i < evalFields.length; i++) {
-                    fieldValueBuffer.reset();
-                    evalFields[i].evaluate(tuple);
-                    if (fieldValueBuffer.getByteArray()[0] != ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
-                        recBuilder.addField(i, fieldValueBuffer);
+                    evalFields[i].evaluate(tuple, fieldValuePointable);
+                    if (fieldValuePointable.getByteArray()[fieldValuePointable
+                            .getStartOffset()] != ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                        recBuilder.addField(i, fieldValuePointable);
                     }
                 }
                 recBuilder.write(out, true);
+                result.set(resultStorage);
             } catch (HyracksDataException e) {
                 throw new AlgebricksException(e);
             }



Mime
View raw message