Jackie-Jiang commented on code in PR #16002:
URL: https://github.com/apache/pinot/pull/16002#discussion_r2136632610


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/geospatial/BaseH3IndexCreator.java:
##########
@@ -104,12 +106,25 @@ public abstract class BaseH3IndexCreator implements 
GeoSpatialIndexCreator {
 
   @Override
   public Geometry deserialize(byte[] bytes) {
-    return GeometrySerializer.deserialize(bytes);
+    try {
+      return GeometrySerializer.deserialize(bytes);
+    } catch (Exception e) {
+      // For invalid serialized geometry, return null so that the doc can be 
skipped
+      return null;
+    }
   }
 
   @Override
   public void add(Geometry geometry)

Review Comment:
   Add `@Nullable` to the argument, same for interface



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/geospatial/BaseH3IndexCreator.java:
##########
@@ -104,12 +106,25 @@ public abstract class BaseH3IndexCreator implements 
GeoSpatialIndexCreator {
 
   @Override
   public Geometry deserialize(byte[] bytes) {
-    return GeometrySerializer.deserialize(bytes);
+    try {
+      return GeometrySerializer.deserialize(bytes);
+    } catch (Exception e) {
+      // For invalid serialized geometry, return null so that the doc can be 
skipped
+      return null;
+    }
   }
 
   @Override
   public void add(Geometry geometry)
       throws IOException {
+    if (geometry == null) {
+      ServerMetrics metrics = ServerMetrics.get();
+      if (metrics != null) {
+        metrics.addMeteredGlobalValue(ServerMeter.INDEXING_FAILURES, 1);
+      }
+      _nextDocId++;
+      return;
+    }
     Preconditions.checkState(geometry instanceof Point, "H3 index can only be 
applied to Point, got: %s",

Review Comment:
   Let's change this `checkState` into a if check. Currently the code cannot 
handle bytes representing anything other than `Point`. 



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/geospatial/BaseH3IndexCreator.java:
##########
@@ -104,12 +106,25 @@ public abstract class BaseH3IndexCreator implements 
GeoSpatialIndexCreator {
 
   @Override
   public Geometry deserialize(byte[] bytes) {
-    return GeometrySerializer.deserialize(bytes);
+    try {
+      return GeometrySerializer.deserialize(bytes);

Review Comment:
   We are capturing the exception from the caller side, no need to do another 
try-catch here



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/geospatial/BaseH3IndexCreator.java:
##########
@@ -104,12 +106,25 @@ public abstract class BaseH3IndexCreator implements 
GeoSpatialIndexCreator {
 
   @Override
   public Geometry deserialize(byte[] bytes) {
-    return GeometrySerializer.deserialize(bytes);
+    try {
+      return GeometrySerializer.deserialize(bytes);
+    } catch (Exception e) {
+      // For invalid serialized geometry, return null so that the doc can be 
skipped
+      return null;
+    }
   }
 
   @Override
   public void add(Geometry geometry)
       throws IOException {
+    if (geometry == null) {
+      ServerMetrics metrics = ServerMetrics.get();
+      if (metrics != null) {

Review Comment:
   (minor) This check is redundant



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/geospatial/BaseH3IndexCreator.java:
##########
@@ -104,12 +106,25 @@ public abstract class BaseH3IndexCreator implements 
GeoSpatialIndexCreator {
 
   @Override
   public Geometry deserialize(byte[] bytes) {
-    return GeometrySerializer.deserialize(bytes);
+    try {
+      return GeometrySerializer.deserialize(bytes);
+    } catch (Exception e) {
+      // For invalid serialized geometry, return null so that the doc can be 
skipped
+      return null;
+    }
   }
 
   @Override
   public void add(Geometry geometry)
       throws IOException {
+    if (geometry == null) {
+      ServerMetrics metrics = ServerMetrics.get();
+      if (metrics != null) {
+        metrics.addMeteredGlobalValue(ServerMeter.INDEXING_FAILURES, 1);

Review Comment:
   Can we include the table name and index type similar to how this meter is 
emitted in `MutableSegmentImpl`? We should be able to include the table name 
within `IndexCreationContext` and pass it in



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to