Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade h3 lib from 3.7.2 to 4.0.0 to lower glibc requirement #9335

Merged
merged 1 commit into from
Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}

Expand All @@ -63,7 +62,7 @@ private static LongSet coverLineInH3(LineString lineString, int resolution) {
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);
}
}
Expand All @@ -72,7 +71,7 @@ private static LongSet coverLineInH3(LineString lineString, int resolution) {

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
Expand All @@ -96,7 +95,7 @@ private static Pair<LongSet, LongSet> coverPolygonInH3(Polygon polygon, int reso
}

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));
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down