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

[pinot] branch master updated: upgrade h3 lib from 3.7.2 to 4.0.0 to lower glibc requirement (#9335)

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

xiangfu 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 0f4bcfcb60 upgrade h3 lib from 3.7.2 to 4.0.0 to lower glibc requirement (#9335)
0f4bcfcb60 is described below

commit 0f4bcfcb601eec41d9f131b25b49a009a8621c24
Author: Xiang Fu <xi...@gmail.com>
AuthorDate: Sun Sep 4 06:12:34 2022 -0700

    upgrade h3 lib from 3.7.2 to 4.0.0 to lower glibc requirement (#9335)
---
 .../org/apache/pinot/segment/local/utils/H3Utils.java   | 17 ++++++++---------
 pom.xml                                                 |  2 +-
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/H3Utils.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/H3Utils.java
index 7fab9bd3aa..706a85e388 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/H3Utils.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/H3Utils.java
@@ -18,9 +18,8 @@
  */
 package org.apache.pinot.segment.local.utils;
 
-import com.uber.h3core.H3Core;
-import com.uber.h3core.exceptions.LineUndefinedException;
-import com.uber.h3core.util.GeoCoord;
+import com.uber.h3core.H3CoreV3;
+import com.uber.h3core.util.LatLng;
 import it.unimi.dsi.fastutil.longs.LongArrayList;
 import it.unimi.dsi.fastutil.longs.LongList;
 import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
@@ -44,13 +43,13 @@ public class H3Utils {
   private H3Utils() {
   }
 
-  public static final H3Core H3_CORE;
+  public static final H3CoreV3 H3_CORE;
 
   static {
     try {
-      H3_CORE = H3Core.newInstance();
+      H3_CORE = H3CoreV3.newInstance();
     } catch (IOException e) {
-      throw new RuntimeException("Failed to instantiate H3 instance", e);
+      throw new RuntimeException("Failed to instantiate H3 V3 instance", e);
     }
   }
 
@@ -63,7 +62,7 @@ public class H3Utils {
     for (int i = 0; i < endpointH3Cells.size() - 1; i++) {
       try {
         coveringH3Cells.addAll(H3_CORE.h3Line(endpointH3Cells.getLong(i), endpointH3Cells.getLong(i + 1)));
-      } catch (LineUndefinedException e) {
+      } catch (Exception e) {
         throw new RuntimeException(e);
       }
     }
@@ -72,7 +71,7 @@ public class H3Utils {
 
   private static Pair<LongSet, LongSet> coverPolygonInH3(Polygon polygon, int resolution) {
     List<Long> polyfillCells = H3_CORE.polyfill(Arrays.stream(polygon.getExteriorRing().getCoordinates())
-            .map(coordinate -> new GeoCoord(coordinate.y, coordinate.x)).collect(Collectors.toList()),
+            .map(coordinate -> new LatLng(coordinate.y, coordinate.x)).collect(Collectors.toList()),
         Collections.emptyList(), resolution);
     // TODO: this can be further optimized to use native H3 implementation. They have plan to support natively.
     // https://github.com/apache/pinot/issues/8547
@@ -96,7 +95,7 @@ public class H3Utils {
   }
 
   private static Polygon createPolygonFromH3Cell(long h3Cell) {
-    List<GeoCoord> boundary = H3_CORE.h3ToGeoBoundary(h3Cell);
+    List<LatLng> boundary = H3_CORE.h3ToGeoBoundary(h3Cell);
     boundary.add(boundary.get(0));
     return GeometryUtils.GEOMETRY_FACTORY.createPolygon(
         boundary.stream().map(geoCoord -> new Coordinate(geoCoord.lng, geoCoord.lat)).toArray(Coordinate[]::new));
diff --git a/pom.xml b/pom.xml
index 54a77f30ec..59e48d3337 100644
--- a/pom.xml
+++ b/pom.xml
@@ -154,7 +154,7 @@
     <netty.version>4.1.79.Final</netty.version>
     <reactivestreams.version>1.0.3</reactivestreams.version>
     <jts.version>1.16.1</jts.version>
-    <h3.version>3.7.2</h3.version>
+    <h3.version>4.0.0</h3.version>
     <jmh.version>1.26</jmh.version>
     <audienceannotations.version>0.13.0</audienceannotations.version>
 


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