-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Geo spatial interfaces #16029
Geo spatial interfaces #16029
Conversation
processing/src/test/java/org/apache/druid/collections/spatial/search/RectangularBoundTest.java
Fixed
Show fixed
Hide fixed
processing/src/test/java/org/apache/druid/collections/spatial/search/RectangularBoundTest.java
Fixed
Show fixed
Hide fixed
processing/src/test/java/org/apache/druid/collections/spatial/search/RectangularBoundTest.java
Fixed
Show fixed
Hide fixed
processing/src/test/java/org/apache/druid/collections/spatial/search/RectangularBoundTest.java
Fixed
Show fixed
Hide fixed
processing/src/test/java/org/apache/druid/collections/spatial/search/RadiusBoundTest.java
Fixed
Show fixed
Hide fixed
processing/src/test/java/org/apache/druid/collections/spatial/search/RadiusBoundTest.java
Fixed
Show fixed
Hide fixed
processing/src/test/java/org/apache/druid/collections/spatial/search/RadiusBoundTest.java
Fixed
Show fixed
Hide fixed
Assert.assertFalse(bound.containsDouble(geoPoint)); | ||
float[] floatPoint = new float[]{ | ||
Float.parseFloat(String.valueOf(geoPoint[0])), // this is how legacy sptial index | ||
Float.parseFloat(String.valueOf(geoPoint[1])) |
Check notice
Code scanning / CodeQL
Missing catch of NumberFormatException Note test
Can you please take look at this? |
processing/src/test/java/org/apache/druid/collections/spatial/search/RectangularBoundTest.java
Fixed
Show fixed
Hide fixed
processing/src/test/java/org/apache/druid/collections/spatial/search/RectangularBoundTest.java
Fixed
Show fixed
Hide fixed
Assert.assertTrue(distance < circleRadius); | ||
Assert.assertTrue(bound.containsDouble(geoPoint)); | ||
float[] floatPoint = new float[]{ | ||
Float.parseFloat(String.valueOf(geoPoint[0])), |
Check notice
Code scanning / CodeQL
Missing catch of NumberFormatException Note test
Assert.assertTrue(haversineDistance > circleRadius); // asserts that point is outside | ||
Assert.assertFalse(bound.containsDouble(geoPoint)); | ||
float[] floatPoint = new float[]{ | ||
Float.parseFloat(String.valueOf(geoPoint[0])), |
Check notice
Code scanning / CodeQL
Missing catch of NumberFormatException Note test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
double lat1 = coord1[0]; | ||
double lon1 = coord1[1]; | ||
double lat2 = coord2[0]; | ||
double lon2 = coord2[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe just inline these in the next 4 double declarations since they aren't used separately
(also a lot of these could be marked final
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
/** | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe either add real javadoc or delete this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
/** | ||
* An immutable representation of an {@link RTree} for spatial indexing. | ||
*/ | ||
public final class ImmutableRTree32BitImpl implements ImmutableRTree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: how about ImmutableFloatRTree
? or this is fine too, naming things is the worst
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed
48f71dd
to
f827ea7
Compare
Assert.assertTrue(bound.contains(geoPoint)); | ||
float[] floatPoint = new float[]{ | ||
Float.parseFloat(String.valueOf(geoPoint[0])), | ||
Float.parseFloat(String.valueOf(geoPoint[1])) |
Check notice
Code scanning / CodeQL
Missing catch of NumberFormatException Note test
} | ||
|
||
@Test | ||
public void testDeSerForDoubleArrays() throws JsonProcessingException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: test name is stale i guess. Also instead of doing it with a string, it would be nicer to make a RectangularBound
serialize it to string, and then deserialize back to an object to make sure round tripping works ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified test
|
||
@JsonCreator | ||
public RadiusBound( | ||
@JsonProperty("coords") float[] coords, | ||
@JsonProperty("radius") float radius, | ||
@JsonProperty("limit") int limit | ||
@JsonProperty("limit") int limit, | ||
@JsonProperty("radiusUnit") RadiusUnit radiusUnit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably add a serde test to RadiusBoundTest
with the new parameter. also it should be marked @Nullable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added more tests for nullable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments but not a blocker so I will merge the PR.
this.childrenOffset = initialOffset | ||
+ offsetFromInitial | ||
+ HEADER_NUM_BYTES | ||
+ 2 * numDims * Float.BYTES | ||
+ Integer.BYTES | ||
+ bitmapSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.childrenOffset = initialOffset | |
+ offsetFromInitial | |
+ HEADER_NUM_BYTES | |
+ 2 * numDims * Float.BYTES | |
+ Integer.BYTES | |
+ bitmapSize; | |
this.childrenOffset = sizePosition | |
+ Integer.BYTES | |
+ bitmapSize; |
final int sizePosition = initialOffset + offsetFromInitial + HEADER_NUM_BYTES + 2 * numDims * Float.BYTES; | ||
int bitmapSize = data.getInt(sizePosition); | ||
this.childrenOffset = initialOffset | ||
+ offsetFromInitial | ||
+ HEADER_NUM_BYTES | ||
+ 2 * numDims * Float.BYTES | ||
+ Integer.BYTES | ||
+ bitmapSize; | ||
|
||
this.data = data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final int sizePosition = initialOffset + offsetFromInitial + HEADER_NUM_BYTES + 2 * numDims * Float.BYTES; | |
int bitmapSize = data.getInt(sizePosition); | |
this.childrenOffset = initialOffset | |
+ offsetFromInitial | |
+ HEADER_NUM_BYTES | |
+ 2 * numDims * Float.BYTES | |
+ Integer.BYTES | |
+ bitmapSize; | |
this.data = data; | |
this(numDims, initialOffset, offsetFromInitial, numChildren, leaf, data, bitmapFactory) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not work as this( ) calls needs to first statement. I just renamed the class here with no other changes.
import java.util.Iterator; | ||
|
||
/** | ||
* Byte layout: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the child here and what is the dim?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nums of dims = size of float array, needs it here esp for byte layout. Child here in byte layout represents the child node stored at the childOffeset
this.childrenOffset = initialOffset
+ offsetFromInitial
+ HEADER_NUM_BYTES
+ 2 * numDims * Float.BYTES
+ Integer.BYTES
+ bitmapSize;
{ | ||
private static Random random = ThreadLocalRandom.current(); | ||
|
||
public static float[][] generateGeoCoordinatesAroundCircle( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since its only used in test, the method should be moved to test code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is already in test package.
Description
Iterable<ImmutableBitmap> search(ImmutableDoubleNode node, Bound bound);
PR is fully backward compatible. Let me know if you have any questions.
Release Notes:
Adding radiusUnit in Radius Bound filter. radiusUnit : String value of radius unit in lowercase, default value is 'euclidean'. Allowed units are euclidean, meters, miles, kilometers.
This PR has: