[ASTERIXDB-2516][RT] Make asterix types comparators singleton and stateless
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
Avoid creating asterix types comparators when they could be made singleton.
Change-Id: I65972162ed2cf14d1f2654dbf00442aa35dd5c01
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3255
Reviewed-by: Michael Blow <mblow@apache.org>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/io/PersistedResourceRegistry.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/io/PersistedResourceRegistry.java
index 77af1c5..f02fdba 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/io/PersistedResourceRegistry.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/io/PersistedResourceRegistry.java
@@ -50,7 +50,6 @@
import org.apache.asterix.dataflow.data.nontagged.comparators.BooleanBinaryComparatorFactory;
import org.apache.asterix.dataflow.data.nontagged.comparators.ListItemBinaryComparatorFactory;
import org.apache.asterix.dataflow.data.nontagged.comparators.LongBinaryComparatorFactory;
-import org.apache.asterix.dataflow.data.nontagged.comparators.RawBinaryComparatorFactory;
import org.apache.asterix.dataflow.data.nontagged.valueproviders.PrimitiveValueProviderFactory;
import org.apache.asterix.formats.nontagged.AnyBinaryComparatorFactory;
import org.apache.asterix.formats.nontagged.OrderedBinaryComparatorFactory;
@@ -72,6 +71,7 @@
import org.apache.hyracks.api.io.IJsonSerializable;
import org.apache.hyracks.api.io.IPersistedResourceRegistry;
import org.apache.hyracks.data.std.accessors.PointableBinaryComparatorFactory;
+import org.apache.hyracks.data.std.accessors.RawBinaryComparatorFactory;
import org.apache.hyracks.data.std.primitive.BooleanPointable;
import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
import org.apache.hyracks.data.std.primitive.BytePointable;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ACirclePartialBinaryComparatorFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ACirclePartialBinaryComparatorFactory.java
index 7eeb05d..dcc531d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ACirclePartialBinaryComparatorFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ACirclePartialBinaryComparatorFactory.java
@@ -32,60 +32,43 @@
public class ACirclePartialBinaryComparatorFactory implements IBinaryComparatorFactory {
private static final long serialVersionUID = 1L;
-
public static final ACirclePartialBinaryComparatorFactory INSTANCE = new ACirclePartialBinaryComparatorFactory();
private ACirclePartialBinaryComparatorFactory() {
-
}
- /* (non-Javadoc)
- * @see org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
- */
@Override
public IBinaryComparator createBinaryComparator() {
- return new IBinaryComparator() {
+ return ACirclePartialBinaryComparatorFactory::compare;
+ }
- @Override
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
- try {
- // center.x
- int c = Double
- .compare(
- ADoubleSerializerDeserializer.getDouble(
- b1, s1 + ACircleSerializerDeserializer
- .getCenterPointCoordinateOffset(Coordinate.X) - 1),
- ADoubleSerializerDeserializer.getDouble(b2, s2
- + ACircleSerializerDeserializer.getCenterPointCoordinateOffset(Coordinate.X)
- - 1));
- if (c == 0) {
- // center.y
- c = Double
- .compare(
- ADoubleSerializerDeserializer.getDouble(b1,
- s1 + ACircleSerializerDeserializer
- .getCenterPointCoordinateOffset(Coordinate.Y) - 1),
- ADoubleSerializerDeserializer
- .getDouble(
- b2, s2
- + ACircleSerializerDeserializer
- .getCenterPointCoordinateOffset(Coordinate.Y)
- - 1));
- if (c == 0) {
- // radius
- return Double.compare(
- ADoubleSerializerDeserializer.getDouble(b1,
- s1 + ACircleSerializerDeserializer.getRadiusOffset() - 1),
- ADoubleSerializerDeserializer.getDouble(b2,
- s2 + ACircleSerializerDeserializer.getRadiusOffset() - 1));
- }
- }
- return c;
- } catch (HyracksDataException hex) {
- throw new IllegalStateException(hex);
- }
+ @SuppressWarnings("squid:S1172") // unused parameter
+ public static int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) throws HyracksDataException {
+ // center.x
+ int c = Double.compare(
+ ADoubleSerializerDeserializer.getDouble(b1,
+ s1 + ACircleSerializerDeserializer.getCenterPointCoordinateOffset(Coordinate.X) - 1),
+ ADoubleSerializerDeserializer.getDouble(b2,
+ s2 + ACircleSerializerDeserializer.getCenterPointCoordinateOffset(Coordinate.X) - 1));
+ if (c == 0) {
+ // center.y
+ c = Double
+ .compare(
+ ADoubleSerializerDeserializer.getDouble(
+ b1, s1 + ACircleSerializerDeserializer.getCenterPointCoordinateOffset(Coordinate.Y)
+ - 1),
+ ADoubleSerializerDeserializer.getDouble(b2, s2
+ + ACircleSerializerDeserializer.getCenterPointCoordinateOffset(Coordinate.Y) - 1));
+ if (c == 0) {
+ // radius
+ return Double.compare(
+ ADoubleSerializerDeserializer.getDouble(b1,
+ s1 + ACircleSerializerDeserializer.getRadiusOffset() - 1),
+ ADoubleSerializerDeserializer.getDouble(b2,
+ s2 + ACircleSerializerDeserializer.getRadiusOffset() - 1));
}
- };
+ }
+ return c;
}
@Override
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ADurationPartialBinaryComparatorFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ADurationPartialBinaryComparatorFactory.java
index 4f0e0ef..f64a864 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ADurationPartialBinaryComparatorFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ADurationPartialBinaryComparatorFactory.java
@@ -32,38 +32,30 @@
public class ADurationPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
private static final long serialVersionUID = 1L;
-
public static final ADurationPartialBinaryComparatorFactory INSTANCE =
new ADurationPartialBinaryComparatorFactory();
private ADurationPartialBinaryComparatorFactory() {
-
}
- /* (non-Javadoc)
- * @see org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
- */
@Override
public IBinaryComparator createBinaryComparator() {
- return new IBinaryComparator() {
+ return ADurationPartialBinaryComparatorFactory::compare;
+ }
- @Override
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
- int c = Integer.compare(
- AInt32SerializerDeserializer.getInt(b1,
- s1 + ADurationSerializerDeserializer.getYearMonthOffset()),
- AInt32SerializerDeserializer.getInt(b2,
- s2 + ADurationSerializerDeserializer.getYearMonthOffset()));
- if (c == 0) {
- return Double.compare(
- ADoubleSerializerDeserializer.getDouble(b1,
- s1 + ADurationSerializerDeserializer.getDayTimeOffset()),
- ADoubleSerializerDeserializer.getDouble(b2,
- s2 + ADurationSerializerDeserializer.getDayTimeOffset()));
- }
- return c;
- }
- };
+ @SuppressWarnings("squid:S1172") // unused parameter
+ public static int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+ int c = Integer.compare(
+ AInt32SerializerDeserializer.getInt(b1, s1 + ADurationSerializerDeserializer.getYearMonthOffset()),
+ AInt32SerializerDeserializer.getInt(b2, s2 + ADurationSerializerDeserializer.getYearMonthOffset()));
+ if (c == 0) {
+ return Double.compare(
+ ADoubleSerializerDeserializer.getDouble(b1,
+ s1 + ADurationSerializerDeserializer.getDayTimeOffset()),
+ ADoubleSerializerDeserializer.getDouble(b2,
+ s2 + ADurationSerializerDeserializer.getDayTimeOffset()));
+ }
+ return c;
}
@Override
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalAscPartialBinaryComparatorFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalAscPartialBinaryComparatorFactory.java
index 3b086f2..7b7f7d3 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalAscPartialBinaryComparatorFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalAscPartialBinaryComparatorFactory.java
@@ -27,42 +27,37 @@
import com.fasterxml.jackson.databind.JsonNode;
+/**
+ * The ascending interval comparator sorts intervals first by start point, then by end point. If the intervals have
+ * the same point values, the final comparison orders the intervals by type (datetime, date, time).
+ */
public class AIntervalAscPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
private static final long serialVersionUID = 1L;
-
public static final AIntervalAscPartialBinaryComparatorFactory INSTANCE =
new AIntervalAscPartialBinaryComparatorFactory();
private AIntervalAscPartialBinaryComparatorFactory() {
-
}
- /* (non-Javadoc)
- * @see org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
- */
@Override
public IBinaryComparator createBinaryComparator() {
- return new IBinaryComparator() {
+ return AIntervalAscPartialBinaryComparatorFactory::compare;
+ }
- @Override
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
- // The ascending interval comparator sorts intervals first by start point, then by end point.
- // If the interval have the same point values, the final comparison orders the intervals by type
- // (datetime, date, time).
- int c = Long.compare(AIntervalSerializerDeserializer.getIntervalStart(b1, s1),
- AIntervalSerializerDeserializer.getIntervalStart(b2, s2));
- if (c == 0) {
- c = Long.compare(AIntervalSerializerDeserializer.getIntervalEnd(b1, s1),
- AIntervalSerializerDeserializer.getIntervalEnd(b2, s2));
- if (c == 0) {
- c = Byte.compare(AIntervalSerializerDeserializer.getIntervalTimeType(b1, s1),
- AIntervalSerializerDeserializer.getIntervalTimeType(b2, s2));
- }
- }
- return c;
+ @SuppressWarnings("squid:S1172") // unused parameter
+ public static int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+ int c = Long.compare(AIntervalSerializerDeserializer.getIntervalStart(b1, s1),
+ AIntervalSerializerDeserializer.getIntervalStart(b2, s2));
+ if (c == 0) {
+ c = Long.compare(AIntervalSerializerDeserializer.getIntervalEnd(b1, s1),
+ AIntervalSerializerDeserializer.getIntervalEnd(b2, s2));
+ if (c == 0) {
+ c = Byte.compare(AIntervalSerializerDeserializer.getIntervalTimeType(b1, s1),
+ AIntervalSerializerDeserializer.getIntervalTimeType(b2, s2));
}
- };
+ }
+ return c;
}
@Override
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalDescPartialBinaryComparatorFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalDescPartialBinaryComparatorFactory.java
index 6ef58fd..f30a98c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalDescPartialBinaryComparatorFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AIntervalDescPartialBinaryComparatorFactory.java
@@ -27,43 +27,38 @@
import com.fasterxml.jackson.databind.JsonNode;
+/**
+ * The descending interval comparator sorts intervals first by end point, then by start point. If the intervals have
+ * the same point values, the final comparison orders the intervals by type (time, date, datetime).
+ */
public class AIntervalDescPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
private static final long serialVersionUID = 1L;
-
public static final AIntervalDescPartialBinaryComparatorFactory INSTANCE =
new AIntervalDescPartialBinaryComparatorFactory();
private AIntervalDescPartialBinaryComparatorFactory() {
-
}
- /* (non-Javadoc)
- * @see org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
- */
@Override
public IBinaryComparator createBinaryComparator() {
- return new IBinaryComparator() {
+ return AIntervalDescPartialBinaryComparatorFactory::compare;
+ }
- @Override
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
- // The descending interval comparator sorts intervals first by end point, then by start point.
- // If the interval have the same point values, the final comparison orders the intervals by type
- // (time, date, datetime).
- int c = Long.compare(AIntervalSerializerDeserializer.getIntervalEnd(b1, s1),
- AIntervalSerializerDeserializer.getIntervalEnd(b2, s2));
- if (c == 0) {
- c = Long.compare(AIntervalSerializerDeserializer.getIntervalStart(b1, s1),
- AIntervalSerializerDeserializer.getIntervalStart(b2, s2));
- if (c == 0) {
- c = Byte.compare(AIntervalSerializerDeserializer.getIntervalTimeType(b1, s1),
- AIntervalSerializerDeserializer.getIntervalTimeType(b2, s2));
- }
- }
- // Since the comparisons are based on ascending order, the result is reversed.
- return -c;
+ @SuppressWarnings("squid:S1172") // unused parameter
+ public static int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+ int c = Long.compare(AIntervalSerializerDeserializer.getIntervalEnd(b1, s1),
+ AIntervalSerializerDeserializer.getIntervalEnd(b2, s2));
+ if (c == 0) {
+ c = Long.compare(AIntervalSerializerDeserializer.getIntervalStart(b1, s1),
+ AIntervalSerializerDeserializer.getIntervalStart(b2, s2));
+ if (c == 0) {
+ c = Byte.compare(AIntervalSerializerDeserializer.getIntervalTimeType(b1, s1),
+ AIntervalSerializerDeserializer.getIntervalTimeType(b2, s2));
}
- };
+ }
+ // since the comparisons are based on ascending order, the result is reversed.
+ return -c;
}
@Override
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ALinePartialBinaryComparatorFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ALinePartialBinaryComparatorFactory.java
index 5227ebc..a5f80a6 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ALinePartialBinaryComparatorFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ALinePartialBinaryComparatorFactory.java
@@ -32,76 +32,50 @@
public class ALinePartialBinaryComparatorFactory implements IBinaryComparatorFactory {
private static final long serialVersionUID = 1L;
-
public static final ALinePartialBinaryComparatorFactory INSTANCE = new ALinePartialBinaryComparatorFactory();
private ALinePartialBinaryComparatorFactory() {
-
}
- /* (non-Javadoc)
- * @see org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
- */
@Override
public IBinaryComparator createBinaryComparator() {
- return new IBinaryComparator() {
+ return ALinePartialBinaryComparatorFactory::compare;
+ }
- @Override
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
- try {
- int c = Double
+ @SuppressWarnings("squid:S1172") // unused parameter
+ public static int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) throws HyracksDataException {
+ int c = Double.compare(
+ ADoubleSerializerDeserializer.getDouble(b1,
+ s1 + ALineSerializerDeserializer.getStartPointCoordinateOffset(Coordinate.X) - 1),
+ ADoubleSerializerDeserializer.getDouble(b2,
+ s2 + ALineSerializerDeserializer.getStartPointCoordinateOffset(Coordinate.X) - 1));
+ if (c == 0) {
+ c = Double.compare(
+ ADoubleSerializerDeserializer.getDouble(b1,
+ s1 + ALineSerializerDeserializer.getStartPointCoordinateOffset(Coordinate.Y) - 1),
+ ADoubleSerializerDeserializer.getDouble(b2,
+ s2 + ALineSerializerDeserializer.getStartPointCoordinateOffset(Coordinate.Y) - 1));
+ if (c == 0) {
+ c = Double
+ .compare(
+ ADoubleSerializerDeserializer.getDouble(
+ b1, s1 + ALineSerializerDeserializer.getEndPointCoordinateOffset(Coordinate.X)
+ - 1),
+ ADoubleSerializerDeserializer.getDouble(b2, s2
+ + ALineSerializerDeserializer.getEndPointCoordinateOffset(Coordinate.X) - 1));
+ if (c == 0) {
+ return Double
.compare(
ADoubleSerializerDeserializer.getDouble(
b1, s1 + ALineSerializerDeserializer
- .getStartPointCoordinateOffset(Coordinate.X) - 1),
+ .getEndPointCoordinateOffset(Coordinate.Y) - 1),
ADoubleSerializerDeserializer.getDouble(b2,
- s2 + ALineSerializerDeserializer.getStartPointCoordinateOffset(Coordinate.X)
+ s2 + ALineSerializerDeserializer.getEndPointCoordinateOffset(Coordinate.Y)
- 1));
- if (c == 0) {
- c = Double
- .compare(
- ADoubleSerializerDeserializer.getDouble(b1,
- s1 + ALineSerializerDeserializer
- .getStartPointCoordinateOffset(Coordinate.Y) - 1),
- ADoubleSerializerDeserializer
- .getDouble(
- b2, s2
- + ALineSerializerDeserializer
- .getStartPointCoordinateOffset(Coordinate.Y)
- - 1));
- if (c == 0) {
- c = Double
- .compare(
- ADoubleSerializerDeserializer.getDouble(b1,
- s1 + ALineSerializerDeserializer
- .getEndPointCoordinateOffset(Coordinate.X) - 1),
- ADoubleSerializerDeserializer
- .getDouble(
- b2, s2
- + ALineSerializerDeserializer
- .getEndPointCoordinateOffset(Coordinate.X)
- - 1));
- if (c == 0) {
- return Double
- .compare(
- ADoubleSerializerDeserializer
- .getDouble(b1,
- s1 + ALineSerializerDeserializer
- .getEndPointCoordinateOffset(Coordinate.Y) - 1),
- ADoubleSerializerDeserializer
- .getDouble(b2,
- s2 + ALineSerializerDeserializer
- .getEndPointCoordinateOffset(Coordinate.Y)
- - 1));
- }
- }
- }
- return c;
- } catch (HyracksDataException hex) {
- throw new IllegalStateException(hex);
}
}
- };
+ }
+ return c;
}
@Override
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/APoint3DPartialBinaryComparatorFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/APoint3DPartialBinaryComparatorFactory.java
index 58baef5..7f04c40 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/APoint3DPartialBinaryComparatorFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/APoint3DPartialBinaryComparatorFactory.java
@@ -24,7 +24,6 @@
import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.api.exceptions.HyracksException;
import org.apache.hyracks.api.io.IJsonSerializable;
import org.apache.hyracks.api.io.IPersistedResourceRegistry;
@@ -33,56 +32,38 @@
public class APoint3DPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
private static final long serialVersionUID = 1L;
-
public static final APoint3DPartialBinaryComparatorFactory INSTANCE = new APoint3DPartialBinaryComparatorFactory();
private APoint3DPartialBinaryComparatorFactory() {
-
}
- /* (non-Javadoc)
- * @see org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
- */
@Override
public IBinaryComparator createBinaryComparator() {
- return new IBinaryComparator() {
+ return APoint3DPartialBinaryComparatorFactory::compare;
+ }
- @Override
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
- try {
- int c = Double
- .compare(
- ADoubleSerializerDeserializer
- .getDouble(b1,
- s1 + APoint3DSerializerDeserializer
- .getCoordinateOffset(Coordinate.X) - 1),
- ADoubleSerializerDeserializer.getDouble(b2,
- s2 + APoint3DSerializerDeserializer.getCoordinateOffset(Coordinate.X) - 1));
- if (c == 0) {
- c = Double
- .compare(
- ADoubleSerializerDeserializer.getDouble(
- b1, s1 + APoint3DSerializerDeserializer
- .getCoordinateOffset(Coordinate.Y) - 1),
- ADoubleSerializerDeserializer.getDouble(b2,
- s2 + APoint3DSerializerDeserializer.getCoordinateOffset(Coordinate.Y)
- - 1));
- if (c == 0) {
- return Double.compare(
- ADoubleSerializerDeserializer
- .getDouble(b1,
- s1 + APoint3DSerializerDeserializer
- .getCoordinateOffset(Coordinate.Z) - 1),
- ADoubleSerializerDeserializer.getDouble(b2,
- s2 + APoint3DSerializerDeserializer.getCoordinateOffset(Coordinate.Z) - 1));
- }
- }
- return c;
- } catch (HyracksException hex) {
- throw new IllegalStateException(hex);
- }
+ @SuppressWarnings("squid:S1172") // unused parameter
+ public static int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) throws HyracksDataException {
+ int c = Double.compare(
+ ADoubleSerializerDeserializer.getDouble(b1,
+ s1 + APoint3DSerializerDeserializer.getCoordinateOffset(Coordinate.X) - 1),
+ ADoubleSerializerDeserializer.getDouble(b2,
+ s2 + APoint3DSerializerDeserializer.getCoordinateOffset(Coordinate.X) - 1));
+ if (c == 0) {
+ c = Double.compare(
+ ADoubleSerializerDeserializer.getDouble(b1,
+ s1 + APoint3DSerializerDeserializer.getCoordinateOffset(Coordinate.Y) - 1),
+ ADoubleSerializerDeserializer.getDouble(b2,
+ s2 + APoint3DSerializerDeserializer.getCoordinateOffset(Coordinate.Y) - 1));
+ if (c == 0) {
+ return Double.compare(
+ ADoubleSerializerDeserializer.getDouble(b1,
+ s1 + APoint3DSerializerDeserializer.getCoordinateOffset(Coordinate.Z) - 1),
+ ADoubleSerializerDeserializer.getDouble(b2,
+ s2 + APoint3DSerializerDeserializer.getCoordinateOffset(Coordinate.Z) - 1));
}
- };
+ }
+ return c;
}
@Override
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/APointPartialBinaryComparatorFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/APointPartialBinaryComparatorFactory.java
index 920545f..0e209cf 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/APointPartialBinaryComparatorFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/APointPartialBinaryComparatorFactory.java
@@ -32,40 +32,31 @@
public class APointPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
private static final long serialVersionUID = 1L;
-
- public final static APointPartialBinaryComparatorFactory INSTANCE = new APointPartialBinaryComparatorFactory();
+ public static final APointPartialBinaryComparatorFactory INSTANCE = new APointPartialBinaryComparatorFactory();
private APointPartialBinaryComparatorFactory() {
-
}
@Override
public IBinaryComparator createBinaryComparator() {
- return new IBinaryComparator() {
+ return APointPartialBinaryComparatorFactory::compare;
+ }
- @Override
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
- try {
- int c = Double.compare(
- ADoubleSerializerDeserializer.getDouble(b1,
- s1 + APointSerializerDeserializer.getCoordinateOffset(Coordinate.X) - 1),
- ADoubleSerializerDeserializer.getDouble(b2,
- s2 + APointSerializerDeserializer.getCoordinateOffset(Coordinate.X) - 1));
- if (c == 0) {
- return Double
- .compare(
- ADoubleSerializerDeserializer.getDouble(
- b1, s1 + APointSerializerDeserializer.getCoordinateOffset(Coordinate.Y)
- - 1),
- ADoubleSerializerDeserializer.getDouble(b2, s2
- + APointSerializerDeserializer.getCoordinateOffset(Coordinate.Y) - 1));
- }
- return c;
- } catch (HyracksDataException hex) {
- throw new IllegalStateException(hex);
- }
- }
- };
+ @SuppressWarnings("squid:S1172") // unused parameter
+ public static int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) throws HyracksDataException {
+ int c = Double.compare(
+ ADoubleSerializerDeserializer.getDouble(b1,
+ s1 + APointSerializerDeserializer.getCoordinateOffset(Coordinate.X) - 1),
+ ADoubleSerializerDeserializer.getDouble(b2,
+ s2 + APointSerializerDeserializer.getCoordinateOffset(Coordinate.X) - 1));
+ if (c == 0) {
+ return Double.compare(
+ ADoubleSerializerDeserializer.getDouble(b1,
+ s1 + APointSerializerDeserializer.getCoordinateOffset(Coordinate.Y) - 1),
+ ADoubleSerializerDeserializer.getDouble(b2,
+ s2 + APointSerializerDeserializer.getCoordinateOffset(Coordinate.Y) - 1));
+ }
+ return c;
}
@Override
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/APolygonPartialBinaryComparatorFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/APolygonPartialBinaryComparatorFactory.java
index 3879072..9bc15f5 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/APolygonPartialBinaryComparatorFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/APolygonPartialBinaryComparatorFactory.java
@@ -33,64 +33,46 @@
public class APolygonPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
private static final long serialVersionUID = 1L;
-
- public final static APolygonPartialBinaryComparatorFactory INSTANCE = new APolygonPartialBinaryComparatorFactory();
+ public static final APolygonPartialBinaryComparatorFactory INSTANCE = new APolygonPartialBinaryComparatorFactory();
private APolygonPartialBinaryComparatorFactory() {
-
}
- /* (non-Javadoc)
- * @see org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory#createBinaryComparator()
- */
@Override
public IBinaryComparator createBinaryComparator() {
- return new IBinaryComparator() {
+ return APolygonPartialBinaryComparatorFactory::compare;
+ }
- @Override
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
- try {
- short pointCount1 = AInt16SerializerDeserializer.getShort(b1,
- s1 + APolygonSerializerDeserializer.getNumberOfPointsOffset() - 1);
- int c = Short.compare(pointCount1, AInt16SerializerDeserializer.getShort(b2,
- s2 + APolygonSerializerDeserializer.getNumberOfPointsOffset() - 1));
-
- if (c == 0) {
- int ci = 0;
- for (int i = 0; i < pointCount1; i++) {
- ci = Double
- .compare(
- DoublePointable.getDouble(b1,
- s1 + APolygonSerializerDeserializer.getCoordinateOffset(i,
- Coordinate.X) - 1),
- DoublePointable.getDouble(b2, s1 + APolygonSerializerDeserializer
- .getCoordinateOffset(i, Coordinate.X) - 1));
- if (ci == 0) {
- ci = Double
- .compare(
- DoublePointable.getDouble(b1,
- s1 + APolygonSerializerDeserializer.getCoordinateOffset(i,
- Coordinate.Y) - 1),
- DoublePointable
- .getDouble(
- b2, s1
- + APolygonSerializerDeserializer
- .getCoordinateOffset(i, Coordinate.Y)
- - 1));
- if (ci == 0) {
- continue;
- }
- }
- return ci;
- }
+ @SuppressWarnings("squid:S1172") // unused parameter
+ public static int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) throws HyracksDataException {
+ short pointCount1 = AInt16SerializerDeserializer.getShort(b1,
+ s1 + APolygonSerializerDeserializer.getNumberOfPointsOffset() - 1);
+ int c = Short.compare(pointCount1, AInt16SerializerDeserializer.getShort(b2,
+ s2 + APolygonSerializerDeserializer.getNumberOfPointsOffset() - 1));
+ if (c == 0) {
+ int ci;
+ for (int i = 0; i < pointCount1; i++) {
+ ci = Double.compare(
+ DoublePointable.getDouble(b1,
+ s1 + APolygonSerializerDeserializer.getCoordinateOffset(i, Coordinate.X) - 1),
+ DoublePointable.getDouble(b2,
+ s1 + APolygonSerializerDeserializer.getCoordinateOffset(i, Coordinate.X) - 1));
+ if (ci == 0) {
+ ci = Double
+ .compare(
+ DoublePointable.getDouble(
+ b1, s1 + APolygonSerializerDeserializer.getCoordinateOffset(i, Coordinate.Y)
+ - 1),
+ DoublePointable.getDouble(b2, s1
+ + APolygonSerializerDeserializer.getCoordinateOffset(i, Coordinate.Y) - 1));
+ if (ci == 0) {
+ continue;
}
-
- return c;
- } catch (HyracksDataException hex) {
- throw new IllegalStateException(hex);
}
+ return ci;
}
- };
+ }
+ return c;
}
@Override
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ARectanglePartialBinaryComparatorFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ARectanglePartialBinaryComparatorFactory.java
index 7c0301e..ddd613b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ARectanglePartialBinaryComparatorFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ARectanglePartialBinaryComparatorFactory.java
@@ -28,9 +28,9 @@
import com.fasterxml.jackson.databind.JsonNode;
public class ARectanglePartialBinaryComparatorFactory implements IBinaryComparatorFactory {
- private static final long serialVersionUID = 1L;
- public final static ARectanglePartialBinaryComparatorFactory INSTANCE =
+ private static final long serialVersionUID = 1L;
+ public static final ARectanglePartialBinaryComparatorFactory INSTANCE =
new ARectanglePartialBinaryComparatorFactory();
private ARectanglePartialBinaryComparatorFactory() {
@@ -38,34 +38,32 @@
@Override
public IBinaryComparator createBinaryComparator() {
+ return ARectanglePartialBinaryComparatorFactory::compare;
+ }
- return new IBinaryComparator() {
-
- @Override
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
- int c1 = Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1),
- ADoubleSerializerDeserializer.getDouble(b2, s2));
- if (c1 == 0) {
- int c2 = Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1 + 8),
- ADoubleSerializerDeserializer.getDouble(b2, s2 + 8));
- if (c2 == 0) {
- int c3 = Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1 + 16),
- ADoubleSerializerDeserializer.getDouble(b2, s2 + 16));
- if (c3 == 0) {
- int c4 = Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1 + 24),
- ADoubleSerializerDeserializer.getDouble(b2, s2 + 24));
- return c4;
- } else {
- return c3;
- }
- } else {
- return c2;
- }
+ @SuppressWarnings("squid:S1172") // unused parameter
+ public static int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+ int c1 = Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1),
+ ADoubleSerializerDeserializer.getDouble(b2, s2));
+ if (c1 == 0) {
+ int c2 = Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1 + 8),
+ ADoubleSerializerDeserializer.getDouble(b2, s2 + 8));
+ if (c2 == 0) {
+ int c3 = Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1 + 16),
+ ADoubleSerializerDeserializer.getDouble(b2, s2 + 16));
+ if (c3 == 0) {
+ int c4 = Double.compare(ADoubleSerializerDeserializer.getDouble(b1, s1 + 24),
+ ADoubleSerializerDeserializer.getDouble(b2, s2 + 24));
+ return c4;
} else {
- return c1;
+ return c3;
}
+ } else {
+ return c2;
}
- };
+ } else {
+ return c1;
+ }
}
@Override
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AUUIDPartialBinaryComparatorFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AUUIDPartialBinaryComparatorFactory.java
index 2276fe3..01f2537 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AUUIDPartialBinaryComparatorFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AUUIDPartialBinaryComparatorFactory.java
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.asterix.dataflow.data.nontagged.comparators;
import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
@@ -31,23 +30,21 @@
public class AUUIDPartialBinaryComparatorFactory implements IBinaryComparatorFactory {
private static final long serialVersionUID = 1L;
-
public static final AUUIDPartialBinaryComparatorFactory INSTANCE = new AUUIDPartialBinaryComparatorFactory();
@Override
public IBinaryComparator createBinaryComparator() {
- return new IBinaryComparator() {
+ return AUUIDPartialBinaryComparatorFactory::compare;
+ }
- @Override
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
- int msbCompare = Long.compare(LongPointable.getLong(b1, s1), LongPointable.getLong(b2, s2));
- if (msbCompare == 0) {
- return Long.compare(LongPointable.getLong(b1, s1 + 8), LongPointable.getLong(b2, s2 + 8));
- } else {
- return msbCompare;
- }
- }
- };
+ @SuppressWarnings("squid:S1172") // unused parameter
+ public static int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+ int msbCompare = Long.compare(LongPointable.getLong(b1, s1), LongPointable.getLong(b2, s2));
+ if (msbCompare == 0) {
+ return Long.compare(LongPointable.getLong(b1, s1 + 8), LongPointable.getLong(b2, s2 + 8));
+ } else {
+ return msbCompare;
+ }
}
@Override
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AbstractAGenericBinaryComparator.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AbstractAGenericBinaryComparator.java
index 6d7ad76..da51bc3 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AbstractAGenericBinaryComparator.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AbstractAGenericBinaryComparator.java
@@ -44,6 +44,7 @@
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.accessors.RawBinaryComparatorFactory;
import org.apache.hyracks.data.std.api.IMutableValueStorage;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/BooleanBinaryComparatorFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/BooleanBinaryComparatorFactory.java
index 7374951..23e131f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/BooleanBinaryComparatorFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/BooleanBinaryComparatorFactory.java
@@ -27,10 +27,10 @@
import com.fasterxml.jackson.databind.JsonNode;
+// TODO(ali): move to Hyracks
public class BooleanBinaryComparatorFactory implements IBinaryComparatorFactory {
private static final long serialVersionUID = 1L;
-
public static final BooleanBinaryComparatorFactory INSTANCE = new BooleanBinaryComparatorFactory();
private BooleanBinaryComparatorFactory() {
@@ -38,19 +38,13 @@
@Override
public IBinaryComparator createBinaryComparator() {
- return new IBinaryComparator() {
+ return BooleanBinaryComparatorFactory::compare;
+ }
- @Override
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
- boolean v1 = ABooleanSerializerDeserializer.getBoolean(b1, s1);
- boolean v2 = ABooleanSerializerDeserializer.getBoolean(b2, s2);
- if (v1) {
- return v2 ? 0 : 1;
- } else {
- return v2 ? -1 : 0;
- }
- }
- };
+ @SuppressWarnings("squid:S1172") // unused parameter
+ public static int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+ return Boolean.compare(ABooleanSerializerDeserializer.getBoolean(b1, s1),
+ ABooleanSerializerDeserializer.getBoolean(b2, s2));
}
@Override
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ListItemBinaryComparatorFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ListItemBinaryComparatorFactory.java
index 2db54c8..1799559 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ListItemBinaryComparatorFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ListItemBinaryComparatorFactory.java
@@ -27,6 +27,7 @@
import org.apache.hyracks.api.io.IJsonSerializable;
import org.apache.hyracks.api.io.IPersistedResourceRegistry;
import org.apache.hyracks.data.std.accessors.PointableBinaryComparatorFactory;
+import org.apache.hyracks.data.std.accessors.RawBinaryComparatorFactory;
import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
import org.apache.hyracks.data.std.primitive.DoublePointable;
import org.apache.hyracks.data.std.primitive.FloatPointable;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LongBinaryComparatorFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LongBinaryComparatorFactory.java
index 278a2e5..cbab346 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LongBinaryComparatorFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/LongBinaryComparatorFactory.java
@@ -27,10 +27,10 @@
import com.fasterxml.jackson.databind.JsonNode;
+// TODO(ali): move to Hyracks
public class LongBinaryComparatorFactory implements IBinaryComparatorFactory {
private static final long serialVersionUID = 1L;
-
public static final LongBinaryComparatorFactory INSTANCE = new LongBinaryComparatorFactory();
private LongBinaryComparatorFactory() {
@@ -38,15 +38,12 @@
@Override
public IBinaryComparator createBinaryComparator() {
- return new IBinaryComparator() {
+ return LongBinaryComparatorFactory::compare;
+ }
- @Override
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
- long v1 = AInt64SerializerDeserializer.getLong(b1, s1);
- long v2 = AInt64SerializerDeserializer.getLong(b2, s2);
- return v1 < v2 ? -1 : (v1 > v2 ? 1 : 0);
- }
- };
+ @SuppressWarnings("squid:S1172") // unused parameter
+ public static int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+ return Long.compare(AInt64SerializerDeserializer.getLong(b1, s1), AInt64SerializerDeserializer.getLong(b2, s2));
}
@Override
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/BinaryComparatorFactoryProvider.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/BinaryComparatorFactoryProvider.java
index 724c535..27588cd 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/BinaryComparatorFactoryProvider.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/BinaryComparatorFactoryProvider.java
@@ -33,12 +33,12 @@
import org.apache.asterix.dataflow.data.nontagged.comparators.ARectanglePartialBinaryComparatorFactory;
import org.apache.asterix.dataflow.data.nontagged.comparators.AUUIDPartialBinaryComparatorFactory;
import org.apache.asterix.dataflow.data.nontagged.comparators.BooleanBinaryComparatorFactory;
-import org.apache.asterix.dataflow.data.nontagged.comparators.RawBinaryComparatorFactory;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.IAType;
import org.apache.hyracks.algebricks.data.IBinaryComparatorFactoryProvider;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import org.apache.hyracks.data.std.accessors.PointableBinaryComparatorFactory;
+import org.apache.hyracks.data.std.accessors.RawBinaryComparatorFactory;
import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
import org.apache.hyracks.data.std.primitive.BytePointable;
import org.apache.hyracks.data.std.primitive.DoublePointable;
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/ComparisonHelper.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/ComparisonHelper.java
index 7080779..388a9d4 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/ComparisonHelper.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/ComparisonHelper.java
@@ -18,8 +18,6 @@
*/
package org.apache.asterix.runtime.evaluators.comparisons;
-import static org.apache.asterix.om.types.ATypeTag.TINYINT;
-
import java.io.Serializable;
import org.apache.asterix.dataflow.data.nontagged.comparators.ACirclePartialBinaryComparatorFactory;
@@ -31,6 +29,10 @@
import org.apache.asterix.dataflow.data.nontagged.comparators.APolygonPartialBinaryComparatorFactory;
import org.apache.asterix.dataflow.data.nontagged.comparators.ARectanglePartialBinaryComparatorFactory;
import org.apache.asterix.dataflow.data.nontagged.comparators.AUUIDPartialBinaryComparatorFactory;
+import org.apache.asterix.dataflow.data.nontagged.comparators.ComparatorUtil;
+import org.apache.asterix.dataflow.data.nontagged.comparators.LogicalComplexBinaryComparator;
+import org.apache.asterix.dataflow.data.nontagged.comparators.LogicalGenericBinaryComparator;
+import org.apache.asterix.dataflow.data.nontagged.comparators.LogicalScalarBinaryComparator;
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;
@@ -49,6 +51,11 @@
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
+/**
+ * @deprecated replaced by {@link LogicalGenericBinaryComparator}, {@link LogicalScalarBinaryComparator},
+ * {@link LogicalComplexBinaryComparator}, and {@link ComparatorUtil}.
+ */
+@Deprecated
public class ComparisonHelper implements Serializable {
private static final long serialVersionUID = 1L;
static final String COMPARISON = "comparison operations (>, >=, <, and <=)";
@@ -78,6 +85,11 @@
private final SourceLocation sourceLoc;
+ /**
+ * @deprecated replaced by {@link LogicalGenericBinaryComparator}, {@link LogicalScalarBinaryComparator},
+ * {@link LogicalComplexBinaryComparator}, and {@link ComparatorUtil}.
+ */
+ @Deprecated
public ComparisonHelper(SourceLocation sourceLoc) {
this.sourceLoc = sourceLoc;
}
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IBinaryComparator.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IBinaryComparator.java
index 67126e8..60fb912 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IBinaryComparator.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IBinaryComparator.java
@@ -20,6 +20,8 @@
import org.apache.hyracks.api.exceptions.HyracksDataException;
+@FunctionalInterface
public interface IBinaryComparator {
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) throws HyracksDataException;
+
+ int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) throws HyracksDataException;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/RawBinaryComparatorFactory.java b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/accessors/RawBinaryComparatorFactory.java
similarity index 72%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/RawBinaryComparatorFactory.java
rename to hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/accessors/RawBinaryComparatorFactory.java
index df03941..7725ef1 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/RawBinaryComparatorFactory.java
+++ b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/accessors/RawBinaryComparatorFactory.java
@@ -16,8 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-package org.apache.asterix.dataflow.data.nontagged.comparators;
+package org.apache.hyracks.data.std.accessors;
import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
@@ -30,28 +29,24 @@
public class RawBinaryComparatorFactory implements IBinaryComparatorFactory {
private static final long serialVersionUID = 1L;
- public static IBinaryComparatorFactory INSTANCE = new RawBinaryComparatorFactory();
+ public static final IBinaryComparatorFactory INSTANCE = new RawBinaryComparatorFactory();
private RawBinaryComparatorFactory() {
}
@Override
public IBinaryComparator createBinaryComparator() {
- return new IBinaryComparator() {
+ return RawBinaryComparatorFactory::compare;
+ }
- @Override
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
- int commonLength = Math.min(l1, l2);
- for (int i = 0; i < commonLength; i++) {
- if (b1[s1 + i] != b2[s2 + i]) {
- return b1[s1 + i] - b2[s2 + i];
- }
- }
- int difference = l1 - l2;
- return difference == 0 ? 0 : (difference > 0 ? 1 : -1);
+ public static int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+ int commonLength = Math.min(l1, l2);
+ for (int i = 0; i < commonLength; i++) {
+ if (b1[s1 + i] != b2[s2 + i]) {
+ return b1[s1 + i] - b2[s2 + i];
}
-
- };
+ }
+ return Integer.compare(l1, l2);
}
@Override
diff --git a/hyracks-fullstack/hyracks/hyracks-hdfs/pom.xml b/hyracks-fullstack/hyracks/hyracks-hdfs/pom.xml
index d4b1088..7e00d82 100644
--- a/hyracks-fullstack/hyracks/hyracks-hdfs/pom.xml
+++ b/hyracks-fullstack/hyracks/hyracks-hdfs/pom.xml
@@ -87,6 +87,11 @@
<dependencies>
<dependency>
<groupId>org.apache.hyracks</groupId>
+ <artifactId>hyracks-data-std</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hyracks</groupId>
<artifactId>hyracks-control-common</artifactId>
<version>${project.version}</version>
<scope>test</scope>
diff --git a/hyracks-fullstack/hyracks/hyracks-hdfs/src/main/java/org/apache/hyracks/hdfs/lib/RawBinaryComparatorFactory.java b/hyracks-fullstack/hyracks/hyracks-hdfs/src/main/java/org/apache/hyracks/hdfs/lib/RawBinaryComparatorFactory.java
deleted file mode 100644
index 01acddd..0000000
--- a/hyracks-fullstack/hyracks/hyracks-hdfs/src/main/java/org/apache/hyracks/hdfs/lib/RawBinaryComparatorFactory.java
+++ /dev/null
@@ -1,48 +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.hyracks.hdfs.lib;
-
-import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
-import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-
-public class RawBinaryComparatorFactory implements IBinaryComparatorFactory {
-
- private static final long serialVersionUID = 1L;
- private static final IBinaryComparator comparator = RawBinaryComparatorFactory::compare;
- public static final IBinaryComparatorFactory INSTANCE = new RawBinaryComparatorFactory();
-
- private RawBinaryComparatorFactory() {
- }
-
- @Override
- public IBinaryComparator createBinaryComparator() {
- return comparator;
- }
-
- public static final int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
- int commonLength = Math.min(l1, l2);
- for (int i = 0; i < commonLength; i++) {
- if (b1[s1 + i] != b2[s2 + i]) {
- return b1[s1 + i] - b2[s2 + i];
- }
- }
- int difference = l1 - l2;
- return difference == 0 ? 0 : (difference > 0 ? 1 : -1);
- }
-}
diff --git a/hyracks-fullstack/hyracks/hyracks-hdfs/src/test/java/org/apache/hyracks/hdfs/dataflow/DataflowTest.java b/hyracks-fullstack/hyracks/hyracks-hdfs/src/test/java/org/apache/hyracks/hdfs/dataflow/DataflowTest.java
index c2ba188..f33f2a3 100644
--- a/hyracks-fullstack/hyracks/hyracks-hdfs/src/test/java/org/apache/hyracks/hdfs/dataflow/DataflowTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-hdfs/src/test/java/org/apache/hyracks/hdfs/dataflow/DataflowTest.java
@@ -42,12 +42,12 @@
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
import org.apache.hyracks.api.job.JobId;
import org.apache.hyracks.api.job.JobSpecification;
+import org.apache.hyracks.data.std.accessors.RawBinaryComparatorFactory;
import org.apache.hyracks.dataflow.common.data.marshalling.UTF8StringSerializerDeserializer;
import org.apache.hyracks.dataflow.common.data.partition.FieldHashPartitionComputerFactory;
import org.apache.hyracks.dataflow.std.connectors.MToNPartitioningMergingConnectorDescriptor;
import org.apache.hyracks.dataflow.std.connectors.OneToOneConnectorDescriptor;
import org.apache.hyracks.dataflow.std.sort.ExternalSortOperatorDescriptor;
-import org.apache.hyracks.hdfs.lib.RawBinaryComparatorFactory;
import org.apache.hyracks.hdfs.lib.RawBinaryHashFunctionFactory;
import org.apache.hyracks.hdfs.lib.TextKeyValueParserFactory;
import org.apache.hyracks.hdfs.lib.TextTupleWriterFactory;
diff --git a/hyracks-fullstack/hyracks/hyracks-hdfs/src/test/java/org/apache/hyracks/hdfs2/dataflow/DataflowTest.java b/hyracks-fullstack/hyracks/hyracks-hdfs/src/test/java/org/apache/hyracks/hdfs2/dataflow/DataflowTest.java
index e547ac0..e6f4099 100644
--- a/hyracks-fullstack/hyracks/hyracks-hdfs/src/test/java/org/apache/hyracks/hdfs2/dataflow/DataflowTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-hdfs/src/test/java/org/apache/hyracks/hdfs2/dataflow/DataflowTest.java
@@ -40,13 +40,13 @@
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.api.job.JobId;
import org.apache.hyracks.api.job.JobSpecification;
+import org.apache.hyracks.data.std.accessors.RawBinaryComparatorFactory;
import org.apache.hyracks.dataflow.common.data.marshalling.UTF8StringSerializerDeserializer;
import org.apache.hyracks.dataflow.common.data.partition.FieldHashPartitionComputerFactory;
import org.apache.hyracks.dataflow.std.connectors.MToNPartitioningMergingConnectorDescriptor;
import org.apache.hyracks.dataflow.std.connectors.OneToOneConnectorDescriptor;
import org.apache.hyracks.dataflow.std.sort.ExternalSortOperatorDescriptor;
import org.apache.hyracks.hdfs.MiniDFSClusterFactory;
-import org.apache.hyracks.hdfs.lib.RawBinaryComparatorFactory;
import org.apache.hyracks.hdfs.lib.RawBinaryHashFunctionFactory;
import org.apache.hyracks.hdfs.lib.TextKeyValueParserFactory;
import org.apache.hyracks.hdfs.lib.TextTupleWriterFactory;