xiangfu0 commented on code in PR #19865:
URL: https://github.com/apache/pinot/pull/19865#discussion_r4291374162


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/text/LuceneTextIndexReader.java:
##########
@@ -243,11 +257,49 @@ public MutableRoaringBitmap getDocIds(String searchQuery, 
@Nullable String optio
     }
   }
 
+  /// Identifies a parsing configuration. A record so that equality is 
structural: comparing the
+  /// rendered text of these lists instead would conflate `["failed", 
"order"]` with
+  /// `["failed, order"]`, which are different stop-word sets that parse the 
same string differently.
+  private record ParseConfig(String column, String analyzerClass, List<String> 
analyzerArgs,
+                             List<String> analyzerArgTypes, List<String> 
stopWordsInclude,
+                             List<String> stopWordsExclude, boolean 
caseSensitive, String queryParserClass,
+                             boolean useANDForMultiTermQueries, boolean 
prefixSuffixMatchingInPhraseQueries) {
+    private ParseConfig {
+      analyzerArgs = copy(analyzerArgs);
+      analyzerArgTypes = copy(analyzerArgTypes);
+      stopWordsInclude = copy(stopWordsInclude);
+      stopWordsExclude = copy(stopWordsExclude);
+    }
+
+    private static List<String> copy(@Nullable List<String> values) {
+      return values == null ? List.of() : List.copyOf(values);
+    }
+  }
+
+  /// Cache key for one parsed query: the configuration plus the 
request-supplied text.
+  private record ParsedQueryKey(ParseConfig parseConfig, String searchQuery, 
@Nullable String optionsString) {
+  }
+
+  /// Carries a checked parse failure out of the cache's mapper so the 
original exception, and in
+  /// particular a [QueryException]'s error code, survives instead of being 
wrapped.
+  private static final class ParseFailure extends RuntimeException {
+    ParseFailure(Exception cause) {
+      super(cause);
+    }
+  }
+
+  private static ParseConfig buildParseConfig(String column, TextIndexConfig 
config) {
+    return new ParseConfig(column, config.getLuceneAnalyzerClass(), 
config.getLuceneAnalyzerClassArgs(),
+        config.getLuceneAnalyzerClassArgTypes(), config.getStopWordsInclude(), 
config.getStopWordsExclude(),
+        config.isCaseSensitive(), config.getLuceneQueryParserClass(), 
config.isUseANDForMultiTermQueries(),
+        config.isEnablePrefixSuffixMatchingInPhraseQueries());
+  }
+
   /// Parses a search string into a Lucene query, applying the configured 
parser and options.
   ///
   /// Shared by the doc-id and the count paths so that a `count(*)` and the 
filter it counts can never

Review Comment:
   Nit: this Javadoc is now stale after the rename. This method is the 
no-options path, so "applying the configured parser and options" and "Shared by 
the doc-id and the count paths" no longer describe it — that sharing lives in 
`parseQuery`/`buildQuery`. Could reword to just describe the without-options 
parse.



-- 
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]

Reply via email to