File tree 2 files changed +16
-6
lines changed
core/src/java/org/apache/lucene/index
2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ Optimizations
35
35
---------------------
36
36
* GITHUB#14011: Reduce allocation rate in HNSW concurrent merge. (Viliam Durina)
37
37
* GITHUB#14022: Optimize DFS marking of connected components in HNSW by reducing stack depth, improving performance and reducing allocations. (Viswanath Kuchibhotla)
38
+ * GITHUB#14373: Optimized `ParallelLeafReader` to improve term vector fetching efficiency.
38
39
39
40
Bug Fixes
40
41
---------------------
Original file line number Diff line number Diff line change @@ -348,15 +348,24 @@ public void prefetch(int docID) throws IOException {
348
348
@ Override
349
349
public Fields get (int docID ) throws IOException {
350
350
ParallelFields fields = null ;
351
- for (Map .Entry <String , LeafReader > ent : tvFieldToReader .entrySet ()) {
352
- String fieldName = ent .getKey ();
353
- TermVectors termVectors = readerToTermVectors .get (ent .getValue ());
354
- Terms vector = termVectors .get (docID , fieldName );
355
- if (vector != null ) {
351
+
352
+ // Step 2: Fetch all term vectors once per reader
353
+ for (Map .Entry <LeafReader , TermVectors > entry : readerToTermVectors .entrySet ()) {
354
+ TermVectors termVectors = entry .getValue ();
355
+ Fields docFields = termVectors .get (docID ); // Fetch all fields at once
356
+
357
+ if (docFields != null ) {
356
358
if (fields == null ) {
357
359
fields = new ParallelFields ();
358
360
}
359
- fields .addField (fieldName , vector );
361
+
362
+ // Step 3: Aggregate only required fields
363
+ for (String fieldName : docFields ) {
364
+ Terms vector = docFields .terms (fieldName );
365
+ if (vector != null ) {
366
+ fields .addField (fieldName , vector );
367
+ }
368
+ }
360
369
}
361
370
}
362
371
You can’t perform that action at this time.
0 commit comments