saurabhd336 commented on code in PR #12568:
URL: https://github.com/apache/pinot/pull/12568#discussion_r1515534775
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/impl/json/MutableJsonIndexImpl.java:
##########
@@ -291,6 +297,88 @@ private RoaringBitmap getMatchingFlattenedDocIds(Predicate
predicate) {
} else {
return new RoaringBitmap();
}
+ } else if (predicateType == Predicate.Type.REGEXP_LIKE) {
+ String ceilingKey = _postingListMap.ceilingKey(key +
BaseJsonIndexCreator.KEY_VALUE_SEPARATOR);
+ if (ceilingKey == null || !ceilingKey.startsWith(key +
BaseJsonIndexCreator.KEY_VALUE_SEPARATOR)) {
+ // No values with this key exist
+ return new RoaringBitmap();
+ }
+
+ Pattern pattern = ((RegexpLikePredicate) predicate).getPattern();
+ MutableRoaringBitmap result = null;
+ char nextChar = BaseJsonIndexCreator.KEY_VALUE_SEPARATOR + 1;
+ SortedMap<String, RoaringBitmap> subMap =
+ _postingListMap.subMap(ceilingKey, true,
_postingListMap.floorKey(key + nextChar), true);
+
+ for (Map.Entry<String, RoaringBitmap> entry : subMap.entrySet()) {
+ if (!pattern.matcher(entry.getKey().substring(key.length() +
1)).matches()) {
+ continue;
+ }
+ if (result == null) {
+ result = entry.getValue().toMutableRoaringBitmap();
+ } else {
+ result.or(entry.getValue().toMutableRoaringBitmap());
+ }
+ }
+
+ if (result == null) {
+ return new RoaringBitmap();
+ } else {
+ if (matchingDocIds == null) {
+ return result.toRoaringBitmap();
+ } else {
+ matchingDocIds.and(result.toRoaringBitmap());
+ return matchingDocIds;
+ }
+ }
+ } else if (predicateType == Predicate.Type.RANGE) {
+ String ceilingKey = _postingListMap.ceilingKey(key +
BaseJsonIndexCreator.KEY_VALUE_SEPARATOR);
+ if (ceilingKey == null || !ceilingKey.startsWith(key +
BaseJsonIndexCreator.KEY_VALUE_SEPARATOR)) {
+ // No values with this key exist
+ return new RoaringBitmap();
+ }
+
+ MutableRoaringBitmap result = null;
+ char nextChar = BaseJsonIndexCreator.KEY_VALUE_SEPARATOR + 1;
+ SortedMap<String, RoaringBitmap> subMap =
+ _postingListMap.subMap(ceilingKey, true,
_postingListMap.floorKey(key + nextChar), true);
+
+ RangePredicate rangePredicate = (RangePredicate) predicate;
+ FieldSpec.DataType rangeDataType = rangePredicate.getRangeDataType();
Review Comment:
Makes sense. I've simplified to differentiate b/w numeric and string types
--
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]