Commit Graph

37587 Commits

Author SHA1 Message Date
Benjamin Trent 07b37eea71
Add test case to ensure scalar quantization adheres to known ranges (#13336)
Lucene provides int7 & int4 quantization, we should ensure via our tests that the quantized values are within expected ranges.
2024-05-02 09:25:04 -04:00
Benjamin Trent 7d87a773fd
Fix TestHnswBitVectorsFormat.testIndexAndSearchBitVectors flakiness (#13333) 2024-05-02 07:58:22 -04:00
Benjamin Trent e40e1086f5
Improve int4 compressed comparisons performance (#13321)
This updates the int4 dot-product comparison to have an optimized one for when one of the vectors are compressed (the most common search case). This change actually makes the compressed search on ARM faster than the uncompressed. However, on AVX512/256, it still slightly slower than uncompressed, but it still much faster now with this optimization than before (eagerly decompressing).

This optimized is tied tightly with how the vectors are actually compressed and stored, consequently, I added a new scorer that is within the lucene99 codec.

So, this gives us 8x reduction over float32, well more than 2x faster queries than float32, and no need to rerank as the recall and accuracy are excellent.
2024-05-01 10:05:51 -04:00
Uwe Schindler e6dac3400d
Improve MissingDoclet linter to check records correctly (#13332)
Improve MissingDoclet linter to check records correctly:
- exclude default ctors
- exclude accessor methods (like with enums)
- on "method" level checking also check that every record component has an @param tag
2024-04-30 18:00:06 +02:00
Robert Muir 9af3ef8952
IndexWriter: Treat java.lang.Error as tragedy (#13277)
Background:
Historically IndexWriter treated OutOfMemoryError special, for defensive
reasons. It was expanded to VirtualMachineError, to try to play it safe
in similar disastrous circumstances.

We should treat any Error as a tragedy, as it isn't an Exception, and it
isn't something a "reasonable" application should catch. IndexWriter
should be reasonable. See #7049 for some of the reasoning.

We can't pretend this will detect any possible scenario that might cause
harm, e.g. a jvm bug might simply miscompile some code and cause silent
corruption. But we should try harder by playing by the rules.

Closes #13275
Closes #7049
2024-04-23 21:40:22 -04:00
zhouhui fb12e09ab5
Narrow MASKS and UTF8Byte.value's type, assign MASKS by left shift in UTF32ToUTF8 (#13310)
* Change MASKS from int[] to byte[], and assign it with left shift.

* Only set first byte for tmpUTF8.

* Only set first byte value for tmp utf8.

* Change value type from int to byte.

* Remove stale comment.
2024-04-23 10:21:01 -04:00
zhouhui 3c8467d353
Remove unnecessary assert, fix comment. (#13279) 2024-04-23 10:11:59 -04:00
Shubham Chaudhary d57267a0e6
Fix TestLucene90FieldInfosFormat.testRandom (#13135) 2024-04-22 09:40:40 +01:00
zhouhui 3024e66e4a
Use Arrays.compareUnsigned instead of iterating compare. (#13252) 2024-04-19 10:01:16 +02:00
Zhang Chao 1f1181a079
Do not use mock merge policy for TestSimilarity (#13314) 2024-04-18 09:50:40 +08:00
Zhang Chao f665bd196e
Fix test failure TestKnnByteVectorQuery#testTimeLimitingKnnCollectorManager (#13312) 2024-04-18 09:48:11 +08:00
Benjamin Trent 3d86ff2e6a
Add BitVectors format and make flat vectors format easier to extend (#13288)
Instead of making a separate thing pluggable inside of the FieldFormat, this instead keeps the vector similarities as they are, but allows a custom scorer to be provided to the FlatVector storage used by HNSW. 

This idea is akin to the compression extensions we have. But in this case, its for vector scorers. 

To show how this would work in practice, I took the liberty of adding a new HnswBitVectorsFormat in the sandbox module.

A larger part of the change is a refactor of the `RandomAccessVectorValues<T>` to remove the `<T>`. Nothing actually uses that any longer, and we should instead rely on well defined classes and stop relying on casting with generics (yuck).
2024-04-17 13:13:51 -04:00
Vigya Sharma bc678ac67e
Use jdk11 primitives in test to allow backport to branch_9x (#13311) 2024-04-16 23:17:43 -07:00
Benjamin Trent 3ba7ebbad8
Add more backwards compability tests for Scalar quantization (#13298)
This adds more backwards compatibility coverage for scalar quantization. Adding a test that forces the older metadata version to be written and ensures that it can still be read.
2024-04-16 09:08:30 -04:00
Sanjay Dutt dcb512289f
Convert FieldEntry to record (#13296)
Co-authored-by: iamsanjay <sanjaydutt.india@yahoo.com>
2024-04-16 11:34:44 +02:00
Zhang Chao dca87235be
Fix test failure TestDocumentsImpl.testGetDocumentFields (#13303) 2024-04-15 21:56:51 +08:00
Tim Grein 1c3c094227
Use Float.compare/Double.compare instead of '==' in geo classes (#13301)
when using == to compare the floats -0.0 and 0.0 they will be considered equal but their hashcode is different.
2024-04-15 21:54:33 +08:00
Mayya Sharipova 0345fcabb3
UnifiedHighlighter highlight on multiple fields (#13268)
Add ability to UnifiedHighlighter to combine matches from multiple fields
to highlight a single field.

FastVectorHighlighter for a long time has an option to highlight a single field
based on matches from several fields. But UnifiedHighlighter was missing this option.

This adds this ability with a new function: `UnifiedHighlighter::withMaskedFieldsFunc` 
that sets up a function that given a field retuns a set of masked fields whose matches 
are combined  to highlight the given field.
2024-04-12 06:36:25 -04:00
Adrien Grand e19238a7bd
Increase the default number of merge threads. (#13294)
You need as many merge threads as necessary to make sure that merges can keep
up with indexing. But this number depends on the data that you are indexing: if
you are only indexing stored fields, merges can copy compressed data directly
and merges are only a small fraction of the total indexing+flushing+merging
cost. But if you primary index knn vectors, merging N docs may require about as
much work as flushing N docs. If you add the fact that documents typically go
through multiple rounds of merging, the merging cost can end up being more than
half of the total indexing+flushing+merging cost.

This change proposes to update the default number of merge threads assuming an
intermediate scenario where merges perform about half of the total
indexing+flushing+merging work, ie. it gives half the threads of the system to
merges.

One goal of this change is to no longer have to configure a custom number of
merge threads on nightly benchmarks, which run on a highly concurrent machine.
2024-04-11 21:21:28 +02:00
Adrien Grand fbea47b4f4 Tidy 2024-04-11 21:16:42 +02:00
Adrien Grand 927f081fb0
Disable ConcurrentMergeScheduler's auto I/O throttling by default. (#13293)
This is motivated by the fact that merges can hardly steal all I/O resources
from searches on modern NVMe drives. Merges are still not allowed to use all
CPU since they have a budget for the number of threads which is a fraction of
the number of threads that the host can run.

Closes #13193
2024-04-11 18:42:54 +02:00
zhouhui 0016c79c46
Remove unnecessary calculating for termLen. (#13291) 2024-04-11 08:04:27 -04:00
Christine Poerschke f44ded0c95
fix s/Long/Fixed in FixedBitSet javadocs (#13290) 2024-04-11 11:21:49 +01:00
Adrien Grand c22c913063 Move MIGRATE entry to the correct section. 2024-04-11 10:47:26 +02:00
Sanjay Dutt 66b121f9b0
Remove deprecated code (#13286)
Co-authored-by: iamsanjay <sanjaydutt.india@yahoo.com>
2024-04-11 09:44:29 +02:00
Kaival Parikh 13cf882677
Fix failing BaseKnnVectorQueryTestCase#testTimeout (#13283)
* Fix failing BaseKnnVectorQueryTestCase#testTimeout

* Also fix ParentBlockJoinKnnVectorQueryTestCase#testTimeout

---------

Co-authored-by: Kaival Parikh <kaivalp2000@gmail.com>
2024-04-10 20:43:01 -07:00
gf2121 203cf7b553
Simplify bytes arrays in NumericLeafComparator to long (#13246) 2024-04-10 16:57:56 +08:00
Adrien Grand 26fe2c4b9c
Move per-field vector and doc-values readers from TreeMap to HashMap. (#13284)
Our per-field vector and doc-values readers use `TreeMap`s but don't rely on
the iteration order, so these `TreeMap`s can be replaced with more
CPU/RAM-efficient `HashMap`s.

The per-field postings reader stays on a `TreeMap` since it relies on the
iteration order.
2024-04-09 15:59:10 +02:00
Dawid Weiss afe982b3ef
Schedule compileJava after the internal task if it affects source files (#13282) 2024-04-09 07:44:07 +02:00
Pulkit Gupta df0384c34f
Remove Accountable interface in KnnVectorsReader (#13255) 2024-04-08 13:51:42 +02:00
Adrien Grand 4c843fc9ae Update CHANGES after #13267. 2024-04-05 21:51:24 +02:00
Adrien Grand 1b98db5ca1
Propagate the flush IOContext to stored fields / term vectors writers when index sorting is enabled. (#13265)
This fixes index sorting to pass the correct `IOContext` to stored fields and
term vectors writers when index sorting is enabled. This is important for
things like `NRTCachingDirectory`.
2024-04-05 21:10:51 +02:00
Benjamin Trent 767bd3aa91
Revert version files to not include unreleased version (#13274) 2024-04-05 12:34:19 -04:00
Stefan Vodita 9ba4af7b88
Reduce duplication in taxonomy facets; always do counts (#12966)
This is a large change, refactoring most of the taxonomy facets code and changing internal behaviour, without changing the API. There are specific API changes this sets us up to do later, e.g. retrieving counts from aggregation facets.

1. Move most of the responsibility from TaxonomyFacets implementations to TaxonomyFacets itself. This reduces code duplication and enables future development. Addresses genericity issue mentioned in #12553.
2. As a consequence, introduce sparse values to FloatTaxonomyFacets, which previously used dense values always. This issue is part of #12576.
3. Compute counts for all taxonomy facets always, which enables us to add an API to retrieve counts for association facets in the future. Addresses #11282.
4. As a consequence of having counts, we can check whether we encountered a label while faceting (count > 0), while previously we relied on the aggregation value to be positive. Closes #12585.
5. Introduce the idea of doing multiple aggregations in one go, with association facets doing the aggregation they were already doing, plus a count. We can extend to an arbitrary number of aggregations, as suggested in #12546.
6. Don't change the API. The only change in behaviour users should notice is the fix for non-positive aggregation values, which were previously discarded.
7. Add tests which were missing for sparse/dense values and non-positive aggregations.
2024-04-05 12:28:47 +01:00
Robert Muir 02bc51a753
move TestBugInSomething to analysis.tests
This test is setup to reproduce complex failures from TestRandomChains,
e.g. it has SopFilter and other tools for debugging. But it still
resides in the analysis/common module and currently can't be used to
debug any TestRandomChains failures that use other modules (e.g. icu).

relates to #13271
2024-04-04 16:52:35 -04:00
Benjamin Trent 88c0909210
Test mute for issue #13272 (#13273) 2024-04-04 16:21:32 -04:00
Zach Chen 5b5a02d0cd
GITHUB-13218: Add migrate entry for Collector to CollectorManager migration (#13238) 2024-04-04 12:53:12 -07:00
Uwe Schindler f7db975fc4
Make the default ReadAdvice configurable by sysprop (#13264) 2024-04-04 18:42:31 +02:00
Adrien Grand 4ea2bae119
Use `ReadAdvice#RANDOM` when appropriate. (#13222)
This switches the following files to `ReadAdvice.RANDOM`:
 - Stored fields data file.
 - Term vectors data file.
 - HNSW graph.
 - Temporary file storing vectors at merge time that we use to construct the
   merged HNSW graph.
 - Vector data files, including quantized data files.

I hesitated using `ReadAdvice.RANDOM` on terms, since they have a random access
pattern when running term queries, but a more sequential access pattern when
running multi-term queries. I erred on the conservative side and did not switch
them to `ReadAdvice.RANDOM` for now.

For simplicity, I'm only touching the current codec, not previous codecs. There
are also some known issues:
 - These files will keep using a `RANDOM` `ReadAdvice` at merge time. We need
   some way for merge instances to get an updated `IOContext`? We have the same
   problem with `IOContext#LOAD` today.
 - With quantized vectors, raw vectors don't have random access pattern, but it
   was challenging to give raw vectors a sequential access pattern when there
   are quantized vectors and a random access pattern otherwise. So they assume a
   random access pattern all the time.
2024-04-04 18:31:13 +02:00
Benjamin Trent 6104c86abc
Correct quantized HNSW validation to be in-line with HNSW (#13263)
When intra-merge parallelism was introduced, the validation that numWorkers must ==1 with a null executor service was removed from Lucene99HnswVectorsFormat. However, I forgot to remove that validation from Lucene99HnswScalarQuantizedVectorsFormat.

This corrects that mistake, allowing Lucene99HnswScalarQuantizedVectorsFormat and Lucene99HnswVectorsFormat to take advantage of the merge-schedulers intra-merge threading.
2024-04-04 12:05:25 -04:00
Pulkit Gupta 2ee537ce16
Convert BooleanClause class to record class (#13261) 2024-04-04 17:51:48 +02:00
Adrien Grand a2676b1b26
Use ReadAdvice.RANDOM by default. (#13244)
This switches the default `ReadAdvice` from `NORMAL` to `RANDOM`, which is a better fit for the kind of access pattern that Lucene has. This is expected to reduce page cache trashing and contention on the page table.

`NORMAL` is still available, but never used by any of the file formats.
2024-04-04 16:45:41 +02:00
Robert Muir 54a2e11434
upgrade icu4j to 74.2 (#13239)
* fix regeneration, upgrade icu jar, fully regenerate sources, tests pass
* Upgrade RBBI grammar to match 74.2 (add instructions on how to do this)
* Make use of Script_Extensions property in tokenization
* document and test nfkc_scf form
* update tokenizer for improved text in UAX#24 5.2
* use indic syllablic category for myanmar tokenizer instead of relying on Gc
2024-04-04 08:35:25 -04:00
Michael Sokolov 342c814caf
BaseVectorSimilarityQueryTestCase assumes connected hnsw graph (#13260) 2024-04-04 08:31:02 -04:00
Kaival Parikh df154cdc22
Add timeout support to AbstractKnnVectorQuery (#13202)
* Add timeout support to graph searches in AbstractKnnVectorQuery

* Also timeout exact searches

* Return partial KNN results

* Add tests for partial KNN results

- Refactor tests to base classes
- Also timeout exact searches in Lucene99HnswVectorsReader

* Add CHANGES.txt entry and fix some comments

---------

Co-authored-by: Kaival Parikh <kaivalp2000@gmail.com>
2024-04-03 06:53:24 -07:00
Benjamin Trent 45c4f8c052
Adds bwc indices for 9.10.1 (#13258) 2024-04-03 07:42:24 -04:00
Zhang Chao 9c9f934a7c
Simplify PackedInts#longCount (#13256) 2024-04-03 16:46:53 +08:00
Benjamin Trent 07d3be59af
Expand scalar quantization with adding half-byte (int4) quantization (#13197)
This PR is a culmination of some various streams of work:

 - Confidence interval optimizations, unlocked even smaller quantization bytes.
 - The ability to quantize down smaller than just int8 or int7
 - Adding an optimized int4 (halfbyte) vector API comparison for dot-product.

The idea of further scalar quantization gives users the choice between:

 - Further quantizing to gain space through compressing the bits into single byte values
 - Or allowing quantization to give guarantees around maximal values that afford faster vector operations.

I didn't add more panama vector APIs as I think trying to micro-optimize int4 for anything other than dot-product was a fools errand. Additionally, I only focused on ARM. I experimented with trying to get better performance on other architectures, but didn't get very far, so I fall back to dotProduct.
2024-04-02 13:38:40 -04:00
Mike McCandless bf193a7125 #13149: move CHANGES entry under 9.11.0 2024-04-02 09:59:34 -04:00
Anton Hägerstrand 4eeb3a792d
Made DocIdsWriter use DISI when reading documents with an IntersectVisitor (#13149)
* Made DocIdsWriter use DISI when reading documents with an IntersectVisitor.

Instead of calling IntersectVisitor.visit for each doc in the
readDelta16 and readInts32 methods, create a DocIdSetIterator
and call IntersectVisitor.visit(DocIdSetIterator) instead.

This seems to make Lucene faster at sorting and range querying
tasks - the hypothesis being that it is due to fewer virtual calls.

* Spotless

* Changed bulk iteration to use IntsRef instead.

* Clearer comment.

* Decrease cost outside loop

* Added test to make inverse intsref be used.

* Wording improvement in javadoc.

* Added CHANGES.txt entry.
2024-04-02 09:44:31 -04:00