You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/04/09 12:41:21 UTC

[GitHub] [pinot] richardstartin commented on a diff in pull request #8498: Support st_contains using H3 index

richardstartin commented on code in PR #8498:
URL: https://github.com/apache/pinot/pull/8498#discussion_r846627000


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/H3Utils.java:
##########
@@ -35,4 +51,50 @@ private H3Utils() {
       throw new RuntimeException("Failed to instantiate H3 instance", e);
     }
   }
+
+  private static Set<Long> coverLineInH3(LineString lineString, int resolution) {
+    Set<Long> coveringH3Cells = new HashSet<>();
+    List<Long> endpointH3Cells = new ArrayList<>();
+    for (Coordinate endpoint : lineString.getCoordinates()) {
+      endpointH3Cells.add(H3_CORE.geoToH3(endpoint.y, endpoint.x, resolution));
+    }
+    for (int i = 0; i < endpointH3Cells.size() - 1; i++) {
+      try {
+        coveringH3Cells.addAll(H3_CORE.h3Line(endpointH3Cells.get(i), endpointH3Cells.get(i + 1)));
+      } catch (LineUndefinedException e) {
+        throw new RuntimeException(e);
+      }
+    }
+    return coveringH3Cells;
+  }

Review Comment:
   Boxing here is unfortunate, use `LongSet` instead.



-- 
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-unsubscribe@pinot.apache.org

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


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