You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by bu...@apache.org on 2016/05/24 01:31:29 UTC
[11/22] incubator-asterixdb git commit: ASTERIXDB-1228: Add MISSING
into the data model.
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/CreateMBREvalFactory.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/CreateMBREvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/CreateMBREvalFactory.java
index c92daa2..0a4d258 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/CreateMBREvalFactory.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/CreateMBREvalFactory.java
@@ -76,43 +76,58 @@ public class CreateMBREvalFactory implements IScalarEvaluatorFactory {
eval0.evaluate(tuple, inputArg0);
eval1.evaluate(tuple, inputArg1);
eval2.evaluate(tuple, inputArg2);
+ byte[] data0 = inputArg0.getByteArray();
+ byte[] data1 = inputArg1.getByteArray();
+ byte[] data2 = inputArg2.getByteArray();
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 (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(inputArg1.getByteArray(), startOffset1 + 1);
+ if (data0[startOffset0] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG
+ || data1[startOffset1] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG
+ || data2[startOffset2] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
+ out.writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
+ result.set(resultStorage);
+ return;
+ }
+ if (data0[startOffset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+ || data1[startOffset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+ || data2[startOffset2] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+ out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ result.set(resultStorage);
+ return;
+ }
+
+ resultStorage.reset();
+ // type-check: (Point/Line/Polygon/Circle/Rectangle/Null, Int32, Int32)
+ if (data1[startOffset1] != ATypeTag.SERIALIZED_INT32_TYPE_TAG
+ || data2[startOffset2] != ATypeTag.SERIALIZED_INT32_TYPE_TAG) {
+ throw new AlgebricksException(
+ "Expects Types: (Point/Line/Polygon/Circle/Rectangle/Null, Int32, Int32).");
+ }
+
+ int dimension = AInt32SerializerDeserializer.getInt(data1, startOffset1 + 1);
int coordinate = AInt32SerializerDeserializer.getInt(inputArg2.getByteArray(), startOffset2 + 1);
double value;
if (dimension == 2) {
- ATypeTag tag = EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(inputArg0.getByteArray()[startOffset0]);
+ ATypeTag tag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(data0[startOffset0]);
switch (tag) {
case POINT:
switch (coordinate) {
case 0: // 0 is for min x, 1 is for min y, 2
- // for
+ // for
// max x, and 3 for max y
case 2: {
- double x = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
- startOffset0 + APointSerializerDeserializer
- .getCoordinateOffset(Coordinate.X));
+ double x = ADoubleSerializerDeserializer.getDouble(data0, startOffset0
+ + APointSerializerDeserializer.getCoordinateOffset(Coordinate.X));
value = x;
}
break;
case 1:
case 3: {
- double y = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
- startOffset0 + APointSerializerDeserializer
- .getCoordinateOffset(Coordinate.Y));
+ double y = ADoubleSerializerDeserializer.getDouble(data0, startOffset0
+ + APointSerializerDeserializer.getCoordinateOffset(Coordinate.Y));
value = y;
}
@@ -128,10 +143,10 @@ public class CreateMBREvalFactory implements IScalarEvaluatorFactory {
switch (coordinate) {
case 0: {
value = Double.MAX_VALUE;
- double startX = ADoubleSerializerDeserializer.getDouble(
- inputArg0.getByteArray(), startOffset0 + ALineSerializerDeserializer
+ double startX = ADoubleSerializerDeserializer.getDouble(data0,
+ startOffset0 + ALineSerializerDeserializer
.getStartPointCoordinateOffset(Coordinate.X));
- double endX = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double endX = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ALineSerializerDeserializer
.getEndPointCoordinateOffset(Coordinate.X));
@@ -140,10 +155,10 @@ public class CreateMBREvalFactory implements IScalarEvaluatorFactory {
break;
case 1: {
value = Double.MAX_VALUE;
- double startY = ADoubleSerializerDeserializer.getDouble(
- inputArg0.getByteArray(), startOffset0 + ALineSerializerDeserializer
+ double startY = ADoubleSerializerDeserializer.getDouble(data0,
+ startOffset0 + ALineSerializerDeserializer
.getStartPointCoordinateOffset(Coordinate.Y));
- double endY = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double endY = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ALineSerializerDeserializer
.getEndPointCoordinateOffset(Coordinate.Y));
@@ -152,10 +167,10 @@ public class CreateMBREvalFactory implements IScalarEvaluatorFactory {
break;
case 2: {
value = Double.MIN_VALUE;
- double startX = ADoubleSerializerDeserializer.getDouble(
- inputArg0.getByteArray(), startOffset0 + ALineSerializerDeserializer
+ double startX = ADoubleSerializerDeserializer.getDouble(data0,
+ startOffset0 + ALineSerializerDeserializer
.getStartPointCoordinateOffset(Coordinate.X));
- double endX = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double endX = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ALineSerializerDeserializer
.getEndPointCoordinateOffset(Coordinate.X));
@@ -164,10 +179,10 @@ public class CreateMBREvalFactory implements IScalarEvaluatorFactory {
break;
case 3: {
value = Double.MIN_VALUE;
- double startY = ADoubleSerializerDeserializer.getDouble(
- inputArg0.getByteArray(), startOffset0 + ALineSerializerDeserializer
+ double startY = ADoubleSerializerDeserializer.getDouble(data0,
+ startOffset0 + ALineSerializerDeserializer
.getStartPointCoordinateOffset(Coordinate.Y));
- double endY = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double endY = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ALineSerializerDeserializer
.getEndPointCoordinateOffset(Coordinate.Y));
@@ -181,13 +196,13 @@ public class CreateMBREvalFactory implements IScalarEvaluatorFactory {
}
break;
case POLYGON:
- int numOfPoints = AInt16SerializerDeserializer.getShort(inputArg0.getByteArray(),
+ int numOfPoints = AInt16SerializerDeserializer.getShort(data0,
startOffset0 + APolygonSerializerDeserializer.getNumberOfPointsOffset());
switch (coordinate) {
case 0: {
value = Double.MAX_VALUE;
for (int i = 0; i < numOfPoints; i++) {
- double x = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double x = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + APolygonSerializerDeserializer.getCoordinateOffset(i,
Coordinate.X));
value = Math.min(x, value);
@@ -197,7 +212,7 @@ public class CreateMBREvalFactory implements IScalarEvaluatorFactory {
case 1: {
value = Double.MAX_VALUE;
for (int i = 0; i < numOfPoints; i++) {
- double y = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double y = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + APolygonSerializerDeserializer.getCoordinateOffset(i,
Coordinate.Y));
value = Math.min(y, value);
@@ -207,7 +222,7 @@ public class CreateMBREvalFactory implements IScalarEvaluatorFactory {
case 2: {
value = Double.MIN_VALUE;
for (int i = 0; i < numOfPoints; i++) {
- double x = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double x = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + APolygonSerializerDeserializer.getCoordinateOffset(i,
Coordinate.X));
value = Math.max(x, value);
@@ -217,7 +232,7 @@ public class CreateMBREvalFactory implements IScalarEvaluatorFactory {
case 3: {
value = Double.MIN_VALUE;
for (int i = 0; i < numOfPoints; i++) {
- double y = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double y = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + APolygonSerializerDeserializer.getCoordinateOffset(i,
Coordinate.Y));
value = Math.max(y, value);
@@ -233,43 +248,39 @@ public class CreateMBREvalFactory implements IScalarEvaluatorFactory {
case CIRCLE:
switch (coordinate) {
case 0: {
- double x = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double x = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ACircleSerializerDeserializer
.getCenterPointCoordinateOffset(Coordinate.X));
- double radius = ADoubleSerializerDeserializer.getDouble(
- inputArg0.getByteArray(),
+ double radius = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ACircleSerializerDeserializer.getRadiusOffset());
value = x - radius;
}
break;
case 1: {
- double y = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double y = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ACircleSerializerDeserializer
.getCenterPointCoordinateOffset(Coordinate.Y));
- double radius = ADoubleSerializerDeserializer.getDouble(
- inputArg0.getByteArray(),
+ double radius = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ACircleSerializerDeserializer.getRadiusOffset());
value = y - radius;
}
break;
case 2: {
- double x = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double x = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ACircleSerializerDeserializer
.getCenterPointCoordinateOffset(Coordinate.X));
- double radius = ADoubleSerializerDeserializer.getDouble(
- inputArg0.getByteArray(),
+ double radius = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ACircleSerializerDeserializer.getRadiusOffset());
value = x + radius;
}
break;
case 3: {
- double y = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double y = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ACircleSerializerDeserializer
.getCenterPointCoordinateOffset(Coordinate.Y));
- double radius = ADoubleSerializerDeserializer.getDouble(
- inputArg0.getByteArray(),
+ double radius = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ACircleSerializerDeserializer.getRadiusOffset());
value = y + radius;
@@ -285,25 +296,25 @@ public class CreateMBREvalFactory implements IScalarEvaluatorFactory {
value = Double.MAX_VALUE;
switch (coordinate) {
case 0: {
- value = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ value = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ARectangleSerializerDeserializer
.getBottomLeftCoordinateOffset(Coordinate.X));
}
break;
case 1: {
- value = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ value = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ARectangleSerializerDeserializer
.getBottomLeftCoordinateOffset(Coordinate.Y));
}
break;
case 2: {
- value = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ value = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ARectangleSerializerDeserializer
.getUpperRightCoordinateOffset(Coordinate.X));
}
break;
case 3: {
- value = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ value = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ARectangleSerializerDeserializer
.getUpperRightCoordinateOffset(Coordinate.Y));
}
@@ -314,11 +325,6 @@ public class CreateMBREvalFactory implements IScalarEvaluatorFactory {
}
}
break;
- case NULL: {
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
- result.set(resultStorage);
- return;
- }
default:
throw new NotImplementedException(
"create-mbr is only implemented for POINT, LINE, POLYGON, CIRCLE and RECTANGLE. Encountered type: "
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceCheckEvaluator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceCheckEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceCheckEvaluator.java
index 915ff53..3dca584 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceCheckEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceCheckEvaluator.java
@@ -27,6 +27,7 @@ import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.ATypeTag;
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.IScalarEvaluator;
@@ -59,14 +60,29 @@ public class EditDistanceCheckEvaluator extends EditDistanceEvaluator {
}
@Override
- protected void runArgEvals(IFrameTupleReference tuple) throws AlgebricksException {
- super.runArgEvals(tuple);
+ public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+ resultStorage.reset();
+
+ firstStringEval.evaluate(tuple, argPtr1);
+ firstTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset()]);
+ secondStringEval.evaluate(tuple, argPtr2);
+ secondTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset()]);
edThreshEval.evaluate(tuple, argPtrThreshold);
+
+ if (!checkArgTypes(firstTypeTag, secondTypeTag)) {
+ result.set(resultStorage);
+ return;
+ }
try {
edThresh = ATypeHierarchy.getIntegerValue(argPtrThreshold.getByteArray(), argPtrThreshold.getStartOffset());
- } catch (HyracksDataException e) {
+ editDistance = computeResult(argPtr1, argPtr2, firstTypeTag);
+ writeResult(editDistance);
+ } catch (IOException e) {
throw new AlgebricksException(e);
}
+ result.set(resultStorage);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceEvaluator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceEvaluator.java
index f6345d6..d2adc1c 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceEvaluator.java
@@ -25,7 +25,6 @@ import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.fuzzyjoin.similarity.SimilarityMetricEditDistance;
import org.apache.asterix.om.base.AInt64;
import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
@@ -59,9 +58,6 @@ public class EditDistanceEvaluator implements IScalarEvaluator {
@SuppressWarnings("unchecked")
protected final ISerializerDeserializer<AInt64> int64Serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
protected ATypeTag itemTypeTag;
protected ATypeTag firstTypeTag;
@@ -76,7 +72,14 @@ public class EditDistanceEvaluator implements IScalarEvaluator {
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
- runArgEvals(tuple);
+
+ firstStringEval.evaluate(tuple, argPtr1);
+ firstTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset()]);
+ secondStringEval.evaluate(tuple, argPtr2);
+ secondTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset()]);
+
if (!checkArgTypes(firstTypeTag, secondTypeTag)) {
result.set(resultStorage);
return;
@@ -96,15 +99,6 @@ public class EditDistanceEvaluator implements IScalarEvaluator {
result.set(resultStorage);
}
- protected void runArgEvals(IFrameTupleReference tuple) throws AlgebricksException {
- 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(IPointable left, IPointable right, ATypeTag argType)
throws AlgebricksException, HyracksDataException {
byte[] leftBytes = left.getByteArray();
@@ -136,16 +130,6 @@ public class EditDistanceEvaluator implements IScalarEvaluator {
}
protected boolean checkArgTypes(ATypeTag typeTag1, ATypeTag typeTag2) throws AlgebricksException {
- // edit distance between null and anything else is undefined
- if (typeTag1 == ATypeTag.NULL || typeTag2 == ATypeTag.NULL) {
- try {
- nullSerde.serialize(ANull.NULL, out);
- } catch (IOException e) {
- throw new AlgebricksException(e);
- }
- return false;
- }
-
if (typeTag1 != typeTag2) {
throw new AlgebricksException(
"Incompatible argument types given in edit distance: " + typeTag1 + " " + typeTag2);
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardCheckEvaluator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardCheckEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardCheckEvaluator.java
index b2eca6d..f31b289 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardCheckEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardCheckEvaluator.java
@@ -26,6 +26,7 @@ import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ABoolean;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.runtime.evaluators.functions.BinaryHashMap.BinaryEntry;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
@@ -61,11 +62,41 @@ public class SimilarityJaccardCheckEvaluator extends SimilarityJaccardEvaluator
}
@Override
- protected void runArgEvals(IFrameTupleReference tuple) throws AlgebricksException {
- super.runArgEvals(tuple);
+ public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+ resultStorage.reset();
+
+ firstOrdListEval.evaluate(tuple, argPtr1);
+ secondOrdListEval.evaluate(tuple, argPtr2);
jaccThreshEval.evaluate(tuple, jaccThreshPointable);
- jaccThresh = (float) AFloatSerializerDeserializer.getFloat(jaccThreshPointable.getByteArray(),
+
+ firstTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset()]);
+ secondTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset()]);
+
+ firstItemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset() + 1]);
+ secondItemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset() + 1]);
+
+ jaccThresh = AFloatSerializerDeserializer.getFloat(jaccThreshPointable.getByteArray(),
jaccThreshPointable.getStartOffset() + TYPE_INDICATOR_SIZE);
+
+ if (!checkArgTypes(firstTypeTag, secondTypeTag)) {
+ result.set(resultStorage);
+ return;
+ }
+ if (prepareLists(argPtr1, argPtr2, firstTypeTag)) {
+ jaccSim = computeResult();
+ } else {
+ jaccSim = 0.0f;
+ }
+ try {
+ writeResult(jaccSim);
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
+ result.set(resultStorage);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
index 92946c6..01c4b6b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
@@ -100,7 +100,20 @@ public class SimilarityJaccardEvaluator implements IScalarEvaluator {
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
- runArgEvals(tuple);
+
+ firstOrdListEval.evaluate(tuple, argPtr1);
+ secondOrdListEval.evaluate(tuple, argPtr2);
+
+ firstTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset()]);
+ secondTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset()]);
+
+ firstItemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset() + 1]);
+ secondItemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset() + 1]);
+
if (!checkArgTypes(firstTypeTag, secondTypeTag)) {
result.set(resultStorage);
return;
@@ -118,28 +131,6 @@ public class SimilarityJaccardEvaluator implements IScalarEvaluator {
result.set(resultStorage);
}
- protected void runArgEvals(IFrameTupleReference tuple) throws AlgebricksException {
- firstOrdListEval.evaluate(tuple, argPtr1);
- secondOrdListEval.evaluate(tuple, argPtr2);
-
- firstTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset()]);
- secondTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset()]);
-
- if (firstTypeTag == ATypeTag.NULL) {
- return;
- }
- if (secondTypeTag == ATypeTag.NULL) {
- return;
- }
-
- firstItemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset() + 1]);
- secondItemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset() + 1]);
- }
-
protected boolean prepareLists(IPointable left, IPointable right, ATypeTag argType) throws AlgebricksException {
try {
firstListIter.reset(left.getByteArray(), left.getStartOffset());
@@ -249,15 +240,6 @@ public class SimilarityJaccardEvaluator implements IScalarEvaluator {
}
protected boolean checkArgTypes(ATypeTag typeTag1, ATypeTag typeTag2) throws AlgebricksException {
- // Jaccard between null and anything else is 0
- if (typeTag1 == ATypeTag.NULL || typeTag2 == ATypeTag.NULL) {
- try {
- writeResult(0.0f);
- } catch (IOException e) {
- throw new AlgebricksException(e);
- }
- return false;
- }
switch (typeTag1) {
case ORDEREDLIST: {
firstListIter = fstOrdListIter;
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
----------------------------------------------------------------------
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 30f6562..ebf255f 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
@@ -20,18 +20,16 @@ package org.apache.asterix.runtime.evaluators.comparisons;
import java.io.DataOutput;
-import org.apache.asterix.dataflow.data.nontagged.comparators.ABinaryComparator;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ABoolean;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.types.ATypeTag;
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.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.BinaryComparatorConstant.ComparableResultCode;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
@@ -42,13 +40,6 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
public abstract class AbstractComparisonEvaluator implements IScalarEvaluator {
- protected enum ComparisonResult {
- LESS_THAN,
- EQUAL,
- GREATER_THAN,
- UNKNOWN
- }
-
protected ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
protected DataOutput out = resultStorage.getDataOutput();
protected TaggedValuePointable argLeft = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
@@ -62,9 +53,6 @@ public abstract class AbstractComparisonEvaluator implements IScalarEvaluator {
@SuppressWarnings("unchecked")
protected ISerializerDeserializer<ABoolean> serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ABOOLEAN);
- @SuppressWarnings("unchecked")
- protected ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
public AbstractComparisonEvaluator(IScalarEvaluatorFactory evalLeftFactory,
IScalarEvaluatorFactory evalRightFactory, IHyracksTaskContext context) throws AlgebricksException {
@@ -75,7 +63,12 @@ public abstract class AbstractComparisonEvaluator implements IScalarEvaluator {
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
- evalInputs(tuple);
+
+ // Evaluates input args.
+ evalLeft.evaluate(tuple, argLeft);
+ evalRight.evaluate(tuple, argRight);
+ argLeft.getValue(outLeft);
+ argRight.getValue(outRight);
// checks whether we can apply >, >=, <, and <= to the given type since
// these operations cannot be defined for certain types.
@@ -83,54 +76,27 @@ public abstract class AbstractComparisonEvaluator implements IScalarEvaluator {
checkTotallyOrderable();
}
+ ABoolean b;
// Checks whether two types are comparable
- switch (comparabilityCheck()) {
- case UNKNOWN:
- // result:UNKNOWN - NULL value found
- try {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- case FALSE:
- // result:FALSE - two types cannot be compared. Thus we return FALSE since this is equality comparison
- ABoolean b = ABoolean.FALSE;
- try {
- serde.serialize(b, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- break;
- case TRUE:
- // Two types can be compared
- ComparisonResult r = compareResults();
- ABoolean b1 = getComparisonResult(r) ? ABoolean.TRUE : ABoolean.FALSE;
- try {
- serde.serialize(b1, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- break;
- default:
- throw new AlgebricksException(
- "Comparison cannot be processed. The return code from ComparabilityCheck is not correct.");
+ if (comparabilityCheck()) {
+ // Two types can be compared
+ int r = compareResults();
+ b = getComparisonResult(r) ? ABoolean.TRUE : ABoolean.FALSE;
+ } else {
+ // result:FALSE - two types cannot be compared. Thus we return FALSE since this is equality comparison
+ b = ABoolean.FALSE;
+ }
+ try {
+ serde.serialize(b, out);
+ } catch (HyracksDataException e) {
+ throw new AlgebricksException(e);
}
result.set(resultStorage);
}
protected abstract boolean isTotallyOrderable();
- protected abstract boolean getComparisonResult(ComparisonResult r);
-
- protected void evalInputs(IFrameTupleReference tuple) throws AlgebricksException {
- evalLeft.evaluate(tuple, argLeft);
- evalRight.evaluate(tuple, argRight);
-
- argLeft.getValue(outLeft);
- argRight.getValue(outRight);
- }
+ protected abstract boolean getComparisonResult(int r);
// checks whether we can apply >, >=, <, and <= operations to the given type since
// these operations can not be defined for certain types.
@@ -155,46 +121,19 @@ public abstract class AbstractComparisonEvaluator implements IScalarEvaluator {
}
// checks whether two types are comparable
- protected ComparableResultCode comparabilityCheck() {
- // just check TypeTags
- return ABinaryComparator.isComparable(argLeft.getTag(), argRight.getTag());
- }
-
- protected ComparisonResult compareResults() throws AlgebricksException {
- boolean isLeftNull = false;
- boolean isRightNull = false;
- ATypeTag typeTag1 = null;
- ATypeTag typeTag2 = null;
+ protected boolean comparabilityCheck() {
+ // Checks whether two types are comparable or not
+ ATypeTag typeTag1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argLeft.getTag());
+ ATypeTag typeTag2 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argRight.getTag());
- if (outLeft.getLength() == 0) {
- isLeftNull = true;
- } else {
- typeTag1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argLeft.getTag());
- if (typeTag1 == ATypeTag.NULL) {
- isLeftNull = true;
- }
- }
- if (outRight.getLength() == 0) {
- isRightNull = true;
- } else {
- typeTag2 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argRight.getTag());
- if (typeTag2 == ATypeTag.NULL) {
- isRightNull = true;
- }
- }
-
- if (isLeftNull || isRightNull) {
- return ComparisonResult.UNKNOWN;
- }
+ // Are two types compatible, meaning that they can be compared? (e.g., compare between numeric types
+ return ATypeHierarchy.isCompatible(typeTag1, typeTag2);
+ }
- int result = ch.compare(typeTag1, typeTag2, outLeft, outRight);
- if (result == 0) {
- return ComparisonResult.EQUAL;
- } else if (result < 0) {
- return ComparisonResult.LESS_THAN;
- } else {
- return ComparisonResult.GREATER_THAN;
- }
+ protected int compareResults() throws AlgebricksException {
+ int result = ch.compare(EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argLeft.getTag()),
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argRight.getTag()), outLeft, outRight);
+ return result;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/ComparisonEvalFactory.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/ComparisonEvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/ComparisonEvalFactory.java
deleted file mode 100644
index 649f262..0000000
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/ComparisonEvalFactory.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.runtime.evaluators.comparisons;
-
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions.ComparisonKind;
-import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-
-public class ComparisonEvalFactory implements IScalarEvaluatorFactory {
- private static final long serialVersionUID = 1L;
-
- private IScalarEvaluatorFactory evalLeftFactory;
- private IScalarEvaluatorFactory evalRightFactory;
- private ComparisonKind comparisonKind;
-
- public ComparisonEvalFactory(IScalarEvaluatorFactory evalLeftFactory, IScalarEvaluatorFactory evalRightFactory,
- ComparisonKind comparisonKind) {
- this.evalLeftFactory = evalLeftFactory;
- this.evalRightFactory = evalRightFactory;
- this.comparisonKind = comparisonKind;
- }
-
- @Override
- public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
- switch (comparisonKind) {
- // Should we do any normalization?
- case EQ: {
- return new EqualityComparisonEvaluator(evalLeftFactory, evalRightFactory, ctx);
- }
- case GE: {
- return new GreaterThanOrEqualComparisonEvaluator(evalLeftFactory, evalRightFactory, ctx);
- }
- case GT: {
- return new GreaterThanComparisonEvaluator(evalLeftFactory, evalRightFactory, ctx);
- }
- case LE: {
- return new LessThanOrEqualComparisonEvaluator(evalLeftFactory, evalRightFactory, ctx);
- }
- case LT: {
- return new LessThanComparisonEvaluator(evalLeftFactory, evalRightFactory, ctx);
- }
- case NEQ: {
- return new InequalityComparisonEvaluator(evalLeftFactory, evalRightFactory, ctx);
- }
- default: {
- throw new IllegalStateException();
- }
- }
- }
-
- static class EqualityComparisonEvaluator extends AbstractComparisonEvaluator {
- public EqualityComparisonEvaluator(IScalarEvaluatorFactory evalLeftFactory,
- IScalarEvaluatorFactory evalRightFactory, IHyracksTaskContext context) throws AlgebricksException {
- super(evalLeftFactory, evalRightFactory, context);
- }
-
- @Override
- protected boolean getComparisonResult(ComparisonResult r) {
- return (r == ComparisonResult.EQUAL);
- }
-
- @Override
- protected boolean isTotallyOrderable() {
- return false;
- }
- }
-
- static class InequalityComparisonEvaluator extends AbstractComparisonEvaluator {
- public InequalityComparisonEvaluator(IScalarEvaluatorFactory evalLeftFactory,
- IScalarEvaluatorFactory evalRightFactory, IHyracksTaskContext context) throws AlgebricksException {
- super(evalLeftFactory, evalRightFactory, context);
- }
-
- @Override
- protected boolean getComparisonResult(ComparisonResult r) {
- return (r != ComparisonResult.EQUAL);
- }
-
- @Override
- protected boolean isTotallyOrderable() {
- return false;
- }
- }
-
- static class GreaterThanOrEqualComparisonEvaluator extends AbstractComparisonEvaluator {
- public GreaterThanOrEqualComparisonEvaluator(IScalarEvaluatorFactory evalLeftFactory,
- IScalarEvaluatorFactory evalRightFactory, IHyracksTaskContext context) throws AlgebricksException {
- super(evalLeftFactory, evalRightFactory, context);
- }
-
- @Override
- protected boolean getComparisonResult(ComparisonResult r) {
- return (r == ComparisonResult.EQUAL || r == ComparisonResult.GREATER_THAN);
- }
-
- @Override
- protected boolean isTotallyOrderable() {
- return true;
- }
- }
-
- static class GreaterThanComparisonEvaluator extends AbstractComparisonEvaluator {
- public GreaterThanComparisonEvaluator(IScalarEvaluatorFactory evalLeftFactory,
- IScalarEvaluatorFactory evalRightFactory, IHyracksTaskContext context) throws AlgebricksException {
- super(evalLeftFactory, evalRightFactory, context);
- }
-
- @Override
- protected boolean getComparisonResult(ComparisonResult r) {
- return (r == ComparisonResult.GREATER_THAN);
- }
-
- @Override
- protected boolean isTotallyOrderable() {
- return true;
- }
- }
-
- static class LessThanOrEqualComparisonEvaluator extends AbstractComparisonEvaluator {
- public LessThanOrEqualComparisonEvaluator(IScalarEvaluatorFactory evalLeftFactory,
- IScalarEvaluatorFactory evalRightFactory, IHyracksTaskContext context) throws AlgebricksException {
- super(evalLeftFactory, evalRightFactory, context);
- }
-
- @Override
- protected boolean getComparisonResult(ComparisonResult r) {
- return (r == ComparisonResult.EQUAL || r == ComparisonResult.LESS_THAN);
- }
-
- @Override
- protected boolean isTotallyOrderable() {
- return true;
- }
- }
-
- static class LessThanComparisonEvaluator extends AbstractComparisonEvaluator {
- public LessThanComparisonEvaluator(IScalarEvaluatorFactory evalLeftFactory,
- IScalarEvaluatorFactory evalRightFactory, IHyracksTaskContext context) throws AlgebricksException {
- super(evalLeftFactory, evalRightFactory, context);
- }
-
- @Override
- protected boolean getComparisonResult(ComparisonResult r) {
- return (r == ComparisonResult.LESS_THAN);
- }
-
- @Override
- protected boolean isTotallyOrderable() {
- return true;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/EqualsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/EqualsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/EqualsDescriptor.java
new file mode 100644
index 0000000..122c1a2
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/EqualsDescriptor.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.evaluators.comparisons;
+
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+
+public class EqualsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new EqualsDescriptor();
+ }
+ };
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.EQ;
+ }
+
+ @Override
+ public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) throws AlgebricksException {
+ return new IScalarEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+ return new AbstractComparisonEvaluator(args[0], args[1], ctx) {
+
+ @Override
+ protected boolean getComparisonResult(int r) {
+ return r == 0;
+ }
+
+ @Override
+ protected boolean isTotallyOrderable() {
+ return false;
+ }
+ };
+ }
+
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/GreaterThanDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/GreaterThanDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/GreaterThanDescriptor.java
new file mode 100644
index 0000000..1bc731a
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/GreaterThanDescriptor.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.evaluators.comparisons;
+
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+
+public class GreaterThanDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new GreaterThanDescriptor();
+ }
+ };
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.GT;
+ }
+
+ @Override
+ public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) throws AlgebricksException {
+ return new IScalarEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+ return new AbstractComparisonEvaluator(args[0], args[1], ctx) {
+
+ @Override
+ protected boolean getComparisonResult(int r) {
+ return r > 0;
+ }
+
+ @Override
+ protected boolean isTotallyOrderable() {
+ return true;
+ }
+ };
+ }
+
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/GreaterThanOrEqualsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/GreaterThanOrEqualsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/GreaterThanOrEqualsDescriptor.java
new file mode 100644
index 0000000..b6318ad
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/GreaterThanOrEqualsDescriptor.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.evaluators.comparisons;
+
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+
+public class GreaterThanOrEqualsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new GreaterThanOrEqualsDescriptor();
+ }
+ };
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.GE;
+ }
+
+ @Override
+ public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) throws AlgebricksException {
+ return new IScalarEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+ return new AbstractComparisonEvaluator(args[0], args[1], ctx) {
+
+ @Override
+ protected boolean getComparisonResult(int r) {
+ return r >= 0;
+ }
+
+ @Override
+ protected boolean isTotallyOrderable() {
+ return true;
+ }
+ };
+ }
+
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/LessThanDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/LessThanDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/LessThanDescriptor.java
new file mode 100644
index 0000000..d375a61
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/LessThanDescriptor.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.evaluators.comparisons;
+
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+
+public class LessThanDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new LessThanDescriptor();
+ }
+ };
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.LT;
+ }
+
+ @Override
+ public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) throws AlgebricksException {
+ return new IScalarEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+ return new AbstractComparisonEvaluator(args[0], args[1], ctx) {
+
+ @Override
+ protected boolean getComparisonResult(int r) {
+ return r < 0;
+ }
+
+ @Override
+ protected boolean isTotallyOrderable() {
+ return true;
+ }
+ };
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/LessThanOrEqualsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/LessThanOrEqualsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/LessThanOrEqualsDescriptor.java
new file mode 100644
index 0000000..4bcaa5b
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/LessThanOrEqualsDescriptor.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.evaluators.comparisons;
+
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+
+public class LessThanOrEqualsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new LessThanOrEqualsDescriptor();
+ }
+ };
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.LE;
+ }
+
+ @Override
+ public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) throws AlgebricksException {
+ return new IScalarEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+ return new AbstractComparisonEvaluator(args[0], args[1], ctx) {
+
+ @Override
+ protected boolean getComparisonResult(int r) {
+ return r <= 0;
+ }
+
+ @Override
+ protected boolean isTotallyOrderable() {
+ return true;
+ }
+ };
+ }
+
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/NotEqualsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/NotEqualsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/NotEqualsDescriptor.java
new file mode 100644
index 0000000..11ee60f
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/NotEqualsDescriptor.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.evaluators.comparisons;
+
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+
+public class NotEqualsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new NotEqualsDescriptor();
+ }
+ };
+
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.NEQ;
+ }
+
+ @Override
+ public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) throws AlgebricksException {
+ return new IScalarEvaluatorFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+ return new AbstractComparisonEvaluator(args[0], args[1], ctx) {
+
+ @Override
+ protected boolean getComparisonResult(int r) {
+ return r != 0;
+ }
+
+ @Override
+ protected boolean isTotallyOrderable() {
+ return false;
+ }
+ };
+ }
+
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABinaryHexStringConstructorDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABinaryHexStringConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABinaryHexStringConstructorDescriptor.java
index 422f325..74f4b65 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABinaryHexStringConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABinaryHexStringConstructorDescriptor.java
@@ -22,20 +22,16 @@ package org.apache.asterix.runtime.evaluators.constructors;
import java.io.DataOutput;
import java.io.IOException;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -80,10 +76,6 @@ public class ABinaryHexStringConstructorDescriptor extends AbstractScalarFunctio
private IValueParser byteArrayParser;
private UTF8StringPointable utf8Ptr = new UTF8StringPointable();
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
public ABinaryConstructorEvaluator(IScalarEvaluatorFactory copyEvaluatorFactory,
IValueParserFactory valueParserFactory, IHyracksTaskContext context) throws AlgebricksException {
eval = copyEvaluatorFactory.createScalarEvaluator(context);
@@ -99,11 +91,7 @@ public class ABinaryHexStringConstructorDescriptor extends AbstractScalarFunctio
int len = inputArg.getLength();
ATypeTag tt = ATypeTag.VALUE_TYPE_MAPPING[binary[startOffset]];
- if (tt == ATypeTag.NULL) {
- resultStorage.reset();
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- } else if (tt == ATypeTag.BINARY) {
+ if (tt == ATypeTag.BINARY) {
result.set(inputArg);
} else if (tt == ATypeTag.STRING) {
resultStorage.reset();
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java
index 0e41f4a..85ecb75 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java
@@ -24,7 +24,6 @@ import java.io.IOException;
import org.apache.asterix.formats.nontagged.AqlBinaryComparatorFactoryProvider;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ABoolean;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -73,9 +72,6 @@ public class ABooleanConstructorDescriptor extends AbstractScalarFunctionDynamic
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ABoolean> booleanSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ABOOLEAN);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -100,12 +96,9 @@ public class ABooleanConstructorDescriptor extends AbstractScalarFunctionDynamic
} else {
throw new AlgebricksException(errorMessage);
}
- } else if (serString[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
- result.set(resultStorage);
} catch (IOException e1) {
throw new AlgebricksException(errorMessage);
}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java
index 708b027..319ab0e 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java
@@ -25,7 +25,6 @@ import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ACircle;
import org.apache.asterix.om.base.AMutableCircle;
import org.apache.asterix.om.base.AMutablePoint;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -72,9 +71,6 @@ public class ACircleConstructorDescriptor extends AbstractScalarFunctionDynamicD
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ACircle> circleSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ACIRCLE);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@@ -97,8 +93,6 @@ public class ACircleConstructorDescriptor extends AbstractScalarFunctionDynamicD
Double.parseDouble(s.substring(commaIndex + 1, spaceIndex)));
aCircle.setValue(aPoint, Double.parseDouble(s.substring(spaceIndex + 1, s.length())));
circleSerde.serialize(aCircle, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
index d306159..06b9948 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
@@ -24,7 +24,6 @@ import java.io.IOException;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADate;
import org.apache.asterix.om.base.AMutableDate;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.ADateParserFactory;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
@@ -72,9 +71,6 @@ public class ADateConstructorDescriptor extends AbstractScalarFunctionDynamicDes
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADate> dateSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATE);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@@ -109,24 +105,19 @@ public class ADateConstructorDescriptor extends AbstractScalarFunctionDynamicDes
long chrononTimeInMs = ADateParserFactory.parseDatePart(serString, startOffset,
endOffset - startOffset + 1);
-
short temp = 0;
if (chrononTimeInMs < 0
&& chrononTimeInMs % GregorianCalendarSystem.CHRONON_OF_DAY != 0) {
temp = 1;
}
-
aDate.setValue((int) (chrononTimeInMs / GregorianCalendarSystem.CHRONON_OF_DAY) - temp);
-
dateSerde.serialize(aDate, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
result.set(resultStorage);
- } catch (IOException e1) {
- throw new AlgebricksException(errorMessage);
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
}
}
};
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
index a538b2b..63f3461 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
@@ -24,7 +24,6 @@ import java.io.IOException;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADateTime;
import org.apache.asterix.om.base.AMutableDateTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.ADateParserFactory;
import org.apache.asterix.om.base.temporal.ATimeParserFactory;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
@@ -71,9 +70,6 @@ public class ADateTimeConstructorDescriptor extends AbstractScalarFunctionDynami
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATETIME);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -115,8 +111,6 @@ public class ADateTimeConstructorDescriptor extends AbstractScalarFunctionDynami
aDateTime.setValue(chrononTimeInMs);
datetimeSerde.serialize(aDateTime, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}