rdblue commented on code in PR #14101:
URL: https://github.com/apache/iceberg/pull/14101#discussion_r2830538431
##########
api/src/main/java/org/apache/iceberg/expressions/Literals.java:
##########
@@ -719,4 +723,71 @@ public String toString() {
return "X'" + BaseEncoding.base16().encode(bytes) + "'";
}
}
+
+ static class BoundingBoxLiteral implements Literal<ByteBuffer> {
+ private static final Comparator<ByteBuffer> CMP =
+
Comparators.<ByteBuffer>nullsFirst().thenComparing(Comparators.unsignedBytes());
+
+ private final ByteBuffer value;
+
+ BoundingBoxLiteral(BoundingBox value) {
+ this.value = value.toByteBuffer();
+ }
+
+ BoundingBoxLiteral(ByteBuffer value) {
+ Preconditions.checkNotNull(value, "Bounding box buffer cannot be null");
+ this.value = value.slice().order(ByteOrder.LITTLE_ENDIAN);
+ }
+
+ @Override
+ public ByteBuffer value() {
+ return value;
+ }
+
+ @Override
+ public ByteBuffer toByteBuffer() {
+ return value;
+ }
+
+ @Override
+ public <T> Literal<T> to(Type type) {
+ if (type.typeId() != Type.TypeID.GEOMETRY && type.typeId() !=
Type.TypeID.GEOGRAPHY) {
+ return null;
+ }
+
+ return (Literal<T>) this;
+ }
+
+ @Override
+ public Comparator<ByteBuffer> comparator() {
Review Comment:
This doesn't quite fit since we don't expect the types to align. I think
this should throw an exception because there isn't a comparator.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]