clintropolis commented on code in PR #16029: URL: https://github.com/apache/druid/pull/16029#discussion_r1536184367
########## processing/src/main/java/org/apache/druid/collections/spatial/search/RadiusBound.java: ########## @@ -23,37 +23,60 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -import org.apache.druid.collections.spatial.ImmutablePoint; +import org.apache.druid.collections.spatial.ImmutableFloatPoint; +import org.apache.druid.collections.spatial.RTreeUtils; import java.nio.ByteBuffer; /** + * */ public class RadiusBound extends RectangularBound { private static final byte CACHE_TYPE_ID = 0x01; private final float[] coords; private final float radius; + private final RadiusUnit radiusUnit; @JsonCreator public RadiusBound( @JsonProperty("coords") float[] coords, @JsonProperty("radius") float radius, - @JsonProperty("limit") int limit + @JsonProperty("limit") int limit, + @JsonProperty("radiusUnit") RadiusUnit radiusUnit Review Comment: should probably add a serde test to `RadiusBoundTest` with the new parameter. also it should be marked `@Nullable` ########## processing/src/test/java/org/apache/druid/collections/spatial/search/RectangularBoundTest.java: ########## @@ -48,6 +50,57 @@ public void testCacheKey() )); } + @Test + public void testRectangularBound() + { + float[][] insidePoints = new float[][]{ + {37.795717853074635f, -122.40906979480418f}, + {37.79625791859653f, -122.39638788940042f}, + {37.79685798676811f, -122.39335030726777f}, + {37.7966179600844f, -122.39798262002006f} + }; + float[][] outsidePoints = new float[][]{ + {37.79805810848854f, -122.39236309307468f}, + {37.78197485768925f, -122.41886599718191f}, + {37.798298130492945f, -122.39608413118715f}, + {37.783595343766216f, -122.41932163450181f} + }; + RectangularBound rectangularBound = new RectangularBound( + new float[]{37.78185482027019f, -122.41795472254213f}, + new float[]{37.797638168104185f, -122.39228715352137f}, + 10 + ); + for (float[] insidePoint : insidePoints) { + Assert.assertTrue(rectangularBound.contains(insidePoint)); + } + for (float[] outsidePoint : outsidePoints) { + Assert.assertFalse(rectangularBound.contains(outsidePoint)); + } + } + + @Test + public void testDeSerForDoubleArrays() throws JsonProcessingException Review Comment: 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 -- 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-unsubscr...@druid.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org For additional commands, e-mail: commits-h...@druid.apache.org