Commit Graph

37794 Commits

Author SHA1 Message Date
Mike Pellegrini e7a6382089
Fix Flaky Test In TestBlockJoinBulkScorer (#13785) 2024-09-16 14:50:51 +02:00
Adrien Grand 73173a40c1 Revert "Speed up advancing within a block. (#13692)"
This reverts commit 79fd9fee97.
2024-09-16 10:39:21 +02:00
Dawid Weiss ebeb5c3281 Add --stacktrace to gradlew invocations for debugging odd issues #13792 2024-09-16 08:32:05 +02:00
Mike McCandless 3801d85978 #13767: fix test failure: compress can only be true when quantized bits=4 2024-09-15 16:11:00 -04:00
Mike McCandless a7332fb30a GITHUB#13519: move CHANGES entry to 9.12.0 2024-09-15 15:46:16 -04:00
Michael McCandless a1418d9433
Remove 8 bit quantization for HNSW/KNN vector indexing (it is buggy today) (#13767)
4 and 7 bit quantization still work.

It's a bit tricky because 9.11 indices may have 8 bit compressed
vectors which are buggy at search time (and users may not realize it,
or may not be using them at search time).  But the index is still
intact since we keep the original full float precision vectors.  So,
users can force rewrite all their 9.11 written segments (or reindex
those docs), and can change to 4 or 7 bit quantization for newly
indexed documents.  The 9.11 index is still usable.

(I added a couple test cases confirming that one can indeed change
their mind, indexing a given vector field first with 4 bit
quantization, then later (new IndexWriter / Codec) with 7 bit or with
no quantization.)

I added MIGRATE.md explanation.

Separately, I also tightned up the `compress` boolean to throw an
exception unless bits=4.  Previously (for 7 bit compression) it
silently ignored `compress=true` for 7, 8 bit quantization.  And tried
to improve its javadocs a bit.

Closes #13519.
2024-09-15 15:26:28 -04:00
Shubham Chaudhary 111ccf6c30
Fix TestShapeDocValues.testLatLonPolygonBBox (#13743) 2024-09-15 13:20:50 -04:00
mrhbj 568d1f3fbe
Reduce number of calculations in FSTCompiler (#13788)
* Simplify FST return

* Reduce number of calculations in FSTCompiler
2024-09-14 10:51:12 -04:00
Stefan Vodita aa86a8119a
Add unit-of-least-precision float comparison (#13723) 2024-09-14 09:51:10 +01:00
Christine Poerschke 7c056ab88c
similarities: provide default computeNorm implementation; remove remaining discountOverlaps setters; (#13757)
Co-authored-by: Robert Muir <rmuir@apache.org>
2024-09-13 09:27:35 +01:00
Luca Cavanna f778cc4924
Remove IndexSearcher#search(List<LeafReaderContext>, Weight, Collector) (#13780)
With the introduction of intra-segment concurrency, we have introduced a new
protected search(LeafReaderContextPartition[], Weight, Collector) method. The
previous variant that accepts a list of leaf reader contexts was left deprecated
as there is one leftover usages coming from search(Query, Collector). The hope was
that the latter was going to be removed soon as well, but there is actually no
need to tie the two removals. It is easier to fold this method into its only
caller, in order for it to still bypass the collector manager based methods. 
This way we fold two deprecated methods into a single one.
2024-09-13 09:00:50 +02:00
Luca Cavanna fe64b04fda
Replace docBase with actual docId in MaxScoreAccumulator (#13777)
We have been encoding docBase and the score in MaxScoreAccumulator#accumulate.
That makes the assumption that segments are going to be processed in doc order
and implements global max score accounting across segments searched concurrently.

With the introduction of intra-segment concurrency, the same segment may be seen
multiple times, once per segment partition. Partitions are all going to have the same
docBase, hence you may end up with topN results with higher docIds than expected,
because the search early terminates before docs with same score and lower doc ids
are seen.

This commit encodes the docId in the accumulator in place of the docBase to resolve
the described issue.
2024-09-13 08:58:10 +02:00
Adrien Grand 5045d3c67b Fix compile error. 2024-09-13 07:54:48 +02:00
Adrien Grand e8e179cd45
Add prefetching support to term vectors. (#13758)
This follows the same approach that we used for stored fields.
2024-09-13 07:45:12 +02:00
Chris Hegarty 3a8f75ccfc
Make HnswLock and LockedRow final (#13776)
Trivial commit that makes HnswLock final and LockedRow a record. This is general clean up and helps the JIT a little when reasoning about these types - which show quite a bit in indexing and search profiles.
2024-09-12 20:39:57 +01:00
Adrien Grand 2f7da75b7d
Migrate more classes to records. (#13772) 2024-09-12 21:38:28 +02:00
Luca Cavanna cb48c7121a
Lower number of hits in TestLargeNumHitsTopDocsCollector (#13775)
There's two tests where we use 250_000 as number of collected hits, but we only
ever index max 2000 docs. That makes use create a priority queue of size
250_000 for each segment partition which causes out of memory errors when the
number of partitions is higher than a few.

With this commit I propose that we lower the threshold to 2000 for those tests
that need a high number of collected hits. The assumption that a priority queue
is not built within the LargeNumHitsTopDocsCollector still holds so this change
should not defeat the purpose of the tests.
2024-09-12 16:19:22 +02:00
Luca Cavanna 5359d36ba6
Introduce ProfilerCollectorManager (#13746)
ProfilerCollector did not have until now a corresponding collector manager.
This commit introduces one and switches TestProfilerCollector to use search
concurrency and move away from the deprecated search(Query, Collector) method.

Note that the collector manager does not support children collectors. Figuring
out a generic API for that is rather complicated. Users can always create
their own collector manager depending on their collector hierarchy.

Relates to #12892
2024-09-12 15:30:22 +02:00
mrhbj 91c6954e24
Simplify FST return (#13771) 2024-09-12 15:20:10 +02:00
Adrien Grand ff8b81afc5
Integrate merge-time index reordering with the intra-merge executor. (#13289)
Index reordering can benefit greatly from parallelism, so it should try to use
the intra-merge executor when possible.
2024-09-12 14:43:26 +02:00
Luca Cavanna aa86c2b8a0
Address length used to copy array in FacetsCollector to not be out of bounds (#13774)
This has caused a few recent test failures with jdk23 and jdk24. It should
get fixed replacing the length with the lengt of the array, rather than using
the new length.
2024-09-12 13:08:44 +02:00
Christine Poerschke ef577ea43a
PayloadScoreQuery javadoc update w.r.t. SpanQuery use (#13731) 2024-09-12 11:23:22 +01:00
Benjamin Trent 74e3c44063
Unify how missing field entries are handle in knn formats (#13641)
During segment merge we must verify that a given field has vectors and exists. The typical knn format checks assume the per-field format is used and thus only check for `null`. 

But we should check for field existence in the field info and verify it has dense vectors

Additionally, this commit unifies how the knn formats work and they will throw if a non-existing field is queried. Except for PerField format, which will return null (like the other per field formats)
2024-09-11 16:46:38 -04:00
Shubham Chaudhary 8760654faa
Remove unnecessary methods from DocAndScore (#13769) 2024-09-11 22:32:23 +02:00
Adrien Grand f0fd51c4d5
Make TotalHits a record. (#13762) 2024-09-11 15:50:06 +02:00
Greg Miller c26c2d6e09
Remove usage of IndexSearcher#Search(Query, Collector) from monitor package (#13735) 2024-09-11 06:26:14 -07:00
Benjamin Trent b940511b07
This commit adds a new test CMS that always provides intra-merge parallelism (#13475)
@iverase has uncovered a potential issue with intra-merge CMS parallelism.

This commit helps expose this problem by forcing tests to use intra-merge parallelism instead of always (well, usually) delegating to a SameThreadExecutorService.

When intra-merge parallelism is used, norms, doc_values, stored_values, etc. are all merged in a separate thread than the thread that was used to construct their merge optimized instances.

This trips assertions numerous assertions in AssertingCodec.assertThread where we assume that the thread that called getMergeInstance() is also the thread getting the values to merge.

In addition to the better testing, this corrects poor merge state handling in the event of parallelism.
2024-09-11 09:14:50 -04:00
Mike Pellegrini 45da83bd72
Add Bulk Scorer For ToParentBlockJoinQuery (#13697) 2024-09-11 15:02:49 +02:00
Adrien Grand 3da48d0403
Rename FieldInfo(s)#hasVectors to hasTermVectors. (#13759)
This will help remove confusion between dense numeric vectors and term
vectors.
2024-09-11 13:19:56 +02:00
Egor Potemkin 02b37670e4
DrillSideways#search: use bounded wildcard for the list of drill-sideways CollectorManagers (#13750)
Lists are invariant, so current API doesn't allow passing something like List<CollectorManagerImplementation> where `class CollectorManagerImplementation implements CollectorManager<A, B>`. Invariant makes it so `List<CollectorManagerImplementation>` does not extend `List<CollectorManager<A, B>>`. Using bounded wildcard type allows to overcome that.
2024-09-11 11:14:03 +01:00
mrhbj 029c3b5e13
Modernize switch statements in FST (#13756) 2024-09-11 09:46:48 +02:00
Dawid Weiss ccccf92abd Nightly gh action 'buildAndPushRelease and smokeTestRelease.py' should save release.log on failure #13754 2024-09-11 08:07:08 +02:00
Patrick Zhai 7c529ce092
Implement Accountable for NFARunAutomaton (#13741) 2024-09-10 17:35:37 -07:00
Chris Hegarty e4efae6ab9
Provide a custom hash implementation in HnswLock (#13751)
This commit is a micro optimisation to the HNSW Lock implementation, which avoids integer and vararg boxing when determining the hash of the node and level. Trivially we provide our own arity specialised hash, rather than the more generic java.util.Objects.hash(Object...).
2024-09-10 22:55:43 +01:00
Luca Cavanna d3130e2e9e Address compile errors due to MatchingDocs conversion to a record 2024-09-10 23:36:16 +02:00
Luca Cavanna fafd6af004
Add support for intra-segment search concurrency (#13542)
This commit introduces support for optionally creating slices that target leaf reader context partitions, which allow them to be searched concurrently. This is good to maximize resource usage when searching force-merged indices, or indices with rather big segments, by parallelizig search execution across subsets of segments being searched.
    
Note: this commit does not affect default generation of slices. Segments can be partitioned by overriding the `IndexSearcher#slices(List<LeafReaderContext>)` method to plug in ad-hoc slices creation. Moreover, the existing  `IndexSearcher#slices` static method now creates segment partitions when the additional `allowSegmentsPartitions` argument is set to `true`.
  
The overall design of this change is based on the existing search concurrency support that is based on `LeafSlice` and `CollectorManager`. A new `LeafReaderContextPartition` abstraction is introduced, that holds a reference to a `LeafReaderContext` and the range of doc ids it targets. A `LeafSlice` noew targets segment partitions, each identified by a `LeafReaderContext` instance and a range of doc ids. It is possible for a partition to target a whole segment, and for partitions of different segments to be combined into the same leaf slices freely, hence searched by the same thread. It is not possible for multiple partitions of the same segment to be added to the same leaf slice.
    
Segment partitions are searched concurrently leveraging the existing `BulkScorer#score(LeafCollector collector, Bits acceptDocs, int min, int max)` method, that allows to score a specific subset of documents for a provided
 `LeafCollector`, in place of the `BulkScorer#score(LeafCollector collector, Bits acceptDocs)` that would instead score all documents.

## Changes that require migration

The migrate guide has the following new clarifying items around the contract and breaking changes required to support intra-segment concurrency:
- `Collector#getLeafCollector` may be called multiple times for the same leaf across distinct `Collector` instances created by a `CollectorManager`. Logic that relies on `getLeafCollector` being called once per leaf per search needs updating.
- a `Scorer`, `ScorerSupplier` or `BulkScorer` may be requested multiple times for the same leaf
- `IndexSearcher#searchLeaf` change of signature to accept the range of doc ids
- `BulkScorer#score(LeafCollector, BitSet)` is removed in favour of `BulkScorer#score(LeafCollector, BitSet, int, int)`
-  static `IndexSearcher#slices` method changed to take a last boolean argument that optionally enables the creation of segment partitions
- `TotalHitCountCollectorManager` now requires that an array of `LeafSlice`s, retrieved via `IndexSearcher#getSlices`, 
is provided to its constructor
 
    
Note: `DrillSideways` is the only component that does not support intra-segment concurrency and needs considerable work to do so, due to its requirement that the entire set of docs in a segment gets scored in one go.
    
The default searcher slicing is not affected by this PR, but `LuceneTestCase` now randomly leverages intra-segment concurrency. An additional `newSearcher` method is added that takes a `Concurrency` enum as the last argument in place of the `useThreads` boolean flag. This is important to disable intra-segment concurrency for `DrillSideways` related tests that do support inter-segment concurrency but not intra-segment concurrency.

## Next step

While this change introduces support for intra-segment concurrency, it only sets up the foundations of it. There is still a performance penalty for queries that require segment-level computation ahead of time, such as points/range queries. This is an implementation limitation that we expect to improve in future releases, see #13745.

Additionally, we will need to decide what to do about the lack of support for intra-segment concurrency in `DrillSideways` before we can enable intra-segment slicing by default. See #13753 .

Closes #9721
2024-09-10 23:22:39 +02:00
Shubham Chaudhary 942065cc3e
Convert more classes to record classes (#13328) 2024-09-10 23:08:24 +02:00
Stefan Vodita 955986d836 Remove redundant initialisation in DynamicRangeUtil 2024-09-10 21:03:45 +00:00
panguixin 6634b41f42
Replace Map<String,Object> with IntObjectHashMap for DV producer (#13686) 2024-09-10 22:57:10 +02:00
Shubham Chaudhary 97ca2c42e8
Reorder checks in LRUQueryCache#count (#13742) 2024-09-10 22:45:14 +02:00
Stefan Vodita 0d579338ee
Add dynamic range facets (#13689) 2024-09-10 17:24:28 +01:00
Robert Muir 634eff1851
remove snake case parameter names in RegexpQuery (#13734) 2024-09-10 07:00:35 -04:00
Chris Hegarty 64f5697f53
Add migration note about the deprecation of optional RegExp complement syntax (#13732)
This commit adds a migration note about the deprecation of optional RegExp complement support.
2024-09-09 20:35:35 +01:00
Luca Cavanna 3bcd65206a Remove author name from migrate entry 2024-09-09 20:11:49 +02:00
Luca Cavanna a89bfa57ad
Propagate keepScores to reduced FacetsCollector (#13744)
We recently introduced support for keepScores to FacetsCollectorManager.
The returned reduced FacetsCollector instance though does not reflect that in
that its inner keepScores flag is always false. This commit fixes that.
2024-09-09 16:00:02 +02:00
Robert Muir 22bbc603b4
Add deprecated complement (~) operator to RegExp (#13739)
Previously all regexp parsing required determinization and minimization up-front, which can be costly (exponential time).

Lucene 10 removes the determinization and minimization from RegExp and allows the user to choose:

* determinize() the result and get the DFA query execution of previous releases.
* don't determinize() and possibly get a new NFA query that determinizes-as-it-goes.

Complement of arbitrary automata is incompatible with this choice, as it requires determinization for correctness. It was previously a non-default operator that could be enabled with a special flag: RegExp.COMPLEMENT, or would be included with RegExp.ALL, which turns on all special syntax flags. Lucene 10 removed the operator, as it can't be supported while still giving the user the NFA/DFA choice, and requires exponential time during parsing.

To ease transition: add RegExp.DEPRECATED_COMPLEMENT syntax flag and Kind.DEPRECATED_COMPLEMENT node:
* syntax flag can be enabled with RegExp(s, RegExp.DEPRECATED_COMPLEMENT);
* syntax flag is **NOT** included by RegExp.ALL: e.g. you must do RegExp(s, RegExp.ALL | RegExp.DEPRECATED_COMPLEMENT) to get ALL flags and also the deprecated complement (~) operator. This enforces a java deprecation reference in the calling code to enable the flag.
* deprecated complement (~) runs with an internal limit: Operations.DEFAULT_DETERMINIZE_WORK_LIMIT. It is not configurable. If it is exceeded, you get TooComplexToDeterminize() exception.
* there is intentionally only a single dead-simple test so that this hack doesn't cause us pain with CI/builds. We don't want random automata testing to only rarely encounter an exponential algorithm!

After lucene 10 is branched, this deprecated support can be removed by reverting this commit.
2024-09-09 08:05:00 -04:00
Greg Miller dc47adbbe7 Fixup javadoc for new FacetsCollectorManager static search methods 2024-09-06 15:45:34 -07:00
Luca Cavanna 47c0a6ed18
Replace static FacetsCollector#search methods (#13733)
We have a few public static utility search methods in FacetsCollector that accept
a Collector as last argument. In practice, these are expected to be called
providing a `FacetsCollector` as last argument. Also, we'd like to remove all
the search methods that take a `Collector` in favour of those that take a
`CollectorManager` (see #12892).

This commit adds the corresponding functionality to `FacetsCollectorManager`.
The new methods take a `FacetsCollectorManager` as last argument. The return type
has to be adapted to include also the facets results that were before made
available through the collector argument.

In order for tests to all work I had to add support for `keepScores` to
`FacetsCollectorManager` which was missing.

Closes #13725
2024-09-06 22:46:59 +02:00
Luca Cavanna 0ec453d485 [TEST] Disable concurrency in TestTaxonomyFacetAssociations#testFloatAssociationRandom
The test relies on ordering which requires sequential execution.
2024-09-06 21:00:57 +02:00
Luca Cavanna 0b8ae220be
Remove leftover search(Query, Collector) usages in TestTaxonomyFacetAssociations (#13726) 2024-09-06 11:57:52 +02:00