Commit Graph

36700 Commits

Author SHA1 Message Date
Benjamin Trent 05d26ac44d
Refactor Lucene95 to allow off heap vector reader reuse (#12629)
While going through: https://github.com/apache/lucene/pull/12582

I noticed that for a while now, our offheap vector readers haven't changed at all. We just keep copying them around for no reason.

To make adding a new vector codec simpler, this refactors the lucene95 codec to allow its offheap vector storage format (readers/writers) to be used. 

Additionally, it will handle writing the appropriate fields for sparse vectors (read/write) to a provided index output/inputs.

This should reduce the churn in new codecs significantly.
2023-10-10 14:53:54 -04:00
Dzung Bui 04f38dd288
Move addNode to FSTCompiler (#12646)
Currently FSTCompiler and FST have circular dependencies to each 
other. FSTCompiler creates an instance of FST, and on adding node 
(add(IntsRef input, T output)), it delegates to FST.addNode() and passes
itself as a variable. This introduces a circular dependency and mixes up 
the FST constructing and traversing code.

To make matter worse, this implies one can call FST.addNode with an 
arbitrary FSTCompiler (as it's a parameter), but in reality it should be 
the compiler which creates the FST.

This commit moves the addNode method to FSTCompiler instead.

Co-authored-by: Anh Dung Bui <buidun@amazon.com>
2023-10-10 13:34:57 +01:00
gf2121 65d2227f83
Avoid duplicate array fill in BPIndexReorderer (#12645) 2023-10-10 15:10:09 +08:00
gf2121 4f01de2a2d
Write MSB VLong for better outputs sharing in block tree index (#12631) 2023-10-10 14:00:21 +08:00
gf2121 e20e245f47
DeletedTerms#clear should reset ByteBlockPool (#12630) 2023-10-10 13:42:17 +08:00
Patrick Zhai 33a3af4260 Add a little bit more hint to releaseWizard 2023-10-09 17:05:23 -03:00
Piotrek Żygieło dfff1e6358
Avoid NPEx if the end of the stream has been reached without reading any characters (#12611)
e.g. by user responding with ^D
```
Press (n)ext page, (q)uit or enter number to jump to a page.
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.length()" because "line" is null
	at org.apache.lucene.demo.SearchFiles.doPagingSearch(SearchFiles.java:244)
	at org.apache.lucene.demo.SearchFiles.main(SearchFiles.java:152)
```

```
Press (p)revious page, (n)ext page, (q)uit or enter number to jump to a page.
n
Only results 1 - 50 of 104 total matching documents collected.
Collect more (y/n) ?
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.length()" because "line" is null
	at org.apache.lucene.demo.SearchFiles.doPagingSearch(SearchFiles.java:198)
	at org.apache.lucene.demo.SearchFiles.main(SearchFiles.java:152)
```

Co-authored-by: Piotrek Żygieło <pzygielo@users.noreply.github.com>
2023-10-09 08:11:59 +02:00
Robert Muir ce3a904465
add tests for vectorutils integer boundaries (#12634) 2023-10-08 11:26:33 -04:00
Kaival Parikh 2474940bff
Allow implementers of AbstractKnnVectorQuery to access final topK results (#12590)
* Make AbstractKnnVectorQuery#createRewrittenQuery protected

* Add explicit method to merge per-segment results

* Add javadocs explaining the new method

* Run gradlew tidy

---------

Co-authored-by: Kaival Parikh <kaivalnp@amazon.com>
2023-10-05 15:14:59 -04:00
Adrien Grand 91019d685a
Compute better windows in MaxScoreBulkScorer. (#12593)
MaxScoreBulkScorer computes windows based on the set of clauses that were
essential in the *previous* window. This usually works well as the set of
essential clauses tends to be stable over time, but there are cases when
clauses get swapped between essential and non-essential clauses, and computing
windows based on the previous window can lead to suboptimal choices.

This PR creates a first proposal for the next score window using essential
clauses from the previous window, and then creates a second proposal once
scorers have been partitioned and their max scores have been updated. If this
second proposal results in a smaller window, it gets used.

On one particular query (`the incredibles`) and a reordered index with BP
(which increases chances that scorers move from essential to non-essential or
vice-versa), this change yielded a 2.3x speedup.
2023-10-05 12:46:57 +02:00
gf2121 28f0885bdf
Use a MergeSorter taking advantage of extra storage for StableMSBRadixSorter (#12623) 2023-10-05 04:31:23 -05:00
Michael Peterson 7371493478
TaskExecutor waits for all tasks to complete before returning (#12523)
The TaskExecutor used to run concurrent operations may leave running tasks behind when an exception is thrown by one of the tasks. This commit ensures that it instead waits for all tasks to complete before it re-throws the exception. If there's more than one exception thrown, they are going to be added as suppressed exceptions to the first one that was caught.
2023-10-05 10:25:10 +02:00
iverase ba74da1dc0 Change CHANGES entry to 10 2023-10-04 16:46:11 +02:00
Ignacio Vera c4694c31fd
Add readBytes method to RandomAccessInput (#12600)
Adds a new method to RandomAccessInput tio bulk read bytes into a provided byte array.
2023-10-04 16:23:42 +02:00
gf2121 96052891e6
Reduce FST block size for BlockTreeTermsWriter (#12604) 2023-10-04 01:58:56 -05:00
Kevin Risden 75da33836b
avoid-circular-jar-checks (#12618) 2023-10-03 16:44:55 -04:00
Benjamin Trent 6b7d311c0c
Minor refactor for HNSW graph merging logic (#12616)
This is a minor refactor of HNSW graph merging logic.

Instead of directly checking the KnnVectorReader version, this commit adjusts the logic to see if a specific interface is satisfied for returning a view of the HnswGraph.
2023-10-03 14:28:10 -04:00
Grigoriy Troitskiy 1baae3629a
Make LRUQueryCache respect Accountable queries on eviction and consistency check (#12614)
Given a query that implements Accountable, the LRUQueryCache would increment
its internal accounting by the amount reported by Accountable.ramBytesUsed(), but
only decrement on eviction by the default used for all other queries.  This meant that 
the cache could eventually think it had run out of space, even if there were no queries 
in it at all.  This commit ensures that queries that implement Accountable are always 
accounted for correctly.
2023-10-03 14:52:12 +01:00
Adrien Grand 3f81f2f315 Fix excessive skipping in `BlockMaxConjunctionBulkScorer`. 2023-10-03 11:34:07 +02:00
Luca Cavanna 2106bf5172
Create a task executor when executor is not provided (#12606)
As we introduce more places where we add concurrency (there are
currently three) there is a common pattern around checking whether there
is an executor provided, and then going sequential on the caller thread
or parallel relying on the executor.

That can be improved by internally creating a TaskExecutor that relies
on an executor that executes tasks on the caller thread, which ensures
that the task executor is never null, hence the common conditional is no
longer needed, as the concurrent path that uses the task executor would
be the default and only choice for operations that can be parallelized.
2023-10-03 09:13:45 +02:00
Luca Cavanna 1dd05c89b0
Add missing create github release step to release wizard (#12607)
The "create github release" step was missing from the release wizard. We have forgotten about it a few times recently.

While at it, I also expanded the instructions around closing the current milestone and moved them after removing opened issues / PRs from the current milestone.
2023-10-02 19:59:23 +02:00
Luca Cavanna e93cdd1270
Simplify TaskExecutor API (#12603)
We recently made TaskExecutor public. It currently exposes two methods:
one to create tasks given a collection of callables, and one to execute
all tasks created at step 1. We can rather expose a single public method
that takes a collection of callables which internally creates the
appropriate tasks. This simplifies the API, and stops us from leaking
the internal Task abstraction which can be kept private.

Note that this is backwards compatible as we have not released yet a
version where the TaskExecutor was made public. It is marked
experimental anyways.
2023-10-02 11:07:06 +02:00
elliotzlin 4cff584a48
LUCENE-10520 / #11556 HTMLStripCharFilter bugfix (#11724)
Add generated HTMLStripCharFilter and update tests to reflect correct char filter behavior
2023-10-02 08:50:04 +02:00
Uwe Schindler 6930b57ff5
Upgrade forbiddenapis to 3.6 and ASM for APIJAR extraction to 9.6 (#12612) 2023-10-01 16:29:14 +02:00
gf2121 3cb71436a7
Sort update terms with stable radix sorter (#12591) 2023-09-29 20:11:29 -05:00
Patrick Zhai fbce75e50c Add back-compat indices for 9.8.0 2023-09-29 14:32:09 -07:00
Patrick Zhai f658b83566 Sync CHANGES for 9.8.0 2023-09-29 14:01:17 -07:00
Christine Poerschke 411b7fd518
SuggestIndexSearcher.suggest catches any CollectionTerminatedException (theoretically) thrown by getLeafCollector (#12609) 2023-09-29 12:14:50 +01:00
Christine Poerschke e02f1b1d29
IndexingChain.validateMaxVectorDimension: add missing space in IllegalArgumentException wording (#12605) 2023-09-29 12:14:29 +01:00
Patrick Zhai f01f3679bb DOAP changes for release 9.8.0 2023-09-28 11:34:29 -07:00
Ignacio Vera 6d764c3397
Add length method to RandomAccessInput (#12594)
Add RandomAccessInput#length method to the RandomAccessInput interface. In addition it deprecates
  ByteBuffersDataInput#size in favour of this new method.
2023-09-27 13:00:50 +02:00
Luca Cavanna f559cac755
Shared executor for LuceneTestCase#newSearcher callers (#12588)
Until now, LuceneTestCase#newSearcher randomly associates the returned
IndexSearcher instance with an executor that is ad-hoc created, which
gets shut down when the index reader is closed.

This has made us catch a couple of cases where we were not properly
closing readers in tests. Most recently, we have been seeing test
failures (OOM - unable to create thread) due to too many executor
instances created as part of the same test. This is to be attributed to
creating too many searcher instance, each one getting its separate
executor, which all get shutdown at the end of the entire suite. The
main offender for this is QueryUtils which creates a new searcher for
each leaf reader, and the top-level reader gets closed in the
AfterClass, hence all the executors will stay around for the entire
duration of the test suite that relies on QueryUtils.

This commit eagerly creates an executor in an additional before class
method for LuceneTestCase, and associates that with each searcher that
is supposed to get a non null executor.

Note that the executor is shutdown in the after class to ensure that
no threads leak in tests.

This has the additional advantage that it removes the need to close the
executor as part of an index reader close listener, which also requires
the reader to have an associated reader cache helper.
2023-09-25 17:00:59 +02:00
Adrien Grand ce464c7d6d Fix test failure. 2023-09-25 13:54:08 +02:00
Adrien Grand 483d28853a Move CHANGES entry to correct version. 2023-09-25 13:38:53 +02:00
Adrien Grand f2bd0bbcdd
Run top-level conjunctions of term queries with a specialized BulkScorer. (#12382)
This implements a specialized `BlockMaxConjunctionBulkScorer`, which is really
the same as `BlockMaxConjunctionScorer`, but as a `BulkScorer` instead of a
`Scorer`. Also it doesn't support two-phase iterators in order to focus on the
common case when queries, such as term queries, do not have two-phase
iterators. If a clause has a two-phase iterator, it will keep running as a
`BlockMaxConjunctionScorer` wrapped in a `DefaultBulkScorer`.
2023-09-25 13:36:44 +02:00
Ignacio Vera d48913a957
Allow reading / writing binary stored fields as DataInput (#12581)
This commit adds the possibility to read / write binary stored values using a DataInput and the number of bytes. By default the implementations will allocate those bytes in a newly created byte array and call the already existing method.
2023-09-25 11:09:32 +02:00
gf2121 8b84f6c096
Use radix sort to speed up the sorting of deleted terms (#12573) 2023-09-22 13:33:01 +08:00
Shubham Chaudhary fb1f4dd412
Make TermStates#build concurrent (#12183) 2023-09-21 17:17:36 +02:00
Luca Cavanna 3deead0ed3
Remove deprecated IndexSearcher#getExecutor method (#12580)
Use getTaskExecutor instead. This is important to enforce tracking of
tasks that run in each thread.

Relates to #12578
2023-09-21 12:30:32 +02:00
Tyler Bertrand e43bea4fa4
Resolve CompileJava task cache miss (#12577)
Resolve CompileJava task cache miss. Implement CommandLineArgumentProvider to give relative path sensitivity to apiJar file
2023-09-21 10:42:20 +02:00
Luca Cavanna 1cb0d81b40
Make TaskExecutor public (#12574)
TaskExecutor is currently package private. We have scenarios where we
want to parallelize the execution and reuse it outside of its package,
hence this commit makes it public (and experimental).

Note that its constructor remains package private as it is supposed to
be created by the index searcher, and later retrieved from it via the
appropriate getter, which is also made public as part of this commit.

Co-authored-by: gf2121 <52390227+gf2121@users.noreply.github.com>
2023-09-20 15:27:56 +02:00
Luca Cavanna 24207096c0 Move change entry for #12569 from 9.8 to 9.9 2023-09-20 12:21:47 +02:00
Luca Cavanna 937ebd4296
Prevent concurrent tasks from parallelizing further (#12569)
Concurrent search is currently applied once per search call, either when
search is called, or when concurrent query rewrite happens. They
generally don't happen within one another. There are situations in which
we are going to introduce parallelism in places where there could be
multiple inner levels of parallelism requested as each task could try to
parallelize further. In these cases, with certain executor
implementations, like ThreadPoolExecutor, we may deadlock as we are
waiting for all tasks to complete but they are waiting for threads to
free up to complete their execution.

This commit introduces a simple safeguard that makes sure that we only
parallelize via the executor at the top-level invokeAll call. When each
task tries to parallelize further, we just execute them directly instead
of submitting them to the executor.

Co-authored-by: Adrien Grand <jpountz@gmail.com>
2023-09-20 12:00:13 +02:00
Patrick Zhai 51ade888f3 Update wrong PR number in CHANGES.txt 2023-09-19 23:37:36 -07:00
Patrick Zhai ac62c58d46 Update wrong PR number in CHANGES.txt 2023-09-19 23:29:53 -07:00
Patrick Zhai f5d5dc289e Update wrong PR number in CHANGES.txt 2023-09-19 23:24:17 -07:00
Patrick Zhai 94b879a593 Add next minor version 9.9.0 2023-09-19 22:54:14 -07:00
Tony-X ca69ae6d98
Make FSTPostingsFormat load FSTs off-heap (#12552)
* Make FSTPostingsFormat load FSTs off-heap
2023-09-19 16:29:23 -04:00
Benjamin Trent fe348de619
Fix HNSW graph reading with excessive connections (#12571)
When re-using the HNSW graph during segment merges, it is possible that more than the configured M*2 connections could be made per vector.

In those instances, we should allow the graph to still be read from the codec and searchable.
2023-09-19 15:38:23 -04:00
Adrien Grand 1d0edd76a5 Fix compilation under Java 11. 2023-09-19 12:15:38 +02:00