asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject [02/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:31 GMT
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
index 2e493c5..2160910 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
@@ -40,11 +40,13 @@ 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.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;
 
@@ -60,24 +62,26 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
     };
 
     @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() {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
 
-                    private final DataOutput out = output.getDataOutput();
+                    private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private final DataOutput out = resultStorage.getDataOutput();
 
-                    private final ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
-                    private final ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
-                    private final ArrayBackedValueStorage argOut2 = new ArrayBackedValueStorage();
+                    private final IPointable argPtr0 = new VoidPointable();
+                    private final IPointable argPtr1 = new VoidPointable();
+                    private final IPointable argPtr2 = new VoidPointable();
 
-                    private final ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
-                    private final ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
-                    private final ICopyEvaluator eval2 = args[2].createEvaluator(argOut2);
+                    private final IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
+                    private final IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
+                    private final IScalarEvaluator eval2 = args[2].createScalarEvaluator(ctx);
 
                     private final AMutableInterval aInterval = new AMutableInterval(0, 0, (byte) -1);
 
@@ -91,23 +95,25 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                     private final GregorianCalendarSystem GREG_CAL = GregorianCalendarSystem.getInstance();
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut0.reset();
-                        eval0.evaluate(tuple);
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        resultStorage.reset();
+                        eval0.evaluate(tuple, argPtr0);
+                        byte[] bytes0 = argPtr0.getByteArray();
+                        int offset0 = argPtr0.getStartOffset();
 
-                        ATypeTag type0 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]);
+                        ATypeTag type0 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]);
 
                         long chrononToBin = 0;
                         switch (type0) {
                             case DATE:
-                                chrononToBin = ADateSerializerDeserializer.getChronon(argOut0.getByteArray(), 1)
+                                chrononToBin = ADateSerializerDeserializer.getChronon(bytes0, offset0 + 1)
                                         * GregorianCalendarSystem.CHRONON_OF_DAY;
                                 break;
                             case TIME:
-                                chrononToBin = ATimeSerializerDeserializer.getChronon(argOut0.getByteArray(), 1);
+                                chrononToBin = ATimeSerializerDeserializer.getChronon(bytes0, offset0 + 1);
                                 break;
                             case DATETIME:
-                                chrononToBin = ADateTimeSerializerDeserializer.getChronon(argOut0.getByteArray(), 1);
+                                chrononToBin = ADateTimeSerializerDeserializer.getChronon(bytes0, offset0 + 1);
                                 break;
                             case NULL:
                                 try {
@@ -115,6 +121,7 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                                 } catch (HyracksDataException e) {
                                     throw new AlgebricksException(e);
                                 }
+                                result.set(resultStorage);
                                 return;
                             default:
                                 throw new AlgebricksException(getIdentifier().getName()
@@ -122,28 +129,29 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
 
                         }
 
-                        argOut1.reset();
-                        eval1.evaluate(tuple);
-
-                        ATypeTag type1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]);
+                        eval1.evaluate(tuple, argPtr1);
+                        byte[] bytes1 = argPtr1.getByteArray();
+                        int offset1 = argPtr1.getStartOffset();
+                        ATypeTag type1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]);
 
                         if (type0 != type1) {
-                            if (type0 != ATypeTag.NULL && type1 != ATypeTag.NULL)
+                            if (type0 != ATypeTag.NULL && type1 != ATypeTag.NULL) {
                                 throw new AlgebricksException(getIdentifier().getName() + ": expecting " + type0
                                         + " for the second argument but got " + type1);
+                            }
                         }
 
                         long chrononToStart = 0;
                         switch (type1) {
                             case DATE:
-                                chrononToStart = ADateSerializerDeserializer.getChronon(argOut1.getByteArray(), 1)
+                                chrononToStart = ADateSerializerDeserializer.getChronon(bytes1, offset1 + 1)
                                         * GregorianCalendarSystem.CHRONON_OF_DAY;
                                 break;
                             case TIME:
-                                chrononToStart = ATimeSerializerDeserializer.getChronon(argOut1.getByteArray(), 1);
+                                chrononToStart = ATimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
                                 break;
                             case DATETIME:
-                                chrononToStart = ADateTimeSerializerDeserializer.getChronon(argOut1.getByteArray(), 1);
+                                chrononToStart = ADateTimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
                                 break;
                             case NULL:
                                 try {
@@ -151,26 +159,24 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                                 } catch (HyracksDataException e) {
                                     throw new AlgebricksException(e);
                                 }
+                                result.set(resultStorage);
                                 return;
                             default:
                                 throw new AlgebricksException(getIdentifier().getName() + ": expecting " + type0
                                         + " for the second argument but got " + type1);
                         }
 
-                        argOut2.reset();
-                        eval2.evaluate(tuple);
-
-                        ATypeTag type2 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut2.getByteArray()[0]);
+                        eval2.evaluate(tuple, argPtr2);
+                        byte[] bytes2 = argPtr2.getByteArray();
+                        int offset2 = argPtr2.getStartOffset();
+                        ATypeTag type2 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes2[offset2]);
 
                         int yearMonth = 0;
                         long dayTime = 0;
                         long binIndex, binStartChronon, binEndChronon;
                         switch (type2) {
                             case YEARMONTHDURATION:
-
-                                yearMonth = AYearMonthDurationSerializerDeserializer
-                                        .getYearMonth(argOut2.getByteArray(), 1);
-
+                                yearMonth = AYearMonthDurationSerializerDeserializer.getYearMonth(bytes2, offset2 + 1);
                                 int yearStart = GREG_CAL.getYear(chrononToStart);
                                 int monthStart = GREG_CAL.getMonthOfYear(chrononToStart, yearStart);
                                 int yearToBin = GREG_CAL.getYear(chrononToBin);
@@ -194,8 +200,7 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                                 break;
 
                             case DAYTIMEDURATION:
-                                dayTime = ADayTimeDurationSerializerDeserializer.getDayTime(argOut2.getByteArray(), 1);
-
+                                dayTime = ADayTimeDurationSerializerDeserializer.getDayTime(bytes2, offset2 + 1);
                                 long totalChronon = chrononToBin - chrononToStart;
 
                                 binIndex = totalChronon / dayTime
@@ -208,6 +213,7 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                                 } catch (HyracksDataException e) {
                                     throw new AlgebricksException(e);
                                 }
+                                result.set(resultStorage);
                                 return;
                             default:
                                 throw new AlgebricksException(getIdentifier().getName()
@@ -253,6 +259,7 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                                 } catch (HyracksDataException e) {
                                     throw new AlgebricksException(e);
                                 }
+                                result.set(resultStorage);
                                 return;
                             default:
                                 throw new AlgebricksException(getIdentifier().getName()
@@ -262,10 +269,10 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                         try {
                             aInterval.setValue(binStartChronon, binEndChronon, type0.serialize());
                             intervalSerde.serialize(aInterval, out);
-                            return;
                         } catch (HyracksDataException ex) {
                             throw new AlgebricksException(ex);
                         }
+                        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/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
index a16c59a..4b1fedd 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
@@ -34,11 +34,13 @@ 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.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;
 
@@ -54,18 +56,20 @@ public class MillisecondsFromDayTimeDurationDescriptor extends AbstractScalarFun
     };
 
     @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() {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
 
-                    private DataOutput out = output.getDataOutput();
-                    private ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
-                    private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
+                    private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private DataOutput out = resultStorage.getDataOutput();
+                    private IPointable argPtr0 = new VoidPointable();
+                    private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
 
                     // possible output types
                     @SuppressWarnings("unchecked")
@@ -78,30 +82,32 @@ public class MillisecondsFromDayTimeDurationDescriptor extends AbstractScalarFun
                     AMutableInt64 aInt64 = new AMutableInt64(0);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut0.reset();
-                        eval0.evaluate(tuple);
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        resultStorage.reset();
+                        eval0.evaluate(tuple, argPtr0);
+
+                        byte[] bytes = argPtr0.getByteArray();
+                        int offset = argPtr0.getStartOffset();
 
                         try {
-                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG) {
-                                throw new AlgebricksException(FID.getName()
-                                        + ": expects NULL/DAY-TIME-DURATION, but got "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
+                            if (bytes[offset] != ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG) {
+                                throw new AlgebricksException(
+                                        FID.getName() + ": expects NULL/DAY-TIME-DURATION, but got "
+                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
                             }
 
-                            aInt64.setValue(
-                                    ADayTimeDurationSerializerDeserializer.getDayTime(argOut0.getByteArray(), 1));
-
+                            aInt64.setValue(ADayTimeDurationSerializerDeserializer.getDayTime(bytes, offset + 1));
                             int64Serde.serialize(aInt64, out);
-
                         } catch (HyracksDataException hex) {
                             throw new AlgebricksException(hex);
                         }
+                        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/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
index e7c7863..d7198f1 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
@@ -34,11 +34,13 @@ 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.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;
 
@@ -54,18 +56,20 @@ public class MonthsFromYearMonthDurationDescriptor 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() {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
 
-                    private DataOutput out = output.getDataOutput();
-                    private ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
-                    private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
+                    private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private DataOutput out = resultStorage.getDataOutput();
+                    private IPointable argPtr0 = new VoidPointable();
+                    private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
 
                     // possible output types
                     @SuppressWarnings("unchecked")
@@ -78,30 +82,32 @@ public class MonthsFromYearMonthDurationDescriptor extends AbstractScalarFunctio
                     AMutableInt64 aInt64 = new AMutableInt64(0);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut0.reset();
-                        eval0.evaluate(tuple);
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        resultStorage.reset();;
+                        eval0.evaluate(tuple, argPtr0);
+
+                        byte[] bytes = argPtr0.getByteArray();
+                        int offset = argPtr0.getStartOffset();
 
                         try {
-                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG) {
-                                throw new AlgebricksException(FID.getName()
-                                        + ": expects NULL/YEAR-MONTH-DURATION, but got "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
+                            if (bytes[offset] != ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG) {
+                                throw new AlgebricksException(
+                                        FID.getName() + ": expects NULL/YEAR-MONTH-DURATION, but got "
+                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
                             }
 
-                            aInt64.setValue(
-                                    AYearMonthDurationSerializerDeserializer.getYearMonth(argOut0.getByteArray(), 1));
-
+                            aInt64.setValue(AYearMonthDurationSerializerDeserializer.getYearMonth(bytes, offset + 1));
                             int64Serde.serialize(aInt64, out);
-
                         } catch (HyracksDataException hex) {
                             throw new AlgebricksException(hex);
                         }
+                        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/functions/temporal/OverlapBinsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java
index 917f7c3..fcf22e4 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java
@@ -44,11 +44,13 @@ 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.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;
 
@@ -64,24 +66,26 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
     };
 
     @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() {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
 
-                    private final DataOutput out = output.getDataOutput();
+                    private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private final DataOutput out = resultStorage.getDataOutput();
 
-                    private final ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
-                    private final ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
-                    private final ArrayBackedValueStorage argOut2 = new ArrayBackedValueStorage();
+                    private final IPointable argPtr0 = new VoidPointable();
+                    private final IPointable argPtr1 = new VoidPointable();
+                    private final IPointable argPtr2 = new VoidPointable();
 
-                    private final ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
-                    private final ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
-                    private final ICopyEvaluator eval2 = args[2].createEvaluator(argOut2);
+                    private final IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
+                    private final IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
+                    private final IScalarEvaluator eval2 = args[2].createScalarEvaluator(ctx);
 
                     // for output
                     private OrderedListBuilder listBuilder = new OrderedListBuilder();
@@ -100,26 +104,28 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                     private final GregorianCalendarSystem GREG_CAL = GregorianCalendarSystem.getInstance();
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut0.reset();
-                        eval0.evaluate(tuple);
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        resultStorage.reset();
+                        eval0.evaluate(tuple, argPtr0);
+                        byte[] bytes0 = argPtr0.getByteArray();
+                        int offset0 = argPtr0.getStartOffset();
 
-                        ATypeTag type0 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]);
+                        ATypeTag type0 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]);
 
                         long intervalStart = 0, intervalEnd = 0;
                         byte intervalTypeTag;
 
                         if (type0 == ATypeTag.INTERVAL) {
-                            intervalStart = AIntervalSerializerDeserializer.getIntervalStart(argOut0.getByteArray(), 1);
-                            intervalEnd = AIntervalSerializerDeserializer.getIntervalEnd(argOut0.getByteArray(), 1);
-                            intervalTypeTag = AIntervalSerializerDeserializer
-                                    .getIntervalTimeType(argOut0.getByteArray(), 1);
+                            intervalStart = AIntervalSerializerDeserializer.getIntervalStart(bytes0, offset0 + 1);
+                            intervalEnd = AIntervalSerializerDeserializer.getIntervalEnd(bytes0, offset0 + 1);
+                            intervalTypeTag = AIntervalSerializerDeserializer.getIntervalTimeType(bytes0, offset0 + 1);
                         } else if (type0 == ATypeTag.NULL) {
                             try {
                                 nullSerde.serialize(ANull.NULL, out);
                             } catch (HyracksDataException e) {
                                 throw new AlgebricksException(e);
                             }
+                            result.set(resultStorage);
                             return;
                         } else {
                             throw new AlgebricksException(getIdentifier().getName()
@@ -127,29 +133,31 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                         }
 
                         // get the anchor instance time
-                        argOut1.reset();
-                        eval1.evaluate(tuple);
+                        eval1.evaluate(tuple, argPtr1);
+                        byte[] bytes1 = argPtr1.getByteArray();
+                        int offset1 = argPtr1.getStartOffset();
 
-                        ATypeTag type1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]);
+                        ATypeTag type1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]);
 
                         if (intervalTypeTag != type1.serialize()) {
-                            if (intervalTypeTag != ATypeTag.SERIALIZED_NULL_TYPE_TAG && type1 != ATypeTag.NULL)
+                            if (intervalTypeTag != ATypeTag.SERIALIZED_NULL_TYPE_TAG && type1 != ATypeTag.NULL) {
                                 throw new AlgebricksException(
                                         getIdentifier().getName() + ": expecting compatible type to " + type0 + "("
                                                 + intervalTypeTag + ") for the second argument but got " + type1);
+                            }
                         }
 
                         long anchorTime = 0;
                         switch (type1) {
                             case DATE:
-                                anchorTime = ADateSerializerDeserializer.getChronon(argOut1.getByteArray(), 1)
+                                anchorTime = ADateSerializerDeserializer.getChronon(bytes1, offset1 + 1)
                                         * GregorianCalendarSystem.CHRONON_OF_DAY;
                                 break;
                             case TIME:
-                                anchorTime = ATimeSerializerDeserializer.getChronon(argOut1.getByteArray(), 1);
+                                anchorTime = ATimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
                                 break;
                             case DATETIME:
-                                anchorTime = ADateTimeSerializerDeserializer.getChronon(argOut1.getByteArray(), 1);
+                                anchorTime = ADateTimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
                                 break;
                             case NULL:
                                 try {
@@ -157,6 +165,7 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                                 } catch (HyracksDataException e) {
                                     throw new AlgebricksException(e);
                                 }
+                                result.set(resultStorage);
                                 return;
                             default:
                                 throw new AlgebricksException(
@@ -164,18 +173,18 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                                                 + intervalTypeTag + ") for the second argument but got " + type1);
                         }
 
-                        argOut2.reset();
-                        eval2.evaluate(tuple);
+                        eval2.evaluate(tuple, argPtr2);
+                        byte[] bytes2 = argPtr2.getByteArray();
+                        int offset2 = argPtr2.getStartOffset();
 
-                        ATypeTag type2 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut2.getByteArray()[0]);
+                        ATypeTag type2 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes2[offset2]);
 
                         int yearMonth = 0;
                         long dayTime = 0;
                         long firstBinIndex;
                         switch (type2) {
                             case YEARMONTHDURATION:
-                                yearMonth = AYearMonthDurationSerializerDeserializer
-                                        .getYearMonth(argOut2.getByteArray(), 1);
+                                yearMonth = AYearMonthDurationSerializerDeserializer.getYearMonth(bytes2, offset2 + 1);
 
                                 int yearStart = GREG_CAL.getYear(anchorTime);
                                 int monthStart = GREG_CAL.getMonthOfYear(anchorTime, yearStart);
@@ -199,7 +208,7 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                                 break;
 
                             case DAYTIMEDURATION:
-                                dayTime = ADayTimeDurationSerializerDeserializer.getDayTime(argOut2.getByteArray(), 1);
+                                dayTime = ADayTimeDurationSerializerDeserializer.getDayTime(bytes2, offset2 + 1);
 
                                 long totalChronon = intervalStart - anchorTime;
 
@@ -213,6 +222,7 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                                 } catch (HyracksDataException e) {
                                     throw new AlgebricksException(e);
                                 }
+                                result.set(resultStorage);
                                 return;
 
                             default:
@@ -317,12 +327,11 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                                 throw new AlgebricksException(getIdentifier().getName()
                                         + ": the first argument should be DATE/TIME/DATETIME/NULL but got " + type0);
                             }
-
                             listBuilder.write(out, true);
                         } catch (IOException e1) {
                             throw new AlgebricksException(e1.getMessage());
                         }
-
+                        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/functions/temporal/ParseDateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java
index d4c93ff..1243394 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java
@@ -37,12 +37,14 @@ 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.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.UTF8StringPointable;
+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;
 
@@ -63,20 +65,22 @@ public class ParseDateDescriptor extends AbstractScalarFunctionDynamicDescriptor
     };
 
     @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() {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
 
-                    private DataOutput out = output.getDataOutput();
-                    private ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
-                    private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
-                    private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
-                    private ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
+                    private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private DataOutput out = resultStorage.getDataOutput();
+                    private IPointable argPtr0 = new VoidPointable();
+                    private IPointable argPtr1 = new VoidPointable();
+                    private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
+                    private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
 
                     @SuppressWarnings("unchecked")
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
@@ -89,34 +93,38 @@ public class ParseDateDescriptor extends AbstractScalarFunctionDynamicDescriptor
                     private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut0.reset();
-                        eval0.evaluate(tuple);
-                        argOut1.reset();
-                        eval1.evaluate(tuple);
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        resultStorage.reset();
+                        eval0.evaluate(tuple, argPtr0);
+                        eval1.evaluate(tuple, argPtr1);
+
+                        byte[] bytes0 = argPtr0.getByteArray();
+                        int offset0 = argPtr0.getStartOffset();
+                        int len0 = argPtr0.getLength();
+                        byte[] bytes1 = argPtr1.getByteArray();
+                        int offset1 = argPtr1.getStartOffset();
+                        int len1 = argPtr1.getLength();
 
                         try {
-                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
-                                    || argOut1.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                                    || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
-                                    || argOut1.getByteArray()[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
-                                throw new AlgebricksException(
-                                        getIdentifier().getName() + ": expects two strings but got  ("
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(
-                                                        argOut0.getByteArray()[0])
-                                                + ", " + EnumDeserializer.ATYPETAGDESERIALIZER
-                                                        .deserialize(argOut1.getByteArray()[0])
-                                                + ")");
+                            if (bytes0[offset0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+                                    || bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+                                throw new AlgebricksException(getIdentifier().getName()
+                                        + ": expects two strings but got  ("
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + ", "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]) + ")");
                             }
-                            utf8Ptr.set(argOut0.getByteArray(), 1, argOut0.getLength() - 1);
+                            utf8Ptr.set(bytes0, offset0 + 1, len0 - 1);
                             int start0 = utf8Ptr.getCharStartOffset();
                             int length0 = utf8Ptr.getUTF8Length();
 
-                            utf8Ptr.set(argOut1.getByteArray(), 1, argOut1.getLength() - 1);
+                            utf8Ptr.set(bytes1, offset1 + 1, len1 - 1);
                             int start1 = utf8Ptr.getCharStartOffset();
                             int length1 = utf8Ptr.getUTF8Length();
                             long chronon = 0;
@@ -128,14 +136,13 @@ public class ParseDateDescriptor extends AbstractScalarFunctionDynamicDescriptor
                                 // search for "|"
                                 formatLength = 0;
                                 for (; formatStart + formatLength < start1 + length1; formatLength++) {
-                                    if (argOut1.getByteArray()[formatStart + formatLength] == '|') {
+                                    if (argPtr1.getByteArray()[formatStart + formatLength] == '|') {
                                         break;
                                     }
                                 }
                                 try {
-                                    chronon = DT_UTILS.parseDateTime(argOut0.getByteArray(), start0, length0,
-                                            argOut1.getByteArray(), formatStart, formatLength,
-                                            DateTimeParseMode.DATE_ONLY);
+                                    chronon = DT_UTILS.parseDateTime(bytes0, start0, length0, bytes1, formatStart,
+                                            formatLength, DateTimeParseMode.DATE_ONLY);
                                 } catch (AsterixTemporalTypeParseException ex) {
                                     formatStart += formatLength + 1;
                                     continue;
@@ -150,10 +157,10 @@ public class ParseDateDescriptor extends AbstractScalarFunctionDynamicDescriptor
 
                             aDate.setValue((int) (chronon / GregorianCalendarSystem.CHRONON_OF_DAY));
                             dateSerde.serialize(aDate, out);
-
                         } catch (HyracksDataException ex) {
                             throw new AlgebricksException(ex);
                         }
+                        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/functions/temporal/ParseDateTimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java
index bdd0783..7c8847a 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java
@@ -36,12 +36,14 @@ 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.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.UTF8StringPointable;
+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;
 
@@ -58,20 +60,22 @@ public class ParseDateTimeDescriptor extends AbstractScalarFunctionDynamicDescri
     };
 
     @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() {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
 
-                    private DataOutput out = output.getDataOutput();
-                    private ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
-                    private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
-                    private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
-                    private ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
+                    private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private DataOutput out = resultStorage.getDataOutput();
+                    private IPointable argPtr0 = new VoidPointable();
+                    private IPointable argPtr1 = new VoidPointable();
+                    private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
+                    private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
 
                     @SuppressWarnings("unchecked")
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
@@ -84,34 +88,38 @@ public class ParseDateTimeDescriptor extends AbstractScalarFunctionDynamicDescri
                     private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut0.reset();
-                        eval0.evaluate(tuple);
-                        argOut1.reset();
-                        eval1.evaluate(tuple);
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        resultStorage.reset();
+                        eval0.evaluate(tuple, argPtr0);
+                        eval1.evaluate(tuple, argPtr1);
+
+                        byte[] bytes0 = argPtr0.getByteArray();
+                        int offset0 = argPtr0.getStartOffset();
+                        int len0 = argPtr0.getLength();
+                        byte[] bytes1 = argPtr1.getByteArray();
+                        int offset1 = argPtr1.getStartOffset();
+                        int len1 = argPtr1.getLength();
 
                         try {
-                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
-                                    || argOut1.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                                    || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
-                                    || argOut1.getByteArray()[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
-                                throw new AlgebricksException(
-                                        getIdentifier().getName() + ": expects two strings but got  ("
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(
-                                                        argOut0.getByteArray()[0])
-                                                + ", " + EnumDeserializer.ATYPETAGDESERIALIZER
-                                                        .deserialize(argOut1.getByteArray()[0])
-                                                + ")");
+                            if (bytes0[offset0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+                                    || bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+                                throw new AlgebricksException(getIdentifier().getName()
+                                        + ": expects two strings but got  ("
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + ", "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]) + ")");
                             }
-                            utf8Ptr.set(argOut0.getByteArray(), 1, argOut0.getLength() - 1);
+                            utf8Ptr.set(bytes0, offset0 + 1, len0 - 1);
                             int start0 = utf8Ptr.getCharStartOffset();
                             int length0 = utf8Ptr.getUTF8Length();
 
-                            utf8Ptr.set(argOut1.getByteArray(), 1, argOut1.getLength() - 1);
+                            utf8Ptr.set(bytes1, offset1 + 1, len1 - 1);
                             int start1 = utf8Ptr.getCharStartOffset();
                             int length1 = utf8Ptr.getUTF8Length();
                             long chronon = 0;
@@ -123,14 +131,13 @@ public class ParseDateTimeDescriptor extends AbstractScalarFunctionDynamicDescri
                                 // search for "|"
                                 formatLength = 0;
                                 for (; formatStart + formatLength < start1 + length1; formatLength++) {
-                                    if (argOut1.getByteArray()[formatStart + formatLength] == '|') {
+                                    if (bytes1[formatStart + formatLength] == '|') {
                                         break;
                                     }
                                 }
                                 try {
-                                    chronon = DT_UTILS.parseDateTime(argOut0.getByteArray(), start0, length0,
-                                            argOut1.getByteArray(), formatStart, formatLength,
-                                            DateTimeParseMode.DATETIME);
+                                    chronon = DT_UTILS.parseDateTime(bytes0, start0, length0, bytes1, formatStart,
+                                            formatLength, DateTimeParseMode.DATETIME);
                                 } catch (AsterixTemporalTypeParseException ex) {
                                     formatStart += formatLength + 1;
                                     continue;
@@ -142,13 +149,12 @@ public class ParseDateTimeDescriptor extends AbstractScalarFunctionDynamicDescri
                                 throw new HyracksDataException(
                                         "parse-datetime: Failed to match with any given format string!");
                             }
-
                             aDateTime.setValue(chronon);
                             datetimeSerde.serialize(aDateTime, out);
-
                         } catch (HyracksDataException ex) {
                             throw new AlgebricksException(ex);
                         }
+                        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/functions/temporal/ParseTimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java
index db6e8b3..893c357 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java
@@ -36,12 +36,14 @@ 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.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.UTF8StringPointable;
+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,22 @@ public class ParseTimeDescriptor extends AbstractScalarFunctionDynamicDescriptor
     };
 
     @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() {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
 
-                    private DataOutput out = output.getDataOutput();
-                    private ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
-                    private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
-                    private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
-                    private ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
+                    private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private DataOutput out = resultStorage.getDataOutput();
+                    private IPointable argPtr0 = new VoidPointable();
+                    private IPointable argPtr1 = new VoidPointable();
+                    private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
+                    private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
 
                     @SuppressWarnings("unchecked")
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
@@ -85,34 +89,38 @@ public class ParseTimeDescriptor extends AbstractScalarFunctionDynamicDescriptor
                     private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut0.reset();
-                        eval0.evaluate(tuple);
-                        argOut1.reset();
-                        eval1.evaluate(tuple);
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        resultStorage.reset();
+                        eval0.evaluate(tuple, argPtr0);
+                        eval1.evaluate(tuple, argPtr1);
+
+                        byte[] bytes0 = argPtr0.getByteArray();
+                        int offset0 = argPtr0.getStartOffset();
+                        int len0 = argPtr0.getLength();
+                        byte[] bytes1 = argPtr1.getByteArray();
+                        int offset1 = argPtr1.getStartOffset();
+                        int len1 = argPtr1.getLength();
 
                         try {
-                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
-                                    || argOut1.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                                    || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
-                                    || argOut1.getByteArray()[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
-                                throw new AlgebricksException(
-                                        getIdentifier().getName() + ": expects two strings but got  ("
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(
-                                                        argOut0.getByteArray()[0])
-                                                + ", " + EnumDeserializer.ATYPETAGDESERIALIZER
-                                                        .deserialize(argOut1.getByteArray()[0])
-                                                + ")");
+                            if (bytes0[offset0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+                                    || bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+                                throw new AlgebricksException(getIdentifier().getName()
+                                        + ": expects two strings but got  ("
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + ", "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]) + ")");
                             }
-                            utf8Ptr.set(argOut0.getByteArray(), 1, argOut0.getLength() - 1);
+                            utf8Ptr.set(bytes0, offset0 + 1, len0 - 1);
                             int start0 = utf8Ptr.getCharStartOffset();
                             int length0 = utf8Ptr.getUTF8Length();
 
-                            utf8Ptr.set(argOut1.getByteArray(), 1, argOut1.getLength() - 1);
+                            utf8Ptr.set(bytes1, offset1 + 1, len1 - 1);
                             int start1 = utf8Ptr.getCharStartOffset();
                             int length1 = utf8Ptr.getUTF8Length();
                             long chronon = 0;
@@ -124,14 +132,13 @@ public class ParseTimeDescriptor extends AbstractScalarFunctionDynamicDescriptor
                                 // search for "|"
                                 formatLength = 0;
                                 for (; formatStart + formatLength < start1 + length1; formatLength++) {
-                                    if (argOut1.getByteArray()[formatStart + formatLength] == '|') {
+                                    if (bytes1[formatStart + formatLength] == '|') {
                                         break;
                                     }
                                 }
                                 try {
-                                    chronon = DT_UTILS.parseDateTime(argOut0.getByteArray(), start0, length0,
-                                            argOut1.getByteArray(), formatStart, formatLength,
-                                            DateTimeParseMode.TIME_ONLY);
+                                    chronon = DT_UTILS.parseDateTime(bytes0, start0, length0, bytes1, formatStart,
+                                            formatLength, DateTimeParseMode.TIME_ONLY);
                                 } catch (AsterixTemporalTypeParseException ex) {
                                     formatStart += formatLength + 1;
                                     continue;
@@ -146,10 +153,10 @@ public class ParseTimeDescriptor extends AbstractScalarFunctionDynamicDescriptor
 
                             aTime.setValue((int) chronon);
                             timeSerde.serialize(aTime, out);
-
                         } catch (HyracksDataException ex) {
                             throw new AlgebricksException(ex);
                         }
+                        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/functions/temporal/PrintDateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateDescriptor.java
index d15534d..f48a5c4 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateDescriptor.java
@@ -36,10 +36,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;
 import org.apache.hyracks.util.string.UTF8StringUtil;
@@ -59,20 +61,22 @@ public class PrintDateDescriptor extends AbstractScalarFunctionDynamicDescriptor
     };
 
     @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() {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
 
-                    private DataOutput out = output.getDataOutput();
-                    private ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
-                    private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
-                    private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
-                    private ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
+                    private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private DataOutput out = resultStorage.getDataOutput();
+                    private IPointable argPtr0 = new VoidPointable();
+                    private IPointable argPtr1 = new VoidPointable();
+                    private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
+                    private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
 
                     @SuppressWarnings("unchecked")
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
@@ -82,44 +86,46 @@ public class PrintDateDescriptor extends AbstractScalarFunctionDynamicDescriptor
                     private final UTF8StringWriter utf8Writer = new UTF8StringWriter();
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut0.reset();
-                        eval0.evaluate(tuple);
-                        argOut1.reset();
-                        eval1.evaluate(tuple);
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        resultStorage.reset();
+                        eval0.evaluate(tuple, argPtr0);
+                        eval1.evaluate(tuple, argPtr1);
+
+                        byte[] bytes0 = argPtr0.getByteArray();
+                        int offset0 = argPtr0.getStartOffset();
+                        byte[] bytes1 = argPtr1.getByteArray();
+                        int offset1 = argPtr1.getStartOffset();
 
                         try {
-                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
-                                    || argOut1.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                                    || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_DATE_TYPE_TAG
-                                    || argOut1.getByteArray()[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
-                                throw new AlgebricksException(
-                                        getIdentifier().getName() + ": expects (DATE, STRING) but got  ("
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(
-                                                        argOut0.getByteArray()[0])
-                                                + ", " + EnumDeserializer.ATYPETAGDESERIALIZER
-                                                        .deserialize(argOut1.getByteArray()[0])
-                                                + ")");
+                            if (bytes0[offset0] != ATypeTag.SERIALIZED_DATE_TYPE_TAG
+                                    || bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+                                throw new AlgebricksException(getIdentifier().getName()
+                                        + ": expects (DATE, STRING) but got  ("
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + ", "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]) + ")");
                             }
 
-                            long chronon = ADateSerializerDeserializer.getChronon(argOut0.getByteArray(), 1)
+                            long chronon = ADateSerializerDeserializer.getChronon(bytes0, offset0 + 1)
                                     * GregorianCalendarSystem.CHRONON_OF_DAY;
-                            int formatLength = UTF8StringUtil.getUTFLength(argOut1.getByteArray(), 1);
+                            int formatLength = UTF8StringUtil.getUTFLength(bytes1, offset1 + 1);
                             int offset = UTF8StringUtil.getNumBytesToStoreLength(formatLength);
                             sbder.delete(0, sbder.length());
-                            DT_UTILS.printDateTime(chronon, 0, argOut1.getByteArray(), 1 + offset, formatLength, sbder,
+                            DT_UTILS.printDateTime(chronon, 0, bytes1, offset1 + 1 + offset, formatLength, sbder,
                                     DateTimeParseMode.DATE_ONLY);
 
                             out.writeByte(ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                             utf8Writer.writeUTF8(sbder.toString(), out);
-
                         } catch (IOException ex) {
                             throw new AlgebricksException(ex);
                         }
+                        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/functions/temporal/PrintDateTimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateTimeDescriptor.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateTimeDescriptor.java
index ba35a42..75fcfe7 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateTimeDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateTimeDescriptor.java
@@ -35,11 +35,13 @@ 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.UTF8StringPointable;
+import org.apache.hyracks.data.std.primitive.VoidPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 import org.apache.hyracks.util.string.UTF8StringWriter;
@@ -58,20 +60,22 @@ public class PrintDateTimeDescriptor extends AbstractScalarFunctionDynamicDescri
     };
 
     @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() {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+                return new IScalarEvaluator() {
 
-                    private DataOutput out = output.getDataOutput();
-                    private ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
-                    private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
-                    private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
-                    private ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
+                    private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+                    private DataOutput out = resultStorage.getDataOutput();
+                    private IPointable argPtr0 = new VoidPointable();
+                    private IPointable argPtr1 = new VoidPointable();
+                    private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
+                    private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
 
                     @SuppressWarnings("unchecked")
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
@@ -82,31 +86,34 @@ public class PrintDateTimeDescriptor extends AbstractScalarFunctionDynamicDescri
                     private UTF8StringPointable utf8Ptr = new UTF8StringPointable();
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                        argOut0.reset();
-                        eval0.evaluate(tuple);
-                        argOut1.reset();
-                        eval1.evaluate(tuple);
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                        resultStorage.reset();
+                        eval0.evaluate(tuple, argPtr0);
+                        eval1.evaluate(tuple, argPtr1);
+
+                        byte[] bytes0 = argPtr0.getByteArray();
+                        int offset0 = argPtr0.getStartOffset();
+                        byte[] bytes1 = argPtr1.getByteArray();
+                        int offset1 = argPtr1.getStartOffset();
+                        int len1 = argPtr1.getLength();
 
                         try {
-                            if (argOut0.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
-                                    || argOut1.getByteArray()[0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+                            if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+                                    || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
                                 nullSerde.serialize(ANull.NULL, out);
+                                result.set(resultStorage);
                                 return;
                             }
 
-                            if (argOut0.getByteArray()[0] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG
-                                    || argOut1.getByteArray()[0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
-                                throw new AlgebricksException(
-                                        getIdentifier().getName() + ": expects (DATETIME, STRING) but got  ("
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(
-                                                        argOut0.getByteArray()[0])
-                                                + ", " + EnumDeserializer.ATYPETAGDESERIALIZER
-                                                        .deserialize(argOut1.getByteArray()[0])
-                                                + ")");
+                            if (bytes0[offset0] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG
+                                    || bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+                                throw new AlgebricksException(getIdentifier().getName()
+                                        + ": expects (DATETIME, STRING) but got  ("
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + ", "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]) + ")");
                             }
-                            long chronon = ADateTimeSerializerDeserializer.getChronon(argOut0.getByteArray(), 1);
-                            utf8Ptr.set(argOut1.getByteArray(), 1, argOut1.getLength() - 1);
+                            long chronon = ADateTimeSerializerDeserializer.getChronon(bytes0, offset0 + 1);
+                            utf8Ptr.set(bytes1, offset1 + 1, len1 - 1);
                             int formatLength = utf8Ptr.getUTF8Length();
                             sbder.delete(0, sbder.length());
                             DT_UTILS.printDateTime(chronon, 0, utf8Ptr.getByteArray(), utf8Ptr.getCharStartOffset(),
@@ -114,10 +121,10 @@ public class PrintDateTimeDescriptor extends AbstractScalarFunctionDynamicDescri
 
                             out.writeByte(ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                             utf8Writer.writeUTF8(sbder.toString(), out);
-
                         } catch (IOException ex) {
                             throw new AlgebricksException(ex);
                         }
+                        result.set(resultStorage);
                     }
                 };
             }


Mime
View raw message