diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ILogicalBinaryComparator.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ILogicalBinaryComparator.java
index 8b4348c..eb99918 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ILogicalBinaryComparator.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/ILogicalBinaryComparator.java
@@ -20,6 +20,7 @@
 
 import org.apache.asterix.om.base.IAObject;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.data.std.api.IPointable;
 
 public interface ILogicalBinaryComparator {
 
@@ -36,12 +37,11 @@
         return result < 0 ? Result.LT : (result == 0 ? Result.EQ : Result.GT);
     }
 
-    Result compare(byte[] leftBytes, int leftStart, int leftLen, byte[] rightBytes, int rightStart, int rightLen)
-            throws HyracksDataException;
+    Result compare(IPointable left, IPointable right) throws HyracksDataException;
 
-    Result compare(byte[] leftBytes, int leftStart, int leftLen, IAObject rightConstant);
+    Result compare(IPointable left, IAObject rightConstant);
 
-    Result compare(IAObject leftConstant, byte[] rightBytes, int rightStart, int rightLen);
+    Result compare(IAObject leftConstant, IPointable right);
 
     Result compare(IAObject leftConstant, IAObject rightConstant);
 }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalComparatorUtil.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalComparatorUtil.java
index 7b8b11d..d074010 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalComparatorUtil.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalComparatorUtil.java
@@ -28,6 +28,7 @@
 import static org.apache.asterix.om.types.ATypeTag.TINYINT;
 
 import org.apache.asterix.dataflow.data.common.ILogicalBinaryComparator;
+import org.apache.asterix.dataflow.data.common.ILogicalBinaryComparator.Result;
 import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
 import org.apache.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
 import org.apache.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
@@ -45,6 +46,7 @@
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.IAType;
 import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
+import org.apache.hyracks.data.std.api.IPointable;
 
 public class LogicalComparatorUtil {
 
@@ -65,31 +67,30 @@
         }
     }
 
-    static ILogicalBinaryComparator.Result returnMissingOrNullOrMismatch(ATypeTag leftTag, ATypeTag rightTag) {
+    static Result returnMissingOrNullOrMismatch(ATypeTag leftTag, ATypeTag rightTag) {
         if (leftTag == MISSING || rightTag == MISSING) {
-            return ILogicalBinaryComparator.Result.MISSING;
+            return Result.MISSING;
         }
         if (leftTag == NULL || rightTag == NULL) {
-            return ILogicalBinaryComparator.Result.NULL;
+            return Result.NULL;
         }
         if (!ATypeHierarchy.isCompatible(leftTag, rightTag)) {
-            return ILogicalBinaryComparator.Result.INCOMPARABLE;
+            return Result.INCOMPARABLE;
         }
         return null;
     }
 
     // checking that left and right are compatible has to be done before calling this
-    static ILogicalBinaryComparator.Result compareNumbers(ATypeTag leftTag, byte[] b1, int s1, ATypeTag rightTag,
-            byte[] b2, int s2) {
+    static Result compareNumbers(ATypeTag leftTag, IPointable left, ATypeTag rightTag, IPointable right) {
         int result;
         if (leftTag == DOUBLE || rightTag == DOUBLE) {
-            result = Double.compare(getDoubleValue(leftTag, b1, s1), getDoubleValue(rightTag, b2, s2));
+            result = Double.compare(getDoubleValue(leftTag, left), getDoubleValue(rightTag, right));
         } else if (leftTag == FLOAT || rightTag == FLOAT) {
-            result = Float.compare((float) getDoubleValue(leftTag, b1, s1), (float) getDoubleValue(rightTag, b2, s2));
+            result = Float.compare((float) getDoubleValue(leftTag, left), (float) getDoubleValue(rightTag, right));
         } else if (leftTag == BIGINT || rightTag == BIGINT) {
-            result = Long.compare(getLongValue(leftTag, b1, s1), getLongValue(rightTag, b2, s2));
+            result = Long.compare(getLongValue(leftTag, left), getLongValue(rightTag, right));
         } else if (leftTag == INTEGER || leftTag == SMALLINT || leftTag == TINYINT) {
-            result = Integer.compare((int) getLongValue(leftTag, b1, s1), (int) getLongValue(rightTag, b2, s2));
+            result = Integer.compare((int) getLongValue(leftTag, left), (int) getLongValue(rightTag, right));
         } else {
             return null;
         }
@@ -97,18 +98,17 @@
     }
 
     // checking that left and right are compatible has to be done before calling this
-    static ILogicalBinaryComparator.Result compareNumWithConstant(ATypeTag leftTag, byte[] b1, int s1,
-            IAObject rightConstant) {
+    static Result compareNumWithConstant(ATypeTag leftTag, IPointable left, IAObject rightConstant) {
         int result;
         ATypeTag rightTag = rightConstant.getType().getTypeTag();
         if (leftTag == DOUBLE || rightTag == DOUBLE) {
-            result = Double.compare(getDoubleValue(leftTag, b1, s1), getConstantDouble(rightConstant));
+            result = Double.compare(getDoubleValue(leftTag, left), getConstantDouble(rightConstant));
         } else if (leftTag == FLOAT || rightTag == FLOAT) {
-            result = Float.compare((float) getDoubleValue(leftTag, b1, s1), (float) getConstantDouble(rightConstant));
+            result = Float.compare((float) getDoubleValue(leftTag, left), (float) getConstantDouble(rightConstant));
         } else if (leftTag == BIGINT || rightTag == BIGINT) {
-            result = Long.compare(getLongValue(leftTag, b1, s1), getConstantLong(rightConstant));
+            result = Long.compare(getLongValue(leftTag, left), getConstantLong(rightConstant));
         } else if (leftTag == INTEGER || leftTag == SMALLINT || leftTag == TINYINT) {
-            result = Integer.compare((int) getLongValue(leftTag, b1, s1), (int) getConstantLong(rightConstant));
+            result = Integer.compare((int) getLongValue(leftTag, left), (int) getConstantLong(rightConstant));
         } else {
             return null;
         }
@@ -116,7 +116,7 @@
     }
 
     // checking that left and right are compatible has to be done before calling this
-    static ILogicalBinaryComparator.Result compareConstants(IAObject leftConstant, IAObject rightConstant) {
+    static Result compareConstants(IAObject leftConstant, IAObject rightConstant) {
         int result;
         ATypeTag leftTag = leftConstant.getType().getTypeTag();
         ATypeTag rightTag = rightConstant.getType().getTypeTag();
@@ -134,40 +134,38 @@
         return ILogicalBinaryComparator.asResult(result);
     }
 
-    @SuppressWarnings("squid:S1226") // asking for introducing a new variable for s
-    private static double getDoubleValue(ATypeTag numericTag, byte[] b, int s) {
-        s++;
+    private static double getDoubleValue(ATypeTag numericTag, IPointable value) {
+        int start = value.getStartOffset() + 1;
         switch (numericTag) {
             case TINYINT:
-                return AInt8SerializerDeserializer.getByte(b, s);
+                return AInt8SerializerDeserializer.getByte(value.getByteArray(), start);
             case SMALLINT:
-                return AInt16SerializerDeserializer.getShort(b, s);
+                return AInt16SerializerDeserializer.getShort(value.getByteArray(), start);
             case INTEGER:
-                return AInt32SerializerDeserializer.getInt(b, s);
+                return AInt32SerializerDeserializer.getInt(value.getByteArray(), start);
             case BIGINT:
-                return AInt64SerializerDeserializer.getLong(b, s);
+                return AInt64SerializerDeserializer.getLong(value.getByteArray(), start);
             case FLOAT:
-                return AFloatSerializerDeserializer.getFloat(b, s);
+                return AFloatSerializerDeserializer.getFloat(value.getByteArray(), start);
             case DOUBLE:
-                return ADoubleSerializerDeserializer.getDouble(b, s);
+                return ADoubleSerializerDeserializer.getDouble(value.getByteArray(), start);
             default:
                 // TODO(ali): use unsupported type
                 throw new UnsupportedOperationException();
         }
     }
 
-    @SuppressWarnings("squid:S1226") // asking for introducing a new variable for s
-    private static long getLongValue(ATypeTag numericTag, byte[] b, int s) {
-        s++;
+    private static long getLongValue(ATypeTag numericTag, IPointable value) {
+        int start = value.getStartOffset() + 1;
         switch (numericTag) {
             case TINYINT:
-                return AInt8SerializerDeserializer.getByte(b, s);
+                return AInt8SerializerDeserializer.getByte(value.getByteArray(), start);
             case SMALLINT:
-                return AInt16SerializerDeserializer.getShort(b, s);
+                return AInt16SerializerDeserializer.getShort(value.getByteArray(), start);
             case INTEGER:
-                return AInt32SerializerDeserializer.getInt(b, s);
+                return AInt32SerializerDeserializer.getInt(value.getByteArray(), start);
             case BIGINT:
-                return AInt64SerializerDeserializer.getLong(b, s);
+                return AInt64SerializerDeserializer.getLong(value.getByteArray(), start);
             default:
                 // TODO(ali): use unsupported type
                 throw new UnsupportedOperationException();
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalComplexBinaryComparator.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalComplexBinaryComparator.java
index a5924b9..e792e23 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalComplexBinaryComparator.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalComplexBinaryComparator.java
@@ -76,10 +76,9 @@
     }
 
     @Override
-    public Result compare(byte[] leftBytes, int leftStart, int leftLen, byte[] rightBytes, int rightStart, int rightLen)
-            throws HyracksDataException {
-        ATypeTag leftRuntimeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(leftBytes[leftStart]);
-        ATypeTag rightRuntimeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(rightBytes[rightStart]);
+    public Result compare(IPointable left, IPointable right) throws HyracksDataException {
+        ATypeTag leftRuntimeTag = VALUE_TYPE_MAPPING[left.getByteArray()[left.getStartOffset()]];
+        ATypeTag rightRuntimeTag = VALUE_TYPE_MAPPING[right.getByteArray()[right.getStartOffset()]];
         Result comparisonResult = LogicalComparatorUtil.returnMissingOrNullOrMismatch(leftRuntimeTag, rightRuntimeTag);
         if (comparisonResult != null) {
             return comparisonResult;
@@ -88,14 +87,13 @@
         if (!leftRuntimeTag.isDerivedType() || !rightRuntimeTag.isDerivedType()) {
             throw new IllegalStateException("Input data is not complex type");
         }
-        return compareComplex(leftType, leftRuntimeTag, leftBytes, leftStart, leftLen, rightType, rightRuntimeTag,
-                rightBytes, rightStart, rightLen);
+        return compareComplex(leftType, leftRuntimeTag, left, rightType, rightRuntimeTag, right);
     }
 
     @Override
-    public Result compare(byte[] leftBytes, int leftStart, int leftLen, IAObject rightConstant) {
+    public Result compare(IPointable left, IAObject rightConstant) {
         // TODO(ali): not defined currently for constant complex types
-        ATypeTag leftTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(leftBytes[leftStart]);
+        ATypeTag leftTag = VALUE_TYPE_MAPPING[left.getByteArray()[left.getStartOffset()]];
         ATypeTag rightTag = rightConstant.getType().getTypeTag();
         Result comparisonResult = LogicalComparatorUtil.returnMissingOrNullOrMismatch(leftTag, rightTag);
         if (comparisonResult != null) {
@@ -106,9 +104,9 @@
     }
 
     @Override
-    public Result compare(IAObject leftConstant, byte[] rightBytes, int rightStart, int rightLen) {
+    public Result compare(IAObject leftConstant, IPointable right) {
         // TODO(ali): not defined currently for constant complex types
-        Result result = compare(rightBytes, rightStart, rightLen, leftConstant);
+        Result result = compare(right, leftConstant);
         switch (result) {
             case LT:
                 return Result.GT;
@@ -132,32 +130,32 @@
         return Result.NULL;
     }
 
-    private Result compareComplex(IAType leftType, ATypeTag leftRuntimeTag, byte[] leftBytes, int leftStart,
-            int leftLen, IAType rightType, ATypeTag rightRuntimeTag, byte[] rightBytes, int rightStart, int rightLen)
-            throws HyracksDataException {
-        if (leftRuntimeTag != rightRuntimeTag) {
+    private Result compareComplex(IAType leftType, ATypeTag leftTag, IPointable left, IAType rightType,
+            ATypeTag rightTag, IPointable right) throws HyracksDataException {
+        if (leftTag != rightTag) {
             return Result.INCOMPARABLE;
         }
-        IAType leftCompileType = TypeComputeUtils.getActualTypeOrOpen(leftType, leftRuntimeTag);
-        IAType rightCompileType = TypeComputeUtils.getActualTypeOrOpen(rightType, rightRuntimeTag);
-        switch (leftRuntimeTag) {
+        IAType leftCompileType = TypeComputeUtils.getActualTypeOrOpen(leftType, leftTag);
+        IAType rightCompileType = TypeComputeUtils.getActualTypeOrOpen(rightType, rightTag);
+        switch (leftTag) {
             case MULTISET:
-                return compareMultisets(leftCompileType, leftRuntimeTag, leftBytes, leftStart, rightCompileType,
-                        rightRuntimeTag, rightBytes, rightStart);
+                return compareMultisets(leftCompileType, leftTag, left, rightCompileType, rightTag, right);
             case ARRAY:
-                return compareArrays(leftCompileType, leftRuntimeTag, leftBytes, leftStart, rightCompileType,
-                        rightRuntimeTag, rightBytes, rightStart);
+                return compareArrays(leftCompileType, leftTag, left, rightCompileType, rightTag, right);
             case OBJECT:
-                return compareRecords(leftCompileType, leftBytes, leftStart, leftLen, rightCompileType, rightBytes,
-                        rightStart, rightLen);
+                return compareRecords(leftCompileType, left, rightCompileType, right);
             default:
                 return Result.NULL;
         }
     }
 
-    private Result compareArrays(IAType leftType, ATypeTag leftListTag, byte[] leftBytes, int leftStart,
-            IAType rightType, ATypeTag rightListTag, byte[] rightBytes, int rightStart) throws HyracksDataException {
+    private Result compareArrays(IAType leftType, ATypeTag leftListTag, IPointable left, IAType rightType,
+            ATypeTag rightListTag, IPointable right) throws HyracksDataException {
         // reaching here, both left and right have to be arrays (should be enforced)
+        byte[] leftBytes = left.getByteArray();
+        byte[] rightBytes = right.getByteArray();
+        int leftStart = left.getStartOffset();
+        int rightStart = right.getStartOffset();
         int leftNumItems = ListAccessorUtil.numberOfItems(leftBytes, leftStart);
         int rightNumItems = ListAccessorUtil.numberOfItems(rightBytes, rightStart);
         IAType leftItemCompileType = ((AbstractCollectionType) leftType).getItemType();
@@ -187,13 +185,10 @@
                 leftItemRuntimeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(leftItemTagByte);
                 rightItemRuntimeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(rightItemTagByte);
                 if (leftItemRuntimeTag.isDerivedType() && rightItemRuntimeTag.isDerivedType()) {
-                    tempResult = compareComplex(leftItemCompileType, leftItemRuntimeTag, leftItem.getByteArray(),
-                            leftItem.getStartOffset(), leftItem.getLength(), rightItemCompileType, rightItemRuntimeTag,
-                            rightItem.getByteArray(), rightItem.getStartOffset(), rightItem.getLength());
+                    tempResult = compareComplex(leftItemCompileType, leftItemRuntimeTag, leftItem, rightItemCompileType,
+                            rightItemRuntimeTag, rightItem);
                 } else {
-                    tempResult = scalarComparator.compare(leftItem.getByteArray(), leftItem.getStartOffset(),
-                            leftItem.getLength(), rightItem.getByteArray(), rightItem.getStartOffset(),
-                            rightItem.getLength());
+                    tempResult = scalarComparator.compare(leftItem, rightItem);
                 }
 
                 if (tempResult == Result.INCOMPARABLE || tempResult == Result.MISSING || tempResult == Result.NULL) {
@@ -220,8 +215,8 @@
         }
     }
 
-    private Result compareMultisets(IAType leftType, ATypeTag leftListTag, byte[] leftBytes, int leftStart,
-            IAType rightType, ATypeTag rightListTag, byte[] rightBytes, int rightStart) throws HyracksDataException {
+    private Result compareMultisets(IAType leftType, ATypeTag leftListTag, IPointable left, IAType rightType,
+            ATypeTag rightListTag, IPointable right) throws HyracksDataException {
         // TODO(ali): multiset comparison logic here
         // equality is the only operation defined for multiset
         if (!isEquality) {
@@ -230,8 +225,8 @@
         return Result.NULL;
     }
 
-    private Result compareRecords(IAType leftType, byte[] leftBytes, int leftStart, int leftLen, IAType rightType,
-            byte[] rightBytes, int rightStart, int rightLen) throws HyracksDataException {
+    private Result compareRecords(IAType leftType, IPointable left, IAType rightType, IPointable right)
+            throws HyracksDataException {
         // equality is the only operation defined for records
         if (!isEquality) {
             return Result.INCOMPARABLE;
@@ -243,8 +238,8 @@
         // keeps track of the fields in the right record that have not been matched
         BitSet notMatched = bitSetAllocator.allocate(null);
         try {
-            leftRecord.set(leftBytes, leftStart, leftLen);
-            rightRecord.set(rightBytes, rightStart, rightLen);
+            leftRecord.set(left);
+            rightRecord.set(right);
             List<IVisitablePointable> leftFieldValues = leftRecord.getFieldValues();
             List<IVisitablePointable> leftFieldNames = leftRecord.getFieldNames();
             List<IVisitablePointable> rightFieldValues = rightRecord.getFieldValues();
@@ -282,16 +277,10 @@
                                 } else if (leftFTag.isDerivedType() && rightFTag.isDerivedType()) {
                                     leftFieldType = CompareHashUtil.getType(leftRecordType, i, leftFTag);
                                     rightFieldType = CompareHashUtil.getType(rightRecordType, k, rightFTag);
-                                    tempCompResult =
-                                            compareComplex(leftFieldType, leftFTag, leftFieldValue.getByteArray(),
-                                                    leftFieldValue.getStartOffset(), leftFieldValue.getLength(),
-                                                    rightFieldType, rightFTag, rightFieldValue.getByteArray(),
-                                                    rightFieldValue.getStartOffset(), rightFieldValue.getLength());
+                                    tempCompResult = compareComplex(leftFieldType, leftFTag, leftFieldValue,
+                                            rightFieldType, rightFTag, rightFieldValue);
                                 } else {
-                                    tempCompResult = scalarComparator.compare(leftFieldValue.getByteArray(),
-                                            leftFieldValue.getStartOffset(), leftFieldValue.getLength(),
-                                            rightFieldValue.getByteArray(), rightFieldValue.getStartOffset(),
-                                            rightFieldValue.getLength());
+                                    tempCompResult = scalarComparator.compare(leftFieldValue, rightFieldValue);
                                 }
 
                                 if (tempCompResult == Result.INCOMPARABLE || tempCompResult == Result.MISSING
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalGenericBinaryComparator.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalGenericBinaryComparator.java
index 99c4151..51a782d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalGenericBinaryComparator.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalGenericBinaryComparator.java
@@ -18,47 +18,48 @@
  */
 package org.apache.asterix.dataflow.data.nontagged.comparators;
 
+import static org.apache.asterix.om.types.ATypeTag.VALUE_TYPE_MAPPING;
+
 import org.apache.asterix.dataflow.data.common.ILogicalBinaryComparator;
 import org.apache.asterix.om.base.IAObject;
 import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.data.std.api.IPointable;
 
 public class LogicalGenericBinaryComparator implements ILogicalBinaryComparator {
 
     private final LogicalComplexBinaryComparator complexComparator;
     private final LogicalScalarBinaryComparator scalarComparator;
 
-    public LogicalGenericBinaryComparator(IAType leftType, IAType rightType, boolean isEquality) {
+    LogicalGenericBinaryComparator(IAType leftType, IAType rightType, boolean isEquality) {
         complexComparator = new LogicalComplexBinaryComparator(leftType, rightType, isEquality);
         scalarComparator = new LogicalScalarBinaryComparator(isEquality);
     }
 
     @Override
-    public Result compare(byte[] leftBytes, int leftStart, int leftLen, byte[] rightBytes, int rightStart, int rightLen)
-            throws HyracksDataException {
-        ATypeTag leftTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(leftBytes[leftStart]);
-        ATypeTag rightTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(rightBytes[rightStart]);
+    public Result compare(IPointable left, IPointable right) throws HyracksDataException {
+        ATypeTag leftTag = VALUE_TYPE_MAPPING[left.getByteArray()[left.getStartOffset()]];
+        ATypeTag rightTag = VALUE_TYPE_MAPPING[right.getByteArray()[right.getStartOffset()]];
         if (leftTag.isDerivedType() && rightTag.isDerivedType()) {
-            return complexComparator.compare(leftBytes, leftStart, leftLen, rightBytes, rightStart, rightLen);
+            return complexComparator.compare(left, right);
         }
-        return scalarComparator.compare(leftBytes, leftStart, leftLen, rightBytes, rightStart, rightLen);
+        return scalarComparator.compare(left, right);
     }
 
     @Override
-    public Result compare(byte[] leftBytes, int leftStart, int leftLen, IAObject rightConstant) {
-        ATypeTag leftTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(leftBytes[leftStart]);
+    public Result compare(IPointable left, IAObject rightConstant) {
+        ATypeTag leftTag = VALUE_TYPE_MAPPING[left.getByteArray()[left.getStartOffset()]];
         ATypeTag rightTag = rightConstant.getType().getTypeTag();
         if (leftTag.isDerivedType() && rightTag.isDerivedType()) {
-            return complexComparator.compare(leftBytes, leftStart, leftLen, rightConstant);
+            return complexComparator.compare(left, rightConstant);
         }
-        return scalarComparator.compare(leftBytes, leftStart, leftLen, rightConstant);
+        return scalarComparator.compare(left, rightConstant);
     }
 
     @Override
-    public Result compare(IAObject leftConstant, byte[] rightBytes, int rightStart, int rightLen) {
-        Result result = compare(rightBytes, rightStart, rightLen, leftConstant);
+    public Result compare(IAObject leftConstant, IPointable right) {
+        Result result = compare(right, leftConstant);
         if (result == Result.LT) {
             return Result.GT;
         } else if (result == Result.GT) {
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalScalarBinaryComparator.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalScalarBinaryComparator.java
index a25c90e..f293193 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalScalarBinaryComparator.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LogicalScalarBinaryComparator.java
@@ -26,6 +26,7 @@
 import static org.apache.asterix.om.types.ATypeTag.POINT3D;
 import static org.apache.asterix.om.types.ATypeTag.POLYGON;
 import static org.apache.asterix.om.types.ATypeTag.RECTANGLE;
+import static org.apache.asterix.om.types.ATypeTag.VALUE_TYPE_MAPPING;
 
 import java.util.EnumSet;
 
@@ -38,10 +39,10 @@
 import org.apache.asterix.formats.nontagged.BinaryComparatorFactoryProvider;
 import org.apache.asterix.om.base.IAObject;
 import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.accessors.PointableBinaryComparatorFactory;
+import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
 
 public class LogicalScalarBinaryComparator implements ILogicalBinaryComparator {
@@ -80,10 +81,9 @@
 
     @SuppressWarnings("squid:S1226") // asking for introducing a new variable for incremented local variables
     @Override
-    public Result compare(byte[] leftBytes, int leftStart, int leftLen, byte[] rightBytes, int rightStart, int rightLen)
-            throws HyracksDataException {
-        ATypeTag leftTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(leftBytes[leftStart]);
-        ATypeTag rightTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(rightBytes[rightStart]);
+    public Result compare(IPointable left, IPointable right) throws HyracksDataException {
+        ATypeTag leftTag = VALUE_TYPE_MAPPING[left.getByteArray()[left.getStartOffset()]];
+        ATypeTag rightTag = VALUE_TYPE_MAPPING[right.getByteArray()[right.getStartOffset()]];
         Result comparisonResult = LogicalComparatorUtil.returnMissingOrNullOrMismatch(leftTag, rightTag);
         if (comparisonResult != null) {
             return comparisonResult;
@@ -92,8 +92,7 @@
             return Result.INCOMPARABLE;
         }
         // compare number if one of args is number
-        comparisonResult =
-                LogicalComparatorUtil.compareNumbers(leftTag, leftBytes, leftStart, rightTag, rightBytes, rightStart);
+        comparisonResult = LogicalComparatorUtil.compareNumbers(leftTag, left, rightTag, right);
         if (comparisonResult != null) {
             return comparisonResult;
         }
@@ -104,10 +103,12 @@
             throw new IllegalStateException("Two different non-numeric tags but they are compatible");
         }
 
-        leftStart++;
-        leftLen--;
-        rightStart++;
-        rightLen--;
+        byte[] leftBytes = left.getByteArray();
+        byte[] rightBytes = right.getByteArray();
+        int leftStart = left.getStartOffset() + 1;
+        int rightStart = right.getStartOffset() + 1;
+        int leftLen = left.getLength() - 1;
+        int rightLen = right.getLength() - 1;
 
         int result;
         switch (leftTag) {
@@ -177,9 +178,9 @@
     }
 
     @Override
-    public Result compare(byte[] leftBytes, int leftStart, int leftLen, IAObject rightConstant) {
+    public Result compare(IPointable left, IAObject rightConstant) {
         // TODO(ali): currently defined for numbers only
-        ATypeTag leftTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(leftBytes[leftStart]);
+        ATypeTag leftTag = VALUE_TYPE_MAPPING[left.getByteArray()[left.getStartOffset()]];
         ATypeTag rightTag = rightConstant.getType().getTypeTag();
         Result comparisonResult = LogicalComparatorUtil.returnMissingOrNullOrMismatch(leftTag, rightTag);
         if (comparisonResult != null) {
@@ -188,7 +189,7 @@
         if (comparisonUndefined(leftTag, rightTag, isEquality)) {
             return Result.NULL;
         }
-        comparisonResult = LogicalComparatorUtil.compareNumWithConstant(leftTag, leftBytes, leftStart, rightConstant);
+        comparisonResult = LogicalComparatorUtil.compareNumWithConstant(leftTag, left, rightConstant);
         if (comparisonResult != null) {
             return comparisonResult;
         }
@@ -196,9 +197,9 @@
     }
 
     @Override
-    public Result compare(IAObject leftConstant, byte[] rightBytes, int rightStart, int rightLen) {
+    public Result compare(IAObject leftConstant, IPointable right) {
         // TODO(ali): currently defined for numbers only
-        Result result = compare(rightBytes, rightStart, rightLen, leftConstant);
+        Result result = compare(right, leftConstant);
         if (result == Result.LT) {
             return Result.GT;
         } else if (result == Result.GT) {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
index b7ed05d..1d1b3e1 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
@@ -109,17 +109,14 @@
                 return logicalComparator.compare(leftConstant, rightConstant);
             } else {
                 // left is constant, right isn't
-                return logicalComparator.compare(leftConstant, argRight.getByteArray(), argRight.getStartOffset(),
-                        argRight.getLength());
+                return logicalComparator.compare(leftConstant, argRight);
             }
         } else {
             if (rightConstant != null) {
                 // right is constant, left isn't
-                return logicalComparator.compare(argLeft.getByteArray(), argLeft.getStartOffset(), argLeft.getLength(),
-                        rightConstant);
+                return logicalComparator.compare(argLeft, rightConstant);
             } else {
-                return logicalComparator.compare(argLeft.getByteArray(), argLeft.getStartOffset(), argLeft.getLength(),
-                        argRight.getByteArray(), argRight.getStartOffset(), argRight.getLength());
+                return logicalComparator.compare(argLeft, argRight);
             }
         }
     }
