Commit Graph

37709 Commits

Author SHA1 Message Date
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
Dawid Weiss d7dc57dd0d
jgit/ clean status check should ignore any 'untracked folders' (#13728)
* Ignore any 'untracked folders' #13719
* Upgrade jgit to 6.10.0.202406032230-r.
2024-09-06 09:01:15 +02:00
Luca Cavanna 5f242b3b26
Dry up TestScorerPerf (#13712)
Some of the test methods were commented out when this test class was added. They got later removed
but the removal left unused method behind. I also adjusted visibility of all the internal methods
that were public and should have been private, which led me to further clean up: `MatchingHitCollector`
was not needed and can be removed.
2024-09-05 20:05:46 +02:00
Adrien Grand 4c27bccac5
Early exit from Operations#removeDeadStates when an automaton doesn't have dead states. (#13721) 2024-09-05 16:50:31 +02:00
Adrien Grand a414a96eee Operations#sameLanguage moved to AutomatonTestUtil. 2024-09-05 16:03:29 +02:00
Chris Hegarty 67c0f8e847
Determinize automata used by IntervalsSource.regex (#13718)
This commit determinizes internal automata used in the construction of the IntervalsSource created by the regexp factory.
2024-09-05 14:15:24 +01:00
Adrien Grand 11d7566229
Make Operations#repeat create simpler automata. (#13714)
`Operations#repeat` currently creates an automaton that has one more final
state, and 2x more transitions for each of the final states. With this change,
the returned automaton has a single final state and only 2x more transitions
for state 0.
2024-09-05 15:08:26 +02:00
Uwe Schindler e8440956b9 Remove useless Serializable interface 2024-09-05 14:55:12 +02:00
Uwe Schindler 9d7b07738a Merge branch 'main' of https://gitbox.apache.org/repos/asf/lucene 2024-09-05 14:37:16 +02:00
Uwe Schindler 67ca244ef1 Clean up forbiddenapis: No need to serialize and deserialize the package private class 2024-09-05 14:37:04 +02:00
Robert Muir ea3a9b8927
Relax Operations.isTotal() to work with a deterministic automaton (#13707)
Improve Operations.isTotal() to work with non-minimal automata.
2024-09-05 08:36:10 -04:00
Robert Muir 87bc8270ff
move Operations.sameLanguage/subsetOf to AutomatonTestUtil in test-framework (#13708)
This code is suitable for tests only and may throw unexpected Exceptions or AssertionErrors for some input.
2024-09-05 06:59:55 -04:00
Luca Cavanna b91b4136af
Reduce size of queue in TestBoolean2#testRandomQueries (#13713)
The queue is created as 1000 * mulFactor, but the test succeeds without the 1000 factor.
That causes out of memories as the mulFactor can be as high as 4096 in some cases, and then
each slice will get a collector with a queue of size 1000 * mulFactor. Only the allocation of
such queue makes the test go OOM.

Closes #11754
2024-09-04 16:06:19 +02:00
Egor Potemkin c21bc5405b
Remove CollectorOwner class (#13702) 2024-09-03 17:34:50 -07:00
Luca Cavanna 10420c6c47 Added missing migrate entry for #13602 2024-09-03 09:49:18 +02:00
Ignacio Vera 68cc8734ca
Fix integer overflow in GeoEncodingUtils#Grid implementations (#13704)
* Fix integer overflow in GeoEncodingUtils#Grid implementations

* Add entry in CHANGES.txt
2024-09-02 12:13:53 +02:00
Dawid Weiss ce4f56e74a Add jdk 23-ea to nightly smoke tester run. #13700 2024-08-30 18:19:47 +02:00
Christoph Büscher 6d373dbb4e
Remove IOException from MultiTermQuery#getTermsCount (#13701)
Neither this method nor any of the two overrides can throw an IOException.
This change removes the throws clauses from this method in order simplify
not have to handle them on the callers side.
2024-08-30 14:00:32 +01:00
Dawid Weiss ea1441c81c
Upgrade to gradle 8.10 (#13700) 2024-08-30 12:36:56 +02:00
Luca Cavanna 9172cc4247
Udpate ReadTask to not rely on search(Query, Collector) (#13602)
This commit modifies ReadTask to no longer call the deprecated search(Query, Collector).
Instead, it creates a collector manager and calls search(Query, CollectorManager).

The existing protected createCollector method is removed in favour of createCollectorManager that returns
now a CollectorManager in place of a Collector.

SearchWithCollectorTask works the same way if "topScoreDoc" is provided as config. Loading of a custom collector
will no longer work, and needs to be replaced with loading a collector manager by class name instead.
2024-08-29 10:53:53 +02:00
Uwe Schindler e45b5ebdf8
Fix Gradle build sometimes gives spurious "unreferenced license file" warnings (#13696)
Revert changes by #12150 in jar-checks.gradle, because tasks in this file share internal state between tasks without using files. Because of this all tasks here must always execute together, so they cannot define task outputs.
2024-08-28 20:35:26 +02:00
Adrien Grand 79fd9fee97
Speed up advancing within a block. (#13692)
Advancing within a block consists of finding the first index within an array of
128 values whose value is greater than or equal a target. Given the small size,
it's not obvious whether it's better to perform a linear search, a binary
search or something else... It is surprisingly hard to beat the linear search
that we are using today.

Experiments suggested that the following approach works in practice:
 - First check if the next item in the array is greater than or equal to the
   target.
 - Then find the first 4-values interval that contains our target.
 - Then perform a branchless binary search within this interval of 4 values.

This approach still biases heavily towards the case when the target is very
close to the current index, only a bit less than a linear search.
2024-08-28 17:31:08 +02:00
Michael McCandless d55b92bae0
adding a few toString methods for HNSW scoring classes (#13694) 2024-08-28 10:15:40 -04:00
Stefan Vodita 385f56ba22
Remove mention of SolrNamedThreadFactory (#13690) 2024-08-28 11:07:56 +01:00
Owais Kazi 0f5359a2ac
Fixed exponent value in explain of SigmoidFunction (#13691)
* Fixed exponent in explain of SigmoidFunction

Signed-off-by: Owais <owaiskazi19@gmail.com>

* Updated CHANGES.txt

Signed-off-by: Owais <owaiskazi19@gmail.com>

---------

Signed-off-by: Owais <owaiskazi19@gmail.com>
2024-08-27 16:12:58 -04:00
pierwill 054295fd38
Edit HNSW API docs (#13688)
* Edit HNSW API docs for clarity, readability, punctuation, etc.

Co-authored-by: pierwill <pierwill@users.noreply.github.com>
2024-08-26 14:17:59 -04:00
Greg Miller 3e3a7db1db move GH#13672 entry under 10.0 2024-08-26 10:32:01 -07:00
Greg Miller 6d19a35de3 fixup CHANGES entry for GH#13592 2024-08-26 10:30:15 -07:00
Greg Miller 68882c8b89
Leverage doc value skip lists in DocValuesRewriteMethod if indexed (#13672) 2024-08-26 10:04:12 -07:00
Mike Pellegrini 4e3945ed54
Use Max WAND optimizations with ToParentBlockJoinQuery when using ScoreMode.Max (#13587) 2024-08-26 14:43:48 +02:00
ChrisHegarty e850cd1c86 reconcile changes txt 2024-08-23 15:04:41 +01:00
Chris Hegarty ad81402791
Support JDK 23 in Panama Vectorization Provider (#13678)
This commit updates the Vectorization Provider to support JDK 23. The API has not changed so the changes minimally bump the major JDK check, and enable the incubating API during testing
2024-08-22 13:51:32 +01:00
Ignacio Vera 579427228d
Take advantage of the doc value skipper when it is primary sort (#13592)
Take advantage of the doc value skipper when it is primary sort in SortedNumericDocValuesRangeQuery
 and SortedSetDocValuesRangeQuery.
2024-08-22 12:28:25 +02:00
Armin Braun b4a06770c9
Release memory for cancelled tasks earlier in TaskExecutor (#13609)
We can save some memory in failure scenarios here (and a tiny bit in
every case) by moving our started flag to the `FutureTask` and using the
callable outright. First of all, we save the wrapper callable, but that
also allows us to just `set(null)` on cancellation instead of waiting
for the task to run to set the `null`.
In case we have longer running tasks executing and it would take a while
to get to the cancelled tasks, this saves some memory and allows us to
return from the method earlier.
2024-08-21 21:25:09 +02:00
Michael Sokolov c52ddd83bf
import definition of default parameter values from o.a.l.util.HnswGraphBuilder (#13674) 2024-08-21 14:06:45 -04:00
Adrien Grand 2971ce1b7f
Display frame types when analyzing top frames. (#13670)
This helps understand if a given frame is interpreted, compiled or inlined for instance.
2024-08-20 23:36:51 +02:00