LakshSingla commented on code in PR #16241:
URL: https://github.com/apache/druid/pull/16241#discussion_r1591906052
##########
processing/src/main/java/org/apache/druid/segment/filter/SpatialFilter.java:
##########
@@ -174,8 +173,18 @@ public DruidObjectPredicate<String> makeStringPredicate()
if (input == null) {
return DruidPredicateMatch.UNKNOWN;
}
- final float[] coordinate =
SpatialDimensionRowTransformer.decode(input);
- return DruidPredicateMatch.of(bound.contains(coordinate));
+ return DruidPredicateMatch.of(bound.containsObj(input));
+ };
+ }
+
+ @Override
+ public DruidObjectPredicate<Object> makeObjectPredicate()
+ {
+ return input -> {
+ if (input == null) {
+ return DruidPredicateMatch.UNKNOWN;
+ }
+ return DruidPredicateMatch.of(bound.containsObj(input));
Review Comment:
Since we know that it is always a string, why do we need a new method called
`containsObj` that handles strings? Since the knowledge that it will always be
a string is present here, I think it would be better if we cast the input to
float[] and pass it to the filter as `bound.contains(decodedInput)`.
##########
processing/src/main/java/org/apache/druid/collections/spatial/search/Bound.java:
##########
@@ -43,6 +45,8 @@ public interface Bound<TCoordinateArray, TPoint extends
ImmutableNode<TCoordinat
boolean contains(TCoordinateArray coords);
+ boolean containsObj(@Nullable Object input);
Review Comment:
Can you please add a Javadoc for this method explaining how it differs from
`contains`, what arguments can the implementing class expect, and what happens
if `null` is passed as the argument?
##########
processing/src/main/java/org/apache/druid/collections/spatial/search/RectangularBound.java:
##########
@@ -118,6 +121,19 @@ public boolean contains(float[] coords)
return true;
}
+ @Override
+ public boolean containsObj(@Nullable Object input)
Review Comment:
Method seems to be too "one dimensional" to be called `containsObj`. It
doesn't handle the float[] types.
It is decoding and calling contains on the string input. Better names would
be along the lines of `containsSerializedString` or `decodeAndCheckContains`,
and the input type should be a String.
A better solution in my opinion would be to handle this conversion in the
callers, and pass the decoded dimension to the filter.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]