asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject [18/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:47 GMT
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/CreateMBREvalFactory.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/CreateMBREvalFactory.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/CreateMBREvalFactory.java
index d4563a8..c92daa2 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/CreateMBREvalFactory.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/CreateMBREvalFactory.java
@@ -34,82 +34,85 @@ import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-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 CreateMBREvalFactory implements ICopyEvaluatorFactory {
+public class CreateMBREvalFactory implements IScalarEvaluatorFactory {
 
     private static final long serialVersionUID = 1L;
 
-    private ICopyEvaluatorFactory recordEvalFactory;
-    private ICopyEvaluatorFactory dimensionEvalFactory;
-    private ICopyEvaluatorFactory coordinateEvalFactory;
+    private IScalarEvaluatorFactory recordEvalFactory;
+    private IScalarEvaluatorFactory dimensionEvalFactory;
+    private IScalarEvaluatorFactory coordinateEvalFactory;
 
-    public CreateMBREvalFactory(ICopyEvaluatorFactory recordEvalFactory, ICopyEvaluatorFactory dimensionEvalFactory,
-            ICopyEvaluatorFactory coordinateEvalFactory) {
+    public CreateMBREvalFactory(IScalarEvaluatorFactory recordEvalFactory, IScalarEvaluatorFactory dimensionEvalFactory,
+            IScalarEvaluatorFactory coordinateEvalFactory) {
         this.recordEvalFactory = recordEvalFactory;
         this.dimensionEvalFactory = dimensionEvalFactory;
         this.coordinateEvalFactory = coordinateEvalFactory;
     }
 
     @Override
-    public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
-        return new ICopyEvaluator() {
+    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 inputArg0 = new VoidPointable();
+            private final IPointable inputArg1 = new VoidPointable();
+            private final IPointable inputArg2 = new VoidPointable();
 
-            private DataOutput out = output.getDataOutput();
-
-            private ArrayBackedValueStorage outInput0 = new ArrayBackedValueStorage();
-            private ArrayBackedValueStorage outInput1 = new ArrayBackedValueStorage();
-            private ArrayBackedValueStorage outInput2 = new ArrayBackedValueStorage();
-
-            private ICopyEvaluator eval0 = recordEvalFactory.createEvaluator(outInput0);
-            private ICopyEvaluator eval1 = dimensionEvalFactory.createEvaluator(outInput1);
-            private ICopyEvaluator eval2 = coordinateEvalFactory.createEvaluator(outInput2);
+            private IScalarEvaluator eval0 = recordEvalFactory.createScalarEvaluator(ctx);
+            private IScalarEvaluator eval1 = dimensionEvalFactory.createScalarEvaluator(ctx);
+            private IScalarEvaluator eval2 = coordinateEvalFactory.createScalarEvaluator(ctx);
 
             @Override
-            public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-                outInput0.reset();
-                eval0.evaluate(tuple);
-                outInput1.reset();
-                eval1.evaluate(tuple);
-                outInput2.reset();
-                eval2.evaluate(tuple);
+            public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                eval0.evaluate(tuple, inputArg0);
+                eval1.evaluate(tuple, inputArg1);
+                eval2.evaluate(tuple, inputArg2);
+                int startOffset0 = inputArg0.getStartOffset();
+                int startOffset1 = inputArg1.getStartOffset();
+                int startOffset2 = inputArg2.getStartOffset();
 
+                resultStorage.reset();
                 // type-check: (Point/Line/Polygon/Circle/Rectangle/Null, Int32, Int32)
-                if (outInput1.getByteArray()[0] != ATypeTag.SERIALIZED_INT32_TYPE_TAG
-                        || outInput2.getByteArray()[0] != ATypeTag.SERIALIZED_INT32_TYPE_TAG) {
+                if (inputArg1.getByteArray()[startOffset1] != ATypeTag.SERIALIZED_INT32_TYPE_TAG
+                        || inputArg2.getByteArray()[startOffset2] != ATypeTag.SERIALIZED_INT32_TYPE_TAG) {
                     throw new AlgebricksException(
                             "Expects Types: (Point/Line/Polygon/Circle/Rectangle/Null, Int32, Int32).");
                 }
 
                 try {
-
-                    int dimension = AInt32SerializerDeserializer.getInt(outInput1.getByteArray(), 1);
-                    int coordinate = AInt32SerializerDeserializer.getInt(outInput2.getByteArray(), 1);
+                    int dimension = AInt32SerializerDeserializer.getInt(inputArg1.getByteArray(), startOffset1 + 1);
+                    int coordinate = AInt32SerializerDeserializer.getInt(inputArg2.getByteArray(), startOffset2 + 1);
                     double value;
                     if (dimension == 2) {
-                        ATypeTag tag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(outInput0.getByteArray()[0]);
+                        ATypeTag tag = EnumDeserializer.ATYPETAGDESERIALIZER
+                                .deserialize(inputArg0.getByteArray()[startOffset0]);
                         switch (tag) {
                             case POINT:
                                 switch (coordinate) {
                                     case 0: // 0 is for min x, 1 is for min y, 2
-                                           // for
-                                           // max x, and 3 for max y
+                                            // for
+                                            // max x, and 3 for max y
                                     case 2: {
-                                        double x = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                APointSerializerDeserializer.getCoordinateOffset(Coordinate.X));
-
+                                        double x = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                startOffset0 + APointSerializerDeserializer
+                                                        .getCoordinateOffset(Coordinate.X));
                                         value = x;
                                     }
                                         break;
                                     case 1:
                                     case 3: {
-                                        double y = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                APointSerializerDeserializer.getCoordinateOffset(Coordinate.Y));
+                                        double y = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                startOffset0 + APointSerializerDeserializer
+                                                        .getCoordinateOffset(Coordinate.Y));
 
                                         value = y;
                                     }
@@ -125,44 +128,48 @@ public class CreateMBREvalFactory implements ICopyEvaluatorFactory {
                                 switch (coordinate) {
                                     case 0: {
                                         value = Double.MAX_VALUE;
-                                        double startX = ADoubleSerializerDeserializer
-                                                .getDouble(outInput0.getByteArray(), ALineSerializerDeserializer
+                                        double startX = ADoubleSerializerDeserializer.getDouble(
+                                                inputArg0.getByteArray(), startOffset0 + ALineSerializerDeserializer
                                                         .getStartPointCoordinateOffset(Coordinate.X));
-                                        double endX = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                ALineSerializerDeserializer.getEndPointCoordinateOffset(Coordinate.X));
+                                        double endX = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                startOffset0 + ALineSerializerDeserializer
+                                                        .getEndPointCoordinateOffset(Coordinate.X));
 
                                         value = Math.min(Math.min(startX, endX), value);
                                     }
                                         break;
                                     case 1: {
                                         value = Double.MAX_VALUE;
-                                        double startY = ADoubleSerializerDeserializer
-                                                .getDouble(outInput0.getByteArray(), ALineSerializerDeserializer
+                                        double startY = ADoubleSerializerDeserializer.getDouble(
+                                                inputArg0.getByteArray(), startOffset0 + ALineSerializerDeserializer
                                                         .getStartPointCoordinateOffset(Coordinate.Y));
-                                        double endY = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                ALineSerializerDeserializer.getEndPointCoordinateOffset(Coordinate.Y));
+                                        double endY = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                startOffset0 + ALineSerializerDeserializer
+                                                        .getEndPointCoordinateOffset(Coordinate.Y));
 
                                         value = Math.min(Math.min(startY, endY), value);
                                     }
                                         break;
                                     case 2: {
                                         value = Double.MIN_VALUE;
-                                        double startX = ADoubleSerializerDeserializer
-                                                .getDouble(outInput0.getByteArray(), ALineSerializerDeserializer
+                                        double startX = ADoubleSerializerDeserializer.getDouble(
+                                                inputArg0.getByteArray(), startOffset0 + ALineSerializerDeserializer
                                                         .getStartPointCoordinateOffset(Coordinate.X));
-                                        double endX = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                ALineSerializerDeserializer.getEndPointCoordinateOffset(Coordinate.X));
+                                        double endX = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                startOffset0 + ALineSerializerDeserializer
+                                                        .getEndPointCoordinateOffset(Coordinate.X));
 
                                         value = Math.max(Math.min(startX, endX), value);
                                     }
                                         break;
                                     case 3: {
                                         value = Double.MIN_VALUE;
-                                        double startY = ADoubleSerializerDeserializer
-                                                .getDouble(outInput0.getByteArray(), ALineSerializerDeserializer
+                                        double startY = ADoubleSerializerDeserializer.getDouble(
+                                                inputArg0.getByteArray(), startOffset0 + ALineSerializerDeserializer
                                                         .getStartPointCoordinateOffset(Coordinate.Y));
-                                        double endY = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                ALineSerializerDeserializer.getEndPointCoordinateOffset(Coordinate.Y));
+                                        double endY = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                startOffset0 + ALineSerializerDeserializer
+                                                        .getEndPointCoordinateOffset(Coordinate.Y));
 
                                         value = Math.max(Math.min(startY, endY), value);
                                     }
@@ -174,14 +181,14 @@ public class CreateMBREvalFactory implements ICopyEvaluatorFactory {
                                 }
                                 break;
                             case POLYGON:
-                                int numOfPoints = AInt16SerializerDeserializer.getShort(outInput0.getByteArray(),
-                                        APolygonSerializerDeserializer.getNumberOfPointsOffset());
+                                int numOfPoints = AInt16SerializerDeserializer.getShort(inputArg0.getByteArray(),
+                                        startOffset0 + APolygonSerializerDeserializer.getNumberOfPointsOffset());
                                 switch (coordinate) {
                                     case 0: {
                                         value = Double.MAX_VALUE;
                                         for (int i = 0; i < numOfPoints; i++) {
-                                            double x = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                    APolygonSerializerDeserializer.getCoordinateOffset(i,
+                                            double x = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                    startOffset0 + APolygonSerializerDeserializer.getCoordinateOffset(i,
                                                             Coordinate.X));
                                             value = Math.min(x, value);
                                         }
@@ -190,8 +197,8 @@ public class CreateMBREvalFactory implements ICopyEvaluatorFactory {
                                     case 1: {
                                         value = Double.MAX_VALUE;
                                         for (int i = 0; i < numOfPoints; i++) {
-                                            double y = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                    APolygonSerializerDeserializer.getCoordinateOffset(i,
+                                            double y = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                    startOffset0 + APolygonSerializerDeserializer.getCoordinateOffset(i,
                                                             Coordinate.Y));
                                             value = Math.min(y, value);
                                         }
@@ -200,8 +207,8 @@ public class CreateMBREvalFactory implements ICopyEvaluatorFactory {
                                     case 2: {
                                         value = Double.MIN_VALUE;
                                         for (int i = 0; i < numOfPoints; i++) {
-                                            double x = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                    APolygonSerializerDeserializer.getCoordinateOffset(i,
+                                            double x = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                    startOffset0 + APolygonSerializerDeserializer.getCoordinateOffset(i,
                                                             Coordinate.X));
                                             value = Math.max(x, value);
                                         }
@@ -210,8 +217,8 @@ public class CreateMBREvalFactory implements ICopyEvaluatorFactory {
                                     case 3: {
                                         value = Double.MIN_VALUE;
                                         for (int i = 0; i < numOfPoints; i++) {
-                                            double y = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                    APolygonSerializerDeserializer.getCoordinateOffset(i,
+                                            double y = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                    startOffset0 + APolygonSerializerDeserializer.getCoordinateOffset(i,
                                                             Coordinate.Y));
                                             value = Math.max(y, value);
                                         }
@@ -226,45 +233,44 @@ public class CreateMBREvalFactory implements ICopyEvaluatorFactory {
                             case CIRCLE:
                                 switch (coordinate) {
                                     case 0: {
-                                        double x = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                ACircleSerializerDeserializer
+                                        double x = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                startOffset0 + ACircleSerializerDeserializer
                                                         .getCenterPointCoordinateOffset(Coordinate.X));
                                         double radius = ADoubleSerializerDeserializer.getDouble(
-                                                outInput0.getByteArray(),
-                                                ACircleSerializerDeserializer.getRadiusOffset());
-
+                                                inputArg0.getByteArray(),
+                                                startOffset0 + ACircleSerializerDeserializer.getRadiusOffset());
                                         value = x - radius;
                                     }
                                         break;
                                     case 1: {
-                                        double y = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                ACircleSerializerDeserializer
+                                        double y = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                startOffset0 + ACircleSerializerDeserializer
                                                         .getCenterPointCoordinateOffset(Coordinate.Y));
                                         double radius = ADoubleSerializerDeserializer.getDouble(
-                                                outInput0.getByteArray(),
-                                                ACircleSerializerDeserializer.getRadiusOffset());
+                                                inputArg0.getByteArray(),
+                                                startOffset0 + ACircleSerializerDeserializer.getRadiusOffset());
 
                                         value = y - radius;
                                     }
                                         break;
                                     case 2: {
-                                        double x = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                ACircleSerializerDeserializer
+                                        double x = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                startOffset0 + ACircleSerializerDeserializer
                                                         .getCenterPointCoordinateOffset(Coordinate.X));
                                         double radius = ADoubleSerializerDeserializer.getDouble(
-                                                outInput0.getByteArray(),
-                                                ACircleSerializerDeserializer.getRadiusOffset());
+                                                inputArg0.getByteArray(),
+                                                startOffset0 + ACircleSerializerDeserializer.getRadiusOffset());
 
                                         value = x + radius;
                                     }
                                         break;
                                     case 3: {
-                                        double y = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                ACircleSerializerDeserializer
+                                        double y = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                startOffset0 + ACircleSerializerDeserializer
                                                         .getCenterPointCoordinateOffset(Coordinate.Y));
                                         double radius = ADoubleSerializerDeserializer.getDouble(
-                                                outInput0.getByteArray(),
-                                                ACircleSerializerDeserializer.getRadiusOffset());
+                                                inputArg0.getByteArray(),
+                                                startOffset0 + ACircleSerializerDeserializer.getRadiusOffset());
 
                                         value = y + radius;
                                     }
@@ -279,26 +285,26 @@ public class CreateMBREvalFactory implements ICopyEvaluatorFactory {
                                 value = Double.MAX_VALUE;
                                 switch (coordinate) {
                                     case 0: {
-                                        value = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                ARectangleSerializerDeserializer
+                                        value = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                startOffset0 + ARectangleSerializerDeserializer
                                                         .getBottomLeftCoordinateOffset(Coordinate.X));
                                     }
                                         break;
                                     case 1: {
-                                        value = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                ARectangleSerializerDeserializer
+                                        value = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                startOffset0 + ARectangleSerializerDeserializer
                                                         .getBottomLeftCoordinateOffset(Coordinate.Y));
                                     }
                                         break;
                                     case 2: {
-                                        value = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                ARectangleSerializerDeserializer
+                                        value = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                startOffset0 + ARectangleSerializerDeserializer
                                                         .getUpperRightCoordinateOffset(Coordinate.X));
                                     }
                                         break;
                                     case 3: {
-                                        value = ADoubleSerializerDeserializer.getDouble(outInput0.getByteArray(),
-                                                ARectangleSerializerDeserializer
+                                        value = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+                                                startOffset0 + ARectangleSerializerDeserializer
                                                         .getUpperRightCoordinateOffset(Coordinate.Y));
                                     }
                                         break;
@@ -310,6 +316,7 @@ public class CreateMBREvalFactory implements ICopyEvaluatorFactory {
                                 break;
                             case NULL: {
                                 out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+                                result.set(resultStorage);
                                 return;
                             }
                             default:
@@ -328,6 +335,7 @@ public class CreateMBREvalFactory implements ICopyEvaluatorFactory {
                 } 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/common/EditDistanceCheckEvaluator.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceCheckEvaluator.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceCheckEvaluator.java
index b002195..915ff53 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceCheckEvaluator.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceCheckEvaluator.java
@@ -29,29 +29,31 @@ import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
 import org.apache.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.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;
 
 public class EditDistanceCheckEvaluator extends EditDistanceEvaluator {
 
-    protected final ICopyEvaluator edThreshEval;
-    protected long edThresh = -1;
+    protected final IScalarEvaluator edThreshEval;
+    protected int edThresh;
+    private final IPointable argPtrThreshold = new VoidPointable();
     protected final OrderedListBuilder listBuilder;
     protected ArrayBackedValueStorage listItemVal;
     @SuppressWarnings("unchecked")
     protected final ISerializerDeserializer<ABoolean> booleanSerde = AqlSerializerDeserializerProvider.INSTANCE
             .getSerializerDeserializer(BuiltinType.ABOOLEAN);
-    protected final static byte SER_INT32_TYPE_TAG = ATypeTag.INT32.serialize();
 
-    public EditDistanceCheckEvaluator(ICopyEvaluatorFactory[] args, IDataOutputProvider output)
+    public EditDistanceCheckEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext context)
             throws AlgebricksException {
-        super(args, output);
-        edThreshEval = args[2].createEvaluator(argOut);
+        super(args, context);
+        edThreshEval = args[2].createScalarEvaluator(context);
         listBuilder = new OrderedListBuilder();
         listItemVal = new ArrayBackedValueStorage();
     }
@@ -59,28 +61,30 @@ public class EditDistanceCheckEvaluator extends EditDistanceEvaluator {
     @Override
     protected void runArgEvals(IFrameTupleReference tuple) throws AlgebricksException {
         super.runArgEvals(tuple);
-        int edThreshStart = argOut.getLength();
-        edThreshEval.evaluate(tuple);
+        edThreshEval.evaluate(tuple, argPtrThreshold);
         try {
-            edThresh = ATypeHierarchy.getIntegerValue(argOut.getByteArray(), edThreshStart);
+            edThresh = ATypeHierarchy.getIntegerValue(argPtrThreshold.getByteArray(), argPtrThreshold.getStartOffset());
         } catch (HyracksDataException e) {
             throw new AlgebricksException(e);
         }
     }
 
     @Override
-    protected int computeResult(byte[] bytes, int firstStart, int secondStart, ATypeTag argType)
+    protected int computeResult(IPointable left, IPointable right, ATypeTag argType)
             throws AlgebricksException, HyracksDataException {
+        byte[] leftBytes = left.getByteArray();
+        int leftStartOffset = left.getStartOffset();
+        byte[] rightBytes = right.getByteArray();
+        int rightStartOffset = right.getStartOffset();
         switch (argType) {
-
             case STRING: {
-                return ed.UTF8StringEditDistance(bytes, firstStart + typeIndicatorSize,
-                        secondStart + typeIndicatorSize, (int) edThresh);
+                return ed.UTF8StringEditDistance(leftBytes, leftStartOffset + typeIndicatorSize, rightBytes,
+                        rightStartOffset + typeIndicatorSize, edThresh);
             }
 
             case ORDEREDLIST: {
-                firstOrdListIter.reset(bytes, firstStart);
-                secondOrdListIter.reset(bytes, secondStart);
+                firstOrdListIter.reset(leftBytes, leftStartOffset);
+                secondOrdListIter.reset(rightBytes, rightStartOffset);
                 return (int) ed.getSimilarity(firstOrdListIter, secondOrdListIter, edThresh);
             }
 
@@ -94,7 +98,6 @@ public class EditDistanceCheckEvaluator extends EditDistanceEvaluator {
 
     @Override
     protected void writeResult(int ed) throws IOException {
-
         listBuilder.reset(new AOrderedListType(BuiltinType.ANY, "list"));
         boolean matches = (ed < 0) ? false : true;
         listItemVal.reset();
@@ -105,7 +108,6 @@ public class EditDistanceCheckEvaluator extends EditDistanceEvaluator {
         aInt64.setValue((matches) ? ed : Integer.MAX_VALUE);
         int64Serde.serialize(aInt64, listItemVal.getDataOutput());
         listBuilder.addItem(listItemVal);
-
         listBuilder.write(out, true);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceContainsEvaluator.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceContainsEvaluator.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceContainsEvaluator.java
index 25ac28f..4ad06d8 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceContainsEvaluator.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceContainsEvaluator.java
@@ -21,42 +21,43 @@ package org.apache.asterix.runtime.evaluators.common;
 import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+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;
 
 public class EditDistanceContainsEvaluator extends EditDistanceCheckEvaluator {
 
-    public EditDistanceContainsEvaluator(ICopyEvaluatorFactory[] args, IDataOutputProvider output)
+    public EditDistanceContainsEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext context)
             throws AlgebricksException {
-        super(args, output);
+        super(args, context);
     }
 
     @Override
-    protected int computeResult(byte[] bytes, int firstStart, int secondStart, ATypeTag argType)
-            throws AlgebricksException {
-        switch (argType) {
+    protected int computeResult(IPointable left, IPointable right, ATypeTag argType) throws AlgebricksException {
+        byte[] leftBytes = left.getByteArray();
+        int leftStartOffset = left.getStartOffset();
+        byte[] rightBytes = right.getByteArray();
+        int rightStartOffset = right.getStartOffset();
 
+        switch (argType) {
             case STRING: {
-                return ed.UTF8StringEditDistanceContains(argOut.getByteArray(), firstStart + typeIndicatorSize,
-                        secondStart + typeIndicatorSize, (int) edThresh);
+                return ed.UTF8StringEditDistanceContains(leftBytes, leftStartOffset + typeIndicatorSize, rightBytes,
+                        rightStartOffset + typeIndicatorSize, edThresh);
             }
-
             case ORDEREDLIST: {
-                firstOrdListIter.reset(bytes, firstStart);
-                secondOrdListIter.reset(bytes, secondStart);
+                firstOrdListIter.reset(leftBytes, leftStartOffset);
+                secondOrdListIter.reset(rightBytes, rightStartOffset);
                 try {
-                    return ed.getSimilarityContains(firstOrdListIter, secondOrdListIter, (int) edThresh);
+                    return ed.getSimilarityContains(firstOrdListIter, secondOrdListIter, edThresh);
                 } catch (HyracksDataException e) {
                     throw new AlgebricksException(e);
                 }
             }
-
             default: {
                 throw new AlgebricksException(AsterixBuiltinFunctions.EDIT_DISTANCE_CONTAINS.getName()
                         + ": expects input type as STRING or ORDEREDLIST but got " + argType + ".");
             }
-
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceEvaluator.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceEvaluator.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceEvaluator.java
index 2f588c7..f6345d6 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceEvaluator.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceEvaluator.java
@@ -30,23 +30,27 @@ import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.om.types.EnumDeserializer;
 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.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;
 
-public class EditDistanceEvaluator implements ICopyEvaluator {
+public class EditDistanceEvaluator implements IScalarEvaluator {
 
     // assuming type indicator in serde format
     protected final int typeIndicatorSize = 1;
 
-    protected final DataOutput out;
-    protected final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
-    protected final ICopyEvaluator firstStringEval;
-    protected final ICopyEvaluator secondStringEval;
+    protected final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+    protected final DataOutput out = resultStorage.getDataOutput();
+    protected final IPointable argPtr1 = new VoidPointable();
+    protected final IPointable argPtr2 = new VoidPointable();
+    protected final IScalarEvaluator firstStringEval;
+    protected final IScalarEvaluator secondStringEval;
     protected final SimilarityMetricEditDistance ed = new SimilarityMetricEditDistance();
     protected final AsterixOrderedListIterator firstOrdListIter = new AsterixOrderedListIterator();
     protected final AsterixOrderedListIterator secondOrdListIter = new AsterixOrderedListIterator();
@@ -60,27 +64,26 @@ public class EditDistanceEvaluator implements ICopyEvaluator {
             .getSerializerDeserializer(BuiltinType.ANULL);
     protected ATypeTag itemTypeTag;
 
-    protected int firstStart = -1;
-    protected int secondStart = -1;
     protected ATypeTag firstTypeTag;
     protected ATypeTag secondTypeTag;
 
-    public EditDistanceEvaluator(ICopyEvaluatorFactory[] args, IDataOutputProvider output) throws AlgebricksException {
-        out = output.getDataOutput();
-        firstStringEval = args[0].createEvaluator(argOut);
-        secondStringEval = args[1].createEvaluator(argOut);
+    public EditDistanceEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext context)
+            throws AlgebricksException {
+        firstStringEval = args[0].createScalarEvaluator(context);
+        secondStringEval = args[1].createScalarEvaluator(context);
     }
 
     @Override
-    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-
+    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+        resultStorage.reset();
         runArgEvals(tuple);
-
-        if (!checkArgTypes(firstTypeTag, secondTypeTag))
+        if (!checkArgTypes(firstTypeTag, secondTypeTag)) {
+            result.set(resultStorage);
             return;
+        }
 
         try {
-            editDistance = computeResult(argOut.getByteArray(), firstStart, secondStart, firstTypeTag);
+            editDistance = computeResult(argPtr1, argPtr2, firstTypeTag);
         } catch (HyracksDataException e1) {
             throw new AlgebricksException(e1);
         }
@@ -90,32 +93,33 @@ public class EditDistanceEvaluator implements ICopyEvaluator {
         } catch (IOException e) {
             throw new AlgebricksException(e);
         }
+        result.set(resultStorage);
     }
 
     protected void runArgEvals(IFrameTupleReference tuple) throws AlgebricksException {
-        argOut.reset();
-
-        firstStart = argOut.getLength();
-        firstStringEval.evaluate(tuple);
-        secondStart = argOut.getLength();
-        secondStringEval.evaluate(tuple);
-
-        firstTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut.getByteArray()[firstStart]);
-        secondTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut.getByteArray()[secondStart]);
+        firstStringEval.evaluate(tuple, argPtr1);
+        firstTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+                .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset()]);
+        secondStringEval.evaluate(tuple, argPtr2);
+        secondTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+                .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset()]);
     }
 
-    protected int computeResult(byte[] bytes, int firstStart, int secondStart, ATypeTag argType)
+    protected int computeResult(IPointable left, IPointable right, ATypeTag argType)
             throws AlgebricksException, HyracksDataException {
-        switch (argType) {
+        byte[] leftBytes = left.getByteArray();
+        int leftStartOffset = left.getStartOffset();
+        byte[] rightBytes = right.getByteArray();
+        int rightStartOffset = right.getStartOffset();
 
+        switch (argType) {
             case STRING: {
-                return ed
-                        .UTF8StringEditDistance(bytes, firstStart + typeIndicatorSize, secondStart + typeIndicatorSize);
+                return ed.UTF8StringEditDistance(leftBytes, leftStartOffset + typeIndicatorSize, rightBytes,
+                        rightStartOffset + typeIndicatorSize);
             }
-
             case ORDEREDLIST: {
-                firstOrdListIter.reset(bytes, firstStart);
-                secondOrdListIter.reset(bytes, secondStart);
+                firstOrdListIter.reset(leftBytes, leftStartOffset);
+                secondOrdListIter.reset(rightBytes, rightStartOffset);
                 try {
                     return (int) ed.getSimilarity(firstOrdListIter, secondOrdListIter);
                 } catch (HyracksDataException e) {
@@ -124,8 +128,8 @@ public class EditDistanceEvaluator implements ICopyEvaluator {
             }
 
             default: {
-                throw new AlgebricksException("Invalid type " + argType
-                        + " passed as argument to edit distance function.");
+                throw new AlgebricksException(
+                        "Invalid type " + argType + " passed as argument to edit distance function.");
             }
 
         }
@@ -143,8 +147,8 @@ public class EditDistanceEvaluator implements ICopyEvaluator {
         }
 
         if (typeTag1 != typeTag2) {
-            throw new AlgebricksException("Incompatible argument types given in edit distance: " + typeTag1 + " "
-                    + typeTag2);
+            throw new AlgebricksException(
+                    "Incompatible argument types given in edit distance: " + typeTag1 + " " + typeTag2);
         }
 
         // Since they are equal, check one tag is enough.
@@ -154,15 +158,17 @@ public class EditDistanceEvaluator implements ICopyEvaluator {
         }
 
         if (typeTag1 == ATypeTag.ORDEREDLIST) {
-            itemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut.getByteArray()[firstStart + 1]);
-            if (itemTypeTag == ATypeTag.ANY)
+            itemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+                    .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset() + 1]);
+            if (itemTypeTag == ATypeTag.ANY) {
                 throw new AlgebricksException("\n Edit Distance can only be called on homogenous lists");
-
-            itemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut.getByteArray()[secondStart + 1]);
-            if (itemTypeTag == ATypeTag.ANY)
+            }
+            itemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+                    .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset() + 1]);
+            if (itemTypeTag == ATypeTag.ANY) {
                 throw new AlgebricksException("\n Edit Distance can only be called on homogenous lists");
+            }
         }
-
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/GramTokensEvaluator.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/GramTokensEvaluator.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/GramTokensEvaluator.java
index 03f8cb1..ed20b26 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/GramTokensEvaluator.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/GramTokensEvaluator.java
@@ -26,63 +26,64 @@ import org.apache.asterix.om.types.AOrderedListType;
 import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
 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.BooleanPointable;
+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.storage.am.lsm.invertedindex.tokenizers.IBinaryTokenizer;
 import org.apache.hyracks.storage.am.lsm.invertedindex.tokenizers.NGramUTF8StringBinaryTokenizer;
 
-public class GramTokensEvaluator implements ICopyEvaluator {
+public class GramTokensEvaluator implements IScalarEvaluator {
 
     // assuming type indicator in serde format
     private final int typeIndicatorSize = 1;
 
-    private final DataOutput out;
-    private final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
-    private final ICopyEvaluator stringEval;
-    private final ICopyEvaluator gramLengthEval;
-    private final ICopyEvaluator prePostEval;
+    private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+    private final DataOutput out = resultStorage.getDataOutput();
+    private final IPointable stringArg = new VoidPointable();
+    private final IPointable gramLengthArg = new VoidPointable();
+    private final IPointable prePostArg = new VoidPointable();
+    private final IScalarEvaluator stringEval;
+    private final IScalarEvaluator gramLengthEval;
+    private final IScalarEvaluator prePostEval;
 
     private final NGramUTF8StringBinaryTokenizer tokenizer;
     private final OrderedListBuilder listBuilder = new OrderedListBuilder();
     private final AOrderedListType listType;
 
-    public GramTokensEvaluator(ICopyEvaluatorFactory[] args, IDataOutputProvider output, IBinaryTokenizer tokenizer,
+    public GramTokensEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext context, IBinaryTokenizer tokenizer,
             BuiltinType itemType) throws AlgebricksException {
-        out = output.getDataOutput();
-        stringEval = args[0].createEvaluator(argOut);
-        gramLengthEval = args[1].createEvaluator(argOut);
-        prePostEval = args[2].createEvaluator(argOut);
+        stringEval = args[0].createScalarEvaluator(context);
+        gramLengthEval = args[1].createScalarEvaluator(context);
+        prePostEval = args[2].createScalarEvaluator(context);
         this.tokenizer = (NGramUTF8StringBinaryTokenizer) tokenizer;
         this.listType = new AOrderedListType(itemType, null);
     }
 
     @Override
-    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
-        argOut.reset();
-        stringEval.evaluate(tuple);
-        int gramLengthOff = argOut.getLength();
-        gramLengthEval.evaluate(tuple);
-        int prePostOff = argOut.getLength();
-        prePostEval.evaluate(tuple);
+    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+        resultStorage.reset();
+        stringEval.evaluate(tuple, stringArg);
+        gramLengthEval.evaluate(tuple, gramLengthArg);
+        prePostEval.evaluate(tuple, prePostArg);
 
-        byte[] bytes = argOut.getByteArray();
         int gramLength = 0;
-
         try {
-            gramLength = ATypeHierarchy.getIntegerValue(bytes, gramLengthOff);
+            gramLength = ATypeHierarchy.getIntegerValue(gramLengthArg.getByteArray(), gramLengthArg.getStartOffset());
         } catch (HyracksDataException e1) {
             throw new AlgebricksException(e1);
         }
 
         tokenizer.setGramlength(gramLength);
-        boolean prePost = BooleanPointable.getBoolean(bytes, prePostOff + typeIndicatorSize);
+        boolean prePost = BooleanPointable.getBoolean(prePostArg.getByteArray(),
+                prePostArg.getStartOffset() + typeIndicatorSize);
         tokenizer.setPrePost(prePost);
-        tokenizer.reset(bytes, 0, gramLengthOff);
+        tokenizer.reset(stringArg.getByteArray(), stringArg.getStartOffset(), stringArg.getLength());
 
         try {
             listBuilder.reset(listType);
@@ -94,5 +95,6 @@ public class GramTokensEvaluator implements ICopyEvaluator {
         } 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/common/SimilarityFiltersCache.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityFiltersCache.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityFiltersCache.java
index 7180df0..52988a0 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityFiltersCache.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityFiltersCache.java
@@ -39,19 +39,20 @@ public class SimilarityFiltersCache {
     private byte[] similarityNameBytesCached = null;
     private SimilarityFilters similarityFiltersCached = null;
 
-    public SimilarityFilters get(float similarityThreshold, byte[] similarityNameBytes) throws AlgebricksException {
+    public SimilarityFilters get(float similarityThreshold, byte[] similarityNameBytes, int startOffset, int len)
+            throws AlgebricksException {
         if (similarityThreshold != similarityThresholdCached || similarityNameBytesCached == null
                 || !Arrays.equals(similarityNameBytes, similarityNameBytesCached)) {
-            bbis.setByteBuffer(ByteBuffer.wrap(similarityNameBytes), 1);
+            bbis.setByteBuffer(ByteBuffer.wrap(similarityNameBytes), startOffset + 1);
             String similarityName;
             try {
                 similarityName = utf8SerDer.deserialize(dis);
             } catch (HyracksDataException e) {
                 throw new AlgebricksException(e);
             }
-            similarityNameBytesCached = Arrays.copyOf(similarityNameBytes, similarityNameBytes.length);
-            similarityFiltersCached = SimilarityFiltersFactory
-                    .getSimilarityFilters(similarityName, similarityThreshold);
+            similarityNameBytesCached = Arrays.copyOfRange(similarityNameBytes, startOffset, len);
+            similarityFiltersCached = SimilarityFiltersFactory.getSimilarityFilters(similarityName,
+                    similarityThreshold);
         }
         return similarityFiltersCached;
     }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardCheckEvaluator.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardCheckEvaluator.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardCheckEvaluator.java
index 94ff35f..b2eca6d 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardCheckEvaluator.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardCheckEvaluator.java
@@ -28,19 +28,22 @@ import org.apache.asterix.om.types.AOrderedListType;
 import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.runtime.evaluators.functions.BinaryHashMap.BinaryEntry;
 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.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.IntegerPointable;
+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 SimilarityJaccardCheckEvaluator extends SimilarityJaccardEvaluator {
 
-    protected final ICopyEvaluator jaccThreshEval;
+    protected final IScalarEvaluator jaccThreshEval;
     protected float jaccThresh = -1f;
+    protected IPointable jaccThreshPointable = new VoidPointable();
 
     protected OrderedListBuilder listBuilder;
     protected ArrayBackedValueStorage inputVal;
@@ -49,10 +52,10 @@ public class SimilarityJaccardCheckEvaluator extends SimilarityJaccardEvaluator
             .getSerializerDeserializer(BuiltinType.ABOOLEAN);
     protected final AOrderedListType listType = new AOrderedListType(BuiltinType.ANY, "list");
 
-    public SimilarityJaccardCheckEvaluator(ICopyEvaluatorFactory[] args, IDataOutputProvider output)
+    public SimilarityJaccardCheckEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext context)
             throws AlgebricksException {
-        super(args, output);
-        jaccThreshEval = args[2].createEvaluator(argOut);
+        super(args, context);
+        jaccThreshEval = args[2].createScalarEvaluator(context);
         listBuilder = new OrderedListBuilder();
         inputVal = new ArrayBackedValueStorage();
     }
@@ -60,10 +63,9 @@ public class SimilarityJaccardCheckEvaluator extends SimilarityJaccardEvaluator
     @Override
     protected void runArgEvals(IFrameTupleReference tuple) throws AlgebricksException {
         super.runArgEvals(tuple);
-        int jaccThreshStart = argOut.getLength();
-        jaccThreshEval.evaluate(tuple);
-        jaccThresh = (float) AFloatSerializerDeserializer.getFloat(argOut.getByteArray(), jaccThreshStart
-                + TYPE_INDICATOR_SIZE);
+        jaccThreshEval.evaluate(tuple, jaccThreshPointable);
+        jaccThresh = (float) AFloatSerializerDeserializer.getFloat(jaccThreshPointable.getByteArray(),
+                jaccThreshPointable.getStartOffset() + TYPE_INDICATOR_SIZE);
     }
 
     @Override
@@ -71,7 +73,8 @@ public class SimilarityJaccardCheckEvaluator extends SimilarityJaccardEvaluator
             throws HyracksDataException {
         // Apply length filter.
         int lengthLowerBound = (int) Math.ceil(jaccThresh * probeListSize);
-        if ((lengthLowerBound > buildListSize) || (buildListSize > (int) Math.floor(1.0f / jaccThresh * probeListSize))) {
+        if ((lengthLowerBound > buildListSize)
+                || (buildListSize > (int) Math.floor(1.0f / jaccThresh * probeListSize))) {
             return -1;
         }
         // Probe phase: Probe items from second list, and compute intersection size.

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
index 4481819..9aa0cdb 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
@@ -33,18 +33,20 @@ import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.functions.BinaryHashMap;
 import org.apache.asterix.runtime.evaluators.functions.BinaryHashMap.BinaryEntry;
 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.dataflow.value.IBinaryComparator;
 import org.apache.hyracks.api.dataflow.value.IBinaryHashFunction;
 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.IntegerPointable;
+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 SimilarityJaccardEvaluator implements ICopyEvaluator {
+public class SimilarityJaccardEvaluator implements IScalarEvaluator {
 
     // Parameters for hash table.
     protected final int TABLE_SIZE = 100;
@@ -53,10 +55,12 @@ public class SimilarityJaccardEvaluator implements ICopyEvaluator {
     // Assuming type indicator in serde format.
     protected final int TYPE_INDICATOR_SIZE = 1;
 
-    protected final DataOutput out;
-    protected final ArrayBackedValueStorage argOut = new ArrayBackedValueStorage();
-    protected final ICopyEvaluator firstOrdListEval;
-    protected final ICopyEvaluator secondOrdListEval;
+    protected final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+    protected final DataOutput out = resultStorage.getDataOutput();
+    protected final IPointable argPtr1 = new VoidPointable();
+    protected final IPointable argPtr2 = new VoidPointable();
+    protected final IScalarEvaluator firstOrdListEval;
+    protected final IScalarEvaluator secondOrdListEval;
 
     protected final AsterixOrderedListIterator fstOrdListIter = new AsterixOrderedListIterator();
     protected final AsterixOrderedListIterator sndOrdListIter = new AsterixOrderedListIterator();
@@ -73,8 +77,6 @@ public class SimilarityJaccardEvaluator implements ICopyEvaluator {
 
     protected ATypeTag firstTypeTag;
     protected ATypeTag secondTypeTag;
-    protected int firstStart = -1;
-    protected int secondStart = -1;
     protected float jaccSim = 0.0f;
     protected ATypeTag firstItemTypeTag;
     protected ATypeTag secondItemTypeTag;
@@ -86,24 +88,25 @@ public class SimilarityJaccardEvaluator implements ICopyEvaluator {
     // Ignore case for strings. Defaults to true.
     protected final boolean ignoreCase = true;
 
-    public SimilarityJaccardEvaluator(ICopyEvaluatorFactory[] args, IDataOutputProvider output)
+    public SimilarityJaccardEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext context)
             throws AlgebricksException {
-        out = output.getDataOutput();
-        firstOrdListEval = args[0].createEvaluator(argOut);
-        secondOrdListEval = args[1].createEvaluator(argOut);
+        firstOrdListEval = args[0].createScalarEvaluator(context);
+        secondOrdListEval = args[1].createScalarEvaluator(context);
         byte[] emptyValBuf = new byte[8];
         Arrays.fill(emptyValBuf, (byte) 0);
         valEntry.set(emptyValBuf, 0, 8);
     }
 
     @Override
-    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+        resultStorage.reset();
         runArgEvals(tuple);
         if (!checkArgTypes(firstTypeTag, secondTypeTag)) {
+            result.set(resultStorage);
             return;
         }
-        if (prepareLists(argOut.getByteArray(), firstStart, secondStart, firstTypeTag)) {
-            jaccSim = computeResult(argOut.getByteArray(), firstStart, secondStart, firstTypeTag);
+        if (prepareLists(argPtr1, argPtr2, firstTypeTag)) {
+            jaccSim = computeResult();
         } else {
             jaccSim = 0.0f;
         }
@@ -112,32 +115,34 @@ public class SimilarityJaccardEvaluator implements ICopyEvaluator {
         } catch (IOException e) {
             throw new AlgebricksException(e);
         }
+        result.set(resultStorage);
     }
 
     protected void runArgEvals(IFrameTupleReference tuple) throws AlgebricksException {
-        argOut.reset();
+        firstOrdListEval.evaluate(tuple, argPtr1);
+        secondOrdListEval.evaluate(tuple, argPtr2);
 
-        firstStart = argOut.getLength();
-        firstOrdListEval.evaluate(tuple);
-        secondStart = argOut.getLength();
-        secondOrdListEval.evaluate(tuple);
+        firstTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+                .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset()]);
+        secondTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+                .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset()]);
 
-        firstTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut.getByteArray()[firstStart]);
-        secondTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut.getByteArray()[secondStart]);
-
-        if (firstTypeTag == ATypeTag.NULL)
+        if (firstTypeTag == ATypeTag.NULL) {
             return;
-        if (secondTypeTag == ATypeTag.NULL)
+        }
+        if (secondTypeTag == ATypeTag.NULL) {
             return;
+        }
 
-        firstItemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut.getByteArray()[firstStart + 1]);
-        secondItemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut.getByteArray()[secondStart + 1]);
+        firstItemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+                .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset() + 1]);
+        secondItemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+                .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset() + 1]);
     }
 
-    protected boolean prepareLists(byte[] bytes, int firstStart, int secondStart, ATypeTag argType)
-            throws AlgebricksException {
-        firstListIter.reset(bytes, firstStart);
-        secondListIter.reset(bytes, secondStart);
+    protected boolean prepareLists(IPointable left, IPointable right, ATypeTag argType) throws AlgebricksException {
+        firstListIter.reset(left.getByteArray(), left.getStartOffset());
+        secondListIter.reset(right.getByteArray(), right.getStartOffset());
         // Check for special case where one of the lists is empty, since list
         // types won't match.
         if (firstListIter.size() == 0 || secondListIter.size() == 0) {
@@ -147,8 +152,7 @@ public class SimilarityJaccardEvaluator implements ICopyEvaluator {
         return true;
     }
 
-    protected float computeResult(byte[] bytes, int firstStart, int secondStart, ATypeTag argType)
-            throws AlgebricksException {
+    protected float computeResult() throws AlgebricksException {
         // We will subtract the intersection size later to get the real union size.
         int firstListSize = firstListIter.size();
         int secondListSize = secondListIter.size();
@@ -161,7 +165,7 @@ public class SimilarityJaccardEvaluator implements ICopyEvaluator {
         ATypeTag buildItemTypeTag = (buildList == firstListIter) ? firstItemTypeTag : secondItemTypeTag;
         ATypeTag probeItemTypeTag = (probeList == firstListIter) ? firstItemTypeTag : secondItemTypeTag;
 
-        setHashMap(bytes, buildItemTypeTag, probeItemTypeTag);
+        setHashMap(buildItemTypeTag, probeItemTypeTag);
         try {
             buildHashMap(buildList);
             int intersectionSize = probeHashMap(probeList, buildListSize, probeListSize);
@@ -225,16 +229,16 @@ public class SimilarityJaccardEvaluator implements ICopyEvaluator {
         return intersectionSize;
     }
 
-    protected void setHashMap(byte[] bytes, ATypeTag buildItemTypeTag, ATypeTag probeItemTypeTag) {
+    protected void setHashMap(ATypeTag buildItemTypeTag, ATypeTag probeItemTypeTag) {
         if (hashMap != null) {
             hashMap.clear();
             return;
         }
 
-        IBinaryHashFunction putHashFunc = ListItemBinaryHashFunctionFactory.INSTANCE.createBinaryHashFunction(
-                buildItemTypeTag, ignoreCase);
-        IBinaryHashFunction getHashFunc = ListItemBinaryHashFunctionFactory.INSTANCE.createBinaryHashFunction(
-                probeItemTypeTag, ignoreCase);
+        IBinaryHashFunction putHashFunc = ListItemBinaryHashFunctionFactory.INSTANCE
+                .createBinaryHashFunction(buildItemTypeTag, ignoreCase);
+        IBinaryHashFunction getHashFunc = ListItemBinaryHashFunctionFactory.INSTANCE
+                .createBinaryHashFunction(probeItemTypeTag, ignoreCase);
         IBinaryComparator cmp = ListItemBinaryComparatorFactory.INSTANCE.createBinaryComparator(buildItemTypeTag,
                 probeItemTypeTag, ignoreCase);
         hashMap = new BinaryHashMap(TABLE_SIZE, TABLE_FRAME_SIZE, putHashFunc, getHashFunc, cmp);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardPrefixEvaluator.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardPrefixEvaluator.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardPrefixEvaluator.java
index c287ba9..946c806 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardPrefixEvaluator.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardPrefixEvaluator.java
@@ -37,33 +37,32 @@ import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
 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.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;
 
-public class SimilarityJaccardPrefixEvaluator implements ICopyEvaluator {
+public class SimilarityJaccardPrefixEvaluator implements IScalarEvaluator {
     // assuming type indicator in serde format
     protected final int typeIndicatorSize = 1;
 
-    protected final DataOutput out;
-    protected final ArrayBackedValueStorage inputVal = new ArrayBackedValueStorage();
-    protected final ICopyEvaluator evalLen1;
-    protected final ICopyEvaluator evalTokens1;
-    protected final ICopyEvaluator evalLen2;
-    protected final ICopyEvaluator evalTokens2;
-    protected final ICopyEvaluator evalTokenPrefix;
-    protected final ICopyEvaluator evalThreshold;
+    protected final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+    protected final DataOutput out = resultStorage.getDataOutput();
+    protected final IPointable inputVal = new VoidPointable();
+    protected final IScalarEvaluator evalLen1;
+    protected final IScalarEvaluator evalTokens1;
+    protected final IScalarEvaluator evalLen2;
+    protected final IScalarEvaluator evalTokens2;
+    protected final IScalarEvaluator evalTokenPrefix;
+    protected final IScalarEvaluator evalThreshold;
 
     protected float similarityThresholdCache;
     protected SimilarityFiltersJaccard similarityFilters;
-
-    private final static byte SER_ORDEREDLIST_TYPE_TAG = ATypeTag.ORDEREDLIST.serialize();
-    private final static byte SER_UNORDEREDLIST_TYPE_TAG = ATypeTag.UNORDEREDLIST.serialize();
-
     protected final IntArray tokens1 = new IntArray();
     protected final IntArray tokens2 = new IntArray();
     protected final PartialIntersect parInter = new PartialIntersect();
@@ -76,46 +75,43 @@ public class SimilarityJaccardPrefixEvaluator implements ICopyEvaluator {
     protected final ISerializerDeserializer<AFloat> reusSerde = AqlSerializerDeserializerProvider.INSTANCE
             .getSerializerDeserializer(BuiltinType.AFLOAT);
 
-    public SimilarityJaccardPrefixEvaluator(ICopyEvaluatorFactory[] args, IDataOutputProvider output)
+    public SimilarityJaccardPrefixEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext context)
             throws AlgebricksException {
-        out = output.getDataOutput();
-        evalLen1 = args[0].createEvaluator(inputVal);
-        evalTokens1 = args[1].createEvaluator(inputVal);
-        evalLen2 = args[2].createEvaluator(inputVal);
-        evalTokens2 = args[3].createEvaluator(inputVal);
-        evalTokenPrefix = args[4].createEvaluator(inputVal);
-        evalThreshold = args[5].createEvaluator(inputVal);
+        evalLen1 = args[0].createScalarEvaluator(context);
+        evalTokens1 = args[1].createScalarEvaluator(context);
+        evalLen2 = args[2].createScalarEvaluator(context);
+        evalTokens2 = args[3].createScalarEvaluator(context);
+        evalTokenPrefix = args[4].createScalarEvaluator(context);
+        evalThreshold = args[5].createScalarEvaluator(context);
     }
 
     @Override
-    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+        resultStorage.reset();
         // similarity threshold
         sim = 0;
-        inputVal.reset();
-        evalThreshold.evaluate(tuple);
-        float similarityThreshold = AFloatSerializerDeserializer.getFloat(inputVal.getByteArray(), 1);
+        evalThreshold.evaluate(tuple, inputVal);
+        float similarityThreshold = AFloatSerializerDeserializer.getFloat(inputVal.getByteArray(),
+                inputVal.getStartOffset() + 1);
 
         if (similarityThreshold != similarityThresholdCache || similarityFilters == null) {
             similarityFilters = new SimilarityFiltersJaccard(similarityThreshold);
             similarityThresholdCache = similarityThreshold;
         }
 
-        inputVal.reset();
-        evalLen1.evaluate(tuple);
+        evalLen1.evaluate(tuple, inputVal);
         int length1 = 0;
-
         try {
-            length1 = ATypeHierarchy.getIntegerValue(inputVal.getByteArray(), 0);
+            length1 = ATypeHierarchy.getIntegerValue(inputVal.getByteArray(), inputVal.getStartOffset());
         } catch (HyracksDataException e1) {
             throw new AlgebricksException(e1);
         }
 
-        inputVal.reset();
-        evalLen2.evaluate(tuple);
+        evalLen2.evaluate(tuple, inputVal);
         int length2 = 0;
 
         try {
-            length2 = ATypeHierarchy.getIntegerValue(inputVal.getByteArray(), 0);
+            length2 = ATypeHierarchy.getIntegerValue(inputVal.getByteArray(), inputVal.getStartOffset());
         } catch (HyracksDataException e1) {
             throw new AlgebricksException(e1);
         }
@@ -128,50 +124,55 @@ public class SimilarityJaccardPrefixEvaluator implements ICopyEvaluator {
             // -- - tokens1 - --
             int i;
             tokens1.reset();
-            inputVal.reset();
-            evalTokens1.evaluate(tuple);
+            evalTokens1.evaluate(tuple, inputVal);
 
             byte[] serList = inputVal.getByteArray();
-            if (serList[0] != SER_ORDEREDLIST_TYPE_TAG && serList[0] != SER_UNORDEREDLIST_TYPE_TAG) {
+            int startOffset = inputVal.getStartOffset();
+            if (serList[startOffset] != ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG
+                    && serList[startOffset] != ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG) {
                 throw new AlgebricksException("Scan collection is not defined for values of type"
-                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serList[0]));
+                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serList[startOffset]));
             }
 
             int lengthTokens1;
-            if (serList[0] == SER_ORDEREDLIST_TYPE_TAG) {
-                lengthTokens1 = AOrderedListSerializerDeserializer.getNumberOfItems(inputVal.getByteArray());
+            if (serList[startOffset] == ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG) {
+                lengthTokens1 = AOrderedListSerializerDeserializer.getNumberOfItems(inputVal.getByteArray(),
+                        startOffset);
                 // read tokens
                 for (i = 0; i < lengthTokens1; i++) {
                     int itemOffset;
                     int token;
                     try {
-                        itemOffset = AOrderedListSerializerDeserializer.getItemOffset(serList, i);
+                        itemOffset = AOrderedListSerializerDeserializer.getItemOffset(serList, startOffset, i);
                     } catch (AsterixException e) {
                         throw new AlgebricksException(e);
                     }
 
                     try {
-                        token = ATypeHierarchy.getIntegerValueWithDifferentTypeTagPosition(serList, itemOffset, 1);
+                        token = ATypeHierarchy.getIntegerValueWithDifferentTypeTagPosition(serList, itemOffset,
+                                startOffset + 1);
                     } catch (HyracksDataException e) {
                         throw new AlgebricksException(e);
                     }
                     tokens1.add(token);
                 }
             } else {
-                lengthTokens1 = AUnorderedListSerializerDeserializer.getNumberOfItems(inputVal.getByteArray());
+                lengthTokens1 = AUnorderedListSerializerDeserializer.getNumberOfItems(inputVal.getByteArray(),
+                        startOffset);
                 // read tokens
                 for (i = 0; i < lengthTokens1; i++) {
                     int itemOffset;
                     int token;
 
                     try {
-                        itemOffset = AUnorderedListSerializerDeserializer.getItemOffset(serList, i);
+                        itemOffset = AUnorderedListSerializerDeserializer.getItemOffset(serList, startOffset, i);
                     } catch (AsterixException e) {
                         throw new AlgebricksException(e);
                     }
 
                     try {
-                        token = ATypeHierarchy.getIntegerValueWithDifferentTypeTagPosition(serList, itemOffset, 1);
+                        token = ATypeHierarchy.getIntegerValueWithDifferentTypeTagPosition(serList, itemOffset,
+                                startOffset + 1);
                     } catch (HyracksDataException e) {
                         throw new AlgebricksException(e);
                     }
@@ -185,51 +186,56 @@ public class SimilarityJaccardPrefixEvaluator implements ICopyEvaluator {
 
             // -- - tokens2 - --
             tokens2.reset();
-            inputVal.reset();
-            evalTokens2.evaluate(tuple);
+            evalTokens2.evaluate(tuple, inputVal);
 
             serList = inputVal.getByteArray();
-            if (serList[0] != SER_ORDEREDLIST_TYPE_TAG && serList[0] != SER_UNORDEREDLIST_TYPE_TAG) {
+            startOffset = inputVal.getStartOffset();
+            if (serList[startOffset] != ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG
+                    && serList[startOffset] != ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG) {
                 throw new AlgebricksException("Scan collection is not defined for values of type"
-                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serList[0]));
+                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serList[startOffset]));
             }
 
             int lengthTokens2;
-            if (serList[0] == SER_ORDEREDLIST_TYPE_TAG) {
-                lengthTokens2 = AOrderedListSerializerDeserializer.getNumberOfItems(inputVal.getByteArray());
+            if (serList[startOffset] == ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG) {
+                lengthTokens2 = AOrderedListSerializerDeserializer.getNumberOfItems(inputVal.getByteArray(),
+                        startOffset);
                 // read tokens
                 for (i = 0; i < lengthTokens2; i++) {
                     int itemOffset;
                     int token;
 
                     try {
-                        itemOffset = AOrderedListSerializerDeserializer.getItemOffset(serList, i);
+                        itemOffset = AOrderedListSerializerDeserializer.getItemOffset(serList, startOffset, i);
                     } catch (AsterixException e) {
                         throw new AlgebricksException(e);
                     }
 
                     try {
-                        token = ATypeHierarchy.getIntegerValueWithDifferentTypeTagPosition(serList, itemOffset, 1);
+                        token = ATypeHierarchy.getIntegerValueWithDifferentTypeTagPosition(serList, itemOffset,
+                                startOffset + 1);
                     } catch (HyracksDataException e) {
                         throw new AlgebricksException(e);
                     }
                     tokens2.add(token);
                 }
             } else {
-                lengthTokens2 = AUnorderedListSerializerDeserializer.getNumberOfItems(inputVal.getByteArray());
+                lengthTokens2 = AUnorderedListSerializerDeserializer.getNumberOfItems(inputVal.getByteArray(),
+                        startOffset);
                 // read tokens
                 for (i = 0; i < lengthTokens2; i++) {
                     int itemOffset;
                     int token;
 
                     try {
-                        itemOffset = AUnorderedListSerializerDeserializer.getItemOffset(serList, i);
+                        itemOffset = AUnorderedListSerializerDeserializer.getItemOffset(serList, startOffset, i);
                     } catch (AsterixException e) {
                         throw new AlgebricksException(e);
                     }
 
                     try {
-                        token = ATypeHierarchy.getIntegerValueWithDifferentTypeTagPosition(serList, itemOffset, 1);
+                        token = ATypeHierarchy.getIntegerValueWithDifferentTypeTagPosition(serList, itemOffset,
+                                startOffset + 1);
                     } catch (HyracksDataException e) {
                         throw new AlgebricksException(e);
                     }
@@ -242,13 +248,11 @@ public class SimilarityJaccardPrefixEvaluator implements ICopyEvaluator {
             }
 
             // -- - token prefix - --
-            inputVal.reset();
-            evalTokenPrefix.evaluate(tuple);
-
+            evalTokenPrefix.evaluate(tuple, inputVal);
             int tokenPrefix = 0;
 
             try {
-                tokenPrefix = ATypeHierarchy.getIntegerValue(inputVal.getByteArray(), 0);
+                tokenPrefix = ATypeHierarchy.getIntegerValue(inputVal.getByteArray(), inputVal.getStartOffset());
             } catch (HyracksDataException e) {
                 throw new AlgebricksException(e);
             }
@@ -279,6 +283,7 @@ public class SimilarityJaccardPrefixEvaluator implements ICopyEvaluator {
         } catch (IOException e) {
             throw new AlgebricksException(e);
         }
+        result.set(resultStorage);
     }
 
     public void writeResult() throws AlgebricksException, IOException {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardSortedCheckEvaluator.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardSortedCheckEvaluator.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardSortedCheckEvaluator.java
index 6c59801..d0b0f7d 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardSortedCheckEvaluator.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardSortedCheckEvaluator.java
@@ -19,24 +19,22 @@
 package org.apache.asterix.runtime.evaluators.common;
 
 import org.apache.asterix.fuzzyjoin.similarity.SimilarityMetricJaccard;
-import org.apache.asterix.om.types.ATypeTag;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+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;
 
 public class SimilarityJaccardSortedCheckEvaluator extends SimilarityJaccardCheckEvaluator {
 
     protected final SimilarityMetricJaccard jaccard = new SimilarityMetricJaccard();
 
-    public SimilarityJaccardSortedCheckEvaluator(ICopyEvaluatorFactory[] args, IDataOutputProvider output)
+    public SimilarityJaccardSortedCheckEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext context)
             throws AlgebricksException {
-        super(args, output);
+        super(args, context);
     }
 
     @Override
-    protected float computeResult(byte[] bytes, int firstStart, int secondStart, ATypeTag argType)
-            throws AlgebricksException {
+    protected float computeResult() throws AlgebricksException {
         try {
             return jaccard.getSimilarity(firstListIter, secondListIter, jaccThresh);
         } catch (HyracksDataException e) {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/0ae30836/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardSortedEvaluator.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardSortedEvaluator.java b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardSortedEvaluator.java
index d99565d..05965d6 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardSortedEvaluator.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardSortedEvaluator.java
@@ -19,24 +19,23 @@
 package org.apache.asterix.runtime.evaluators.common;
 
 import org.apache.asterix.fuzzyjoin.similarity.SimilarityMetricJaccard;
-import org.apache.asterix.om.types.ATypeTag;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+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;
 
 // Assumes that both arguments are sorted by the same ordering.
 public class SimilarityJaccardSortedEvaluator extends SimilarityJaccardEvaluator {
 
     protected final SimilarityMetricJaccard jaccard = new SimilarityMetricJaccard();
 
-    public SimilarityJaccardSortedEvaluator(ICopyEvaluatorFactory[] args, IDataOutputProvider output)
+    public SimilarityJaccardSortedEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext context)
             throws AlgebricksException {
-        super(args, output);
+        super(args, context);
     }
 
-    protected float computeResult(byte[] bytes, int firstStart, int secondStart, ATypeTag argType)
-            throws AlgebricksException {
+    @Override
+    protected float computeResult() throws AlgebricksException {
         try {
             return jaccard.getSimilarity(firstListIter, secondListIter);
         } catch (HyracksDataException e) {


Mime
View raw message