You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ja...@apache.org on 2023/07/25 05:29:50 UTC

[pinot] branch master updated: Increment nextDocId even if geo indexing fails (#11158)

This is an automated email from the ASF dual-hosted git repository.

jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 7231ecfee8 Increment nextDocId even if geo indexing fails (#11158)
7231ecfee8 is described below

commit 7231ecfee875ac80ea61b329887ab16ad65fb94f
Author: Saurabh Dubey <sa...@gmail.com>
AuthorDate: Tue Jul 25 10:59:45 2023 +0530

    Increment nextDocId even if geo indexing fails (#11158)
---
 .../segment/local/realtime/impl/geospatial/MutableH3Index.java | 10 +++++++---
 .../apache/pinot/segment/local/segment/index/H3IndexTest.java  |  4 +++-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/impl/geospatial/MutableH3Index.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/impl/geospatial/MutableH3Index.java
index e87b750659..b4e2ae5dd5 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/impl/geospatial/MutableH3Index.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/impl/geospatial/MutableH3Index.java
@@ -55,8 +55,12 @@ public class MutableH3Index implements H3IndexReader, MutableIndex {
 
   @Override
   public void add(@Nonnull Object value, int dictId, int docId) {
-    Geometry geometry = GeometrySerializer.deserialize((byte[]) value);
-    add(geometry);
+    try {
+      Geometry geometry = GeometrySerializer.deserialize((byte[]) value);
+      add(geometry);
+    } finally {
+      _nextDocId++;
+    }
   }
 
   @Override
@@ -73,7 +77,7 @@ public class MutableH3Index implements H3IndexReader, MutableIndex {
     Coordinate coordinate = geometry.getCoordinate();
     // TODO: support multiple resolutions
     long h3Id = H3Utils.H3_CORE.geoToH3(coordinate.y, coordinate.x, _lowestResolution);
-    _bitmaps.computeIfAbsent(h3Id, k -> new ThreadSafeMutableRoaringBitmap()).add(_nextDocId++);
+    _bitmaps.computeIfAbsent(h3Id, k -> new ThreadSafeMutableRoaringBitmap()).add(_nextDocId);
   }
 
   @Override
diff --git a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/H3IndexTest.java b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/H3IndexTest.java
index ce43146c86..39ba18a904 100644
--- a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/H3IndexTest.java
+++ b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/H3IndexTest.java
@@ -33,6 +33,7 @@ import org.apache.pinot.segment.local.segment.creator.impl.inv.geospatial.OffHea
 import org.apache.pinot.segment.local.segment.creator.impl.inv.geospatial.OnHeapH3IndexCreator;
 import org.apache.pinot.segment.local.segment.index.h3.H3IndexType;
 import org.apache.pinot.segment.local.segment.index.readers.geospatial.ImmutableH3IndexReader;
+import org.apache.pinot.segment.local.utils.GeometrySerializer;
 import org.apache.pinot.segment.local.utils.GeometryUtils;
 import org.apache.pinot.segment.local.utils.H3Utils;
 import org.apache.pinot.segment.spi.V1Constants;
@@ -89,13 +90,14 @@ public class H3IndexTest {
           h3IndexResolution);
           GeoSpatialIndexCreator offHeapCreator = new OffHeapH3IndexCreator(TEMP_DIR, offHeapColumnName,
               h3IndexResolution)) {
+        int docId = 0;
         while (expectedCardinalities.size() < numUniqueH3Ids) {
           double longitude = RANDOM.nextDouble() * 360 - 180;
           double latitude = RANDOM.nextDouble() * 180 - 90;
           Point point = GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(longitude, latitude));
           onHeapCreator.add(point);
           offHeapCreator.add(point);
-          mutableH3Index.add(point);
+          mutableH3Index.add(GeometrySerializer.serialize(point), -1, docId++);
           long h3Id = H3Utils.H3_CORE.geoToH3(latitude, longitude, resolution);
           expectedCardinalities.merge(h3Id, 1, Integer::sum);
         }


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