Jackie-Jiang commented on code in PR #19894:
URL: https://github.com/apache/pinot/pull/19894#discussion_r4593935416


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/fst/RegexpMatcher.java:
##########
@@ -43,9 +44,11 @@ public class RegexpMatcher {
   private final FST<Long> _fst;
   private final Automaton _automaton;
 
+  @SuppressWarnings("deprecation") // Preserve the complement syntax supported 
by existing FST queries.
   public RegexpMatcher(String regexQuery, FST<Long> fst) {
     _fst = fst;
-    _automaton = (new RegExp(regexQuery)).toAutomaton();
+    _automaton = Operations.determinize(new RegExp(regexQuery, RegExp.ALL | 
RegExp.DEPRECATED_COMPLEMENT).toAutomaton(),
+        Operations.DEFAULT_DETERMINIZE_WORK_LIMIT);

Review Comment:
   [P1] Bound regex expansion before constructing the automaton
   
   On an FST-indexed column, `REGEXP_LIKE(col, '^a{1000000000}$')` reaches this 
constructor as `a{1000000000}`. Lucene 9.12 rejected oversized counted 
repetitions before expansion, but Lucene 10 removed those construction-time 
checks. `toAutomaton()` now expands the repetition into a large list/automaton 
before the outer `Operations.determinize(..., DEFAULT_DETERMINIZE_WORK_LIMIT)` 
is reached, so a small query can exhaust server heap. Pinot's periodic 
termination checks occur later, during FST traversal.
   
   Verified from the query path and the pinned Lucene sources: [9.12 repetition 
checks](https://github.com/apache/lucene/blob/releases/lucene/9.12.0/lucene/core/src/java/org/apache/lucene/util/automaton/RegExp.java#L699-L715),
 [10.0 
construction](https://github.com/apache/lucene/blob/releases/lucene/10.0.0/lucene/core/src/java/org/apache/lucene/util/automaton/RegExp.java),
 and [10.0 repetition 
expansion](https://github.com/apache/lucene/blob/releases/lucene/10.0.0/lucene/core/src/java/org/apache/lucene/util/automaton/Operations.java).
   
   Please enforce a bounded construction budget before `toAutomaton()`, 
including nested repetitions, in both this class and 
`RegexpMatcherCaseInsensitive`. Add a regression asserting that oversized 
counted repetitions are rejected before expansion.



##########
pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/invertedindex/HnswIndexRollbackTest.java:
##########
@@ -265,6 +267,9 @@ private static File buildSegment(File tempDir, TableConfig 
tableConfig, SegmentV
 
   private static void installNewerIndex(File tempDir, File segmentDir, 
SegmentVersion version, String layout)
       throws Exception {
+    if (Version.LATEST.major != 9) {
+      throw new SkipException("Lucene 10 fixture exercises rollback recovery 
on Lucene 9 only");
+    }

Review Comment:
   Nonblocking improvement: strengthen the cross-version compatibility coverage
   
   The fixed Lucene 10 rollback fixtures now skip on this runtime, while 
current-writer round-trip tests cannot verify the Lucene 9.12-to-10 upgrade 
boundary. Add small fixed Lucene 9.12 HNSW and multi-column text fixtures, then 
assert that Lucene 10 loads and queries them without rebuilding across 
directory and packed layouts. The runtime compatibility suites currently 
exercise single-column text but lack these index types.
   
   Also parameterize 
[testLucene80IndexReader](https://github.com/apache/pinot/blob/34221a06e1903f663f1d8f4b906a23534d872304/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/readers/text/LuceneTextIndexCompatibleTest.java#L67-L80)
 to load its real Lucene 8 fixture through both the filesystem and 
`PinotDataBuffer` constructors. The existing combined-buffer test creates its 
index with the current writer, so it does not exercise the new Lucene 8 
fallback in that path.



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/vector/lucene99/HnswCodec.java:
##########
@@ -69,10 +69,11 @@ public KnnVectorsFormat getKnnVectorsFormatForField(String 
field) {
   /// Instantiates a new codec, specifying the stored fields compression mode 
to use.
   ///
   /// @param mode stored fields compression mode to use for newly 
flushed/merged segments.
-  public HnswCodec(Lucene912Codec.Mode mode, KnnVectorsFormat 
defaultKnnVectorsFormat) {
-    super("Lucene99", new Lucene912Codec(mode));
+  public HnswCodec(Lucene100Codec.Mode mode, KnnVectorsFormat 
defaultKnnVectorsFormat) {
+    // New indexes use Lucene100 format. Legacy indexes retain Lucene99 and 
are read by lucene-backward-codecs.
+    super("Lucene100", new Lucene100Codec(mode));
     _defaultKnnVectorsFormat = defaultKnnVectorsFormat;
-    _defaultPostingsFormat = new Lucene90PostingsFormat();
+    _defaultPostingsFormat = new Lucene912PostingsFormat();
     _defaultDVFormat = new Lucene90DocValuesFormat();

Review Comment:
   Nonblocking cleanup: customize only the vector format
   
   The postings, doc-values, and points state/overrides duplicate the 
`Lucene100Codec` delegate's exact defaults: `Lucene912PostingsFormat`, 
`Lucene90DocValuesFormat`, `Lucene90PointsFormat`, and the same per-field 
wrappers. Keep `FilterCodec`, but let it delegate those formats and retain only 
the custom vector-format wiring. This removes redundant implementation and 
version-specific imports from future upgrades. I found no in-repository 
subclasses relying on the extra hooks.
   
   Verified against the [Lucene 10.0.0 codec 
implementation](https://github.com/apache/lucene/blob/releases/lucene/10.0.0/lucene/core/src/java/org/apache/lucene/codecs/lucene100/Lucene100Codec.java).



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/fst/RegexpMatcherCaseInsensitive.java:
##########
@@ -44,10 +45,13 @@ public class RegexpMatcherCaseInsensitive {
   private final FST<BytesRef> _ifst;
   private final Automaton _automaton;
 
+  @SuppressWarnings("deprecation") // Preserve the complement syntax supported 
by existing FST queries.
   public RegexpMatcherCaseInsensitive(String regexQuery, FST<BytesRef> ifst) {
     _ifst = ifst;
     // For case-insensitive FSTs, convert regex to lowercase since we only 
store lowercase keys
-    _automaton = (new RegExp(regexQuery.toLowerCase())).toAutomaton();
+    _automaton = Operations.determinize(
+        new RegExp(regexQuery.toLowerCase(), RegExp.ALL | 
RegExp.DEPRECATED_COMPLEMENT).toAutomaton(),
+        Operations.DEFAULT_DETERMINIZE_WORK_LIMIT);

Review Comment:
   Nonblocking cleanup alongside the regex safety fix: share automaton 
compilation
   
   Put construction-budget validation, complement flags, and determinization in 
one helper used by both FST matchers. Keep case normalization in this caller 
and pass the normalized expression to the helper. The matching/traversal 
implementations can stay separate; sharing this compilation policy ensures 
future safety fixes and syntax changes apply consistently to both paths.



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