rdblue commented on code in PR #14101:
URL: https://github.com/apache/iceberg/pull/14101#discussion_r2830543378


##########
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() {
+      return CMP;
+    }
+
+    Object writeReplace() throws ObjectStreamException {
+      return new SerializationProxies.BoundingBoxLiteralProxy(value());
+    }
+
+    @Override
+    public String toString() {
+      return BoundingBox.fromByteBuffer(value()).toString();
+    }
+
+    @Override
+    public boolean equals(Object other) {
+      if (this == other) {
+        return true;
+      }
+      if (!(other instanceof BoundingBoxLiteral)) {
+        return false;
+      }
+
+      BoundingBoxLiteral that = (BoundingBoxLiteral) other;
+      return comparator().compare(value(), that.value()) == 0;

Review Comment:
   If this works, then the comparator is incorrect for values. This is 
comparing serialized bounding boxes.



-- 
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]

Reply via email to