Upgrade to Lucene 9.2 snapshot efa5d6f4d43 (#86227)

Notable changes include:

count implementations for MultiRangeQuery and IndexSortedNumericDocValuesRangeQuery, which may speed up certain aggregations
more efficient decoding of docids in BKD reader
This commit is contained in:
Alan Woodward 2022-05-05 15:48:13 +01:00 committed by GitHub
parent e590e900a4
commit 4d076eee20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
65 changed files with 140 additions and 38 deletions

View file

@ -1,5 +1,5 @@
elasticsearch = 8.3.0 elasticsearch = 8.3.0
lucene = 9.1.0 lucene = 9.2.0-snapshot-efa5d6f4d43
bundled_jdk_vendor = adoptium bundled_jdk_vendor = adoptium
bundled_jdk = 18+36 bundled_jdk = 18+36

View file

@ -1,8 +1,8 @@
include::{docs-root}/shared/versions/stack/{source_branch}.asciidoc[] include::{docs-root}/shared/versions/stack/{source_branch}.asciidoc[]
:lucene_version: 9.1.0 :lucene_version: 9.2.0
:lucene_version_path: 9_1_0 :lucene_version_path: 9_2_0
:jdk: 11.0.2 :jdk: 11.0.2
:jdk_major: 11 :jdk_major: 11
:build_type: tar :build_type: tar

View file

@ -0,0 +1,5 @@
pr: 86227
summary: Upgrade to Lucene 9.2 snapshot
area: Search
type: upgrade
issues: []

View file

@ -26,7 +26,6 @@ import org.elasticsearch.test.ESTestCase;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.URI;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.AccessDeniedException; import java.nio.file.AccessDeniedException;
@ -158,10 +157,8 @@ public class IOUtilsTests extends ESTestCase {
for (int i = 0; i < numberOfLocations; i++) { for (int i = 0; i < numberOfLocations; i++) {
if (exception && randomBoolean()) { if (exception && randomBoolean()) {
final Path location = createTempDir(); final Path location = createTempDir();
final FileSystem fs = new AccessDeniedWhileDeletingFileSystem(location.getFileSystem()).getFileSystem( final FilterFileSystemProvider fsProvider = new AccessDeniedWhileDeletingFileSystem(location.getFileSystem());
URI.create("file:///") final Path wrapped = fsProvider.wrapPath(location);
);
final Path wrapped = new FilterPath(location, fs);
locations[i] = wrapped.resolve(randomAlphaOfLength(8)); locations[i] = wrapped.resolve(randomAlphaOfLength(8));
Files.createDirectory(locations[i]); Files.createDirectory(locations[i]);
locationsThrowingException.add(locations[i]); locationsThrowingException.add(locations[i]);
@ -246,8 +243,8 @@ public class IOUtilsTests extends ESTestCase {
public void testFsyncAccessDeniedOpeningDirectory() throws Exception { public void testFsyncAccessDeniedOpeningDirectory() throws Exception {
final Path path = createTempDir().toRealPath(); final Path path = createTempDir().toRealPath();
final FileSystem fs = new AccessDeniedWhileOpeningDirectoryFileSystem(path.getFileSystem()).getFileSystem(URI.create("file:///")); final FilterFileSystemProvider fsProvider = new AccessDeniedWhileOpeningDirectoryFileSystem(path.getFileSystem());
final Path wrapped = new FilterPath(path, fs); final Path wrapped = fsProvider.wrapPath(path);
if (Constants.WINDOWS) { if (Constants.WINDOWS) {
// no exception, we early return and do not even try to open the directory // no exception, we early return and do not even try to open the directory
fsync(wrapped, true); fsync(wrapped, true);

View file

@ -1 +0,0 @@
2711abb758d101fc738c35a6867ee7559da5308b

View file

@ -0,0 +1 @@
1755a2c955a53ae73096ec2b72b8982d676554b9

View file

@ -1 +0,0 @@
94d7d107c399cd11d407b94fa62f5677fe86f63b

View file

@ -0,0 +1 @@
563fc02413da6a9e9f6b5afdaf92df66253d16ce

View file

@ -1 +0,0 @@
e9b429da553560fa0c363ffc04c774f957c56e14

View file

@ -0,0 +1 @@
1943e5a73bfed85067862388e931bb1702764547

View file

@ -1 +0,0 @@
b247f8a877237b4663e4ab7d86fae21c68a58ea5

View file

@ -0,0 +1 @@
aa21165b2cbc19ba0cc0b0b3ec675ca2577de80d

View file

@ -1 +0,0 @@
30e24b42fb0440911e702a531f4373bf397eb8c6

View file

@ -0,0 +1 @@
57e5f7a8a10ae291e94db06d0262a757d08952dd

View file

@ -1 +0,0 @@
18a321d93836ea2856a5302d192e9dc99c647c6e

View file

@ -0,0 +1 @@
350720d6ebb8cb0b6296069a35f68d4081992b46

View file

@ -1 +0,0 @@
41c847f39a15bb8495be8c9d8a098974be15f74b

View file

@ -0,0 +1 @@
ec86d5ef7d47ae178dd34f52c0df39bd9b9c4344

View file

@ -1 +0,0 @@
ee7995231b181aa0a01f5aef8775562e269f5ef7

View file

@ -0,0 +1 @@
43ffa0c82753b644b66dfc931cae50ca0d351492

View file

@ -1 +0,0 @@
575c458431396baa7f01a546173807f27b12a087

View file

@ -0,0 +1 @@
8fab9f95101a853faaf86eef58f43f5517e5b679

View file

@ -1 +0,0 @@
240e3997fb139ff001e022124c89b686b5a8498d

View file

@ -0,0 +1 @@
38f13d4a20b4a9aec0307004ee18b87845c5e6e8

View file

@ -1 +0,0 @@
de23bdacb09e8b39cbe876ff79c7a5b2ecc1faa6

View file

@ -0,0 +1 @@
c9ac8533aa40378755539d3722b1ffed08b53b7c

View file

@ -1 +0,0 @@
0375603f1dacd8266526404faf0088a2ac8ec2ff

View file

@ -0,0 +1 @@
8be8ebe2a770686fede2c213fd81d4bb0b9f1590

View file

@ -1 +0,0 @@
703308505e62fa7dcb0bf64fdb6d95d335941bdc

View file

@ -0,0 +1 @@
686821eb6732242e3bedebd67788ded567b63470

View file

@ -1 +0,0 @@
7f1925f6ef985000399a277ca17b8f67d3056838

View file

@ -0,0 +1 @@
5d7032e3c10e79e907748478cb1662335ce42345

View file

@ -1 +0,0 @@
e7d39da8e623c99ee8da8bcc0185b2d908aca4b3

View file

@ -0,0 +1 @@
2a249b6127d5c05c67e16d3e1d3a542d5440629c

View file

@ -1 +0,0 @@
209166fd48dae3261ccf26990fe600332b8fb373

View file

@ -0,0 +1 @@
ad395a9f5a29b793bd431d790bb34bac9dce3b80

View file

@ -1 +0,0 @@
905d93b6389060cf4b0cb464ffa8fa2db81b60e7

View file

@ -0,0 +1 @@
08f39a2036656e70844d68227df79f7eb160d171

View file

@ -1 +0,0 @@
c50fc971573910ea239ee6f275e9257b6b6bdd48

View file

@ -0,0 +1 @@
beb6b98e38261d349da54d7cca367847925a2646

View file

@ -1 +0,0 @@
383eb69b12f9d9c98c44237155f50c870c9a34b9

View file

@ -0,0 +1 @@
5adb8b965bae11f0aa3ce7fa43558d6d1eecffeb

View file

@ -1 +0,0 @@
0c728684e750a63f881998fbe27afd897f739762

View file

@ -0,0 +1 @@
22acf5c5f112bed98fa4dfffbf09d5f17ec298e5

View file

@ -1 +0,0 @@
7717b300bc14dfa9eb4b7d5970d8e25a60010e64

View file

@ -0,0 +1 @@
f57269c7c419a5046792da61cfd1d532f9914390

View file

@ -1 +0,0 @@
957fca507eba94dbc3ef0d02377839be49bbe619

View file

@ -0,0 +1 @@
0ac869cf9e6a5045b2578a0f7fbf2acc88f3ceaf

View file

@ -109,7 +109,7 @@ public class Version implements Comparable<Version>, ToXContentFragment {
public static final Version V_8_1_3 = new Version(8_01_03_99, org.apache.lucene.util.Version.LUCENE_9_0_0); public static final Version V_8_1_3 = new Version(8_01_03_99, org.apache.lucene.util.Version.LUCENE_9_0_0);
public static final Version V_8_2_0 = new Version(8_02_00_99, org.apache.lucene.util.Version.LUCENE_9_1_0); public static final Version V_8_2_0 = new Version(8_02_00_99, org.apache.lucene.util.Version.LUCENE_9_1_0);
public static final Version V_8_2_1 = new Version(8_02_01_99, org.apache.lucene.util.Version.LUCENE_9_1_0); public static final Version V_8_2_1 = new Version(8_02_01_99, org.apache.lucene.util.Version.LUCENE_9_1_0);
public static final Version V_8_3_0 = new Version(8_03_00_99, org.apache.lucene.util.Version.LUCENE_9_1_0); public static final Version V_8_3_0 = new Version(8_03_00_99, org.apache.lucene.util.Version.LUCENE_9_2_0);
public static final Version CURRENT = V_8_3_0; public static final Version CURRENT = V_8_3_0;
private static final Map<Integer, Version> idToVersion; private static final Map<Integer, Version> idToVersion;

View file

@ -11,6 +11,7 @@ package org.elasticsearch.index.engine;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.index.CodecReader; import org.apache.lucene.index.CodecReader;
import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.FilterCodecReader; import org.apache.lucene.index.FilterCodecReader;
import org.apache.lucene.index.FilterDirectoryReader; import org.apache.lucene.index.FilterDirectoryReader;
import org.apache.lucene.index.FilterLeafReader; import org.apache.lucene.index.FilterLeafReader;
@ -23,7 +24,6 @@ import org.apache.lucene.index.SoftDeletesDirectoryReaderWrapper;
import org.apache.lucene.index.SoftDeletesRetentionMergePolicy; import org.apache.lucene.index.SoftDeletesRetentionMergePolicy;
import org.apache.lucene.index.Term; import org.apache.lucene.index.Term;
import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.util.Bits; import org.apache.lucene.util.Bits;
import org.apache.lucene.util.FixedBitSet; import org.apache.lucene.util.FixedBitSet;
import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.lucene.Lucene;
@ -227,7 +227,7 @@ public final class LazySoftDeletesDirectoryReaderWrapper extends FilterDirectory
private Bits init() throws IOException { private Bits init() throws IOException {
assert Thread.holdsLock(this); assert Thread.holdsLock(this);
DocIdSetIterator iterator = DocValuesFieldExistsQuery.getDocValuesDocIdSetIterator(field, reader); DocIdSetIterator iterator = getDocValuesDocIdSetIterator(field, reader);
assert iterator != null; assert iterator != null;
Bits liveDocs = reader.getLiveDocs(); Bits liveDocs = reader.getLiveDocs();
final FixedBitSet bits; final FixedBitSet bits;
@ -274,4 +274,39 @@ public final class LazySoftDeletesDirectoryReaderWrapper extends FilterDirectory
super(delegate); super(delegate);
} }
} }
/**
* Returns a {@link DocIdSetIterator} from the given field or null if the field doesn't exist in
* the reader or if the reader has no doc values for the field.
*/
private static DocIdSetIterator getDocValuesDocIdSetIterator(String field, LeafReader reader) throws IOException {
FieldInfo fieldInfo = reader.getFieldInfos().fieldInfo(field);
final DocIdSetIterator iterator;
if (fieldInfo != null) {
switch (fieldInfo.getDocValuesType()) {
case NONE:
iterator = null;
break;
case NUMERIC:
iterator = reader.getNumericDocValues(field);
break;
case BINARY:
iterator = reader.getBinaryDocValues(field);
break;
case SORTED:
iterator = reader.getSortedDocValues(field);
break;
case SORTED_NUMERIC:
iterator = reader.getSortedNumericDocValues(field);
break;
case SORTED_SET:
iterator = reader.getSortedSetDocValues(field);
break;
default:
throw new AssertionError();
}
return iterator;
}
return null;
}
} }

View file

@ -59,6 +59,11 @@ final class GlobalOrdinalMapping extends SortedSetDocValues {
} }
} }
@Override
public long docValueCount() {
return values.docValueCount();
}
@Override @Override
public BytesRef lookupOrd(long globalOrd) throws IOException { public BytesRef lookupOrd(long globalOrd) throws IOException {
final long segmentOrd = ordinalMap.getFirstSegmentOrd(globalOrd); final long segmentOrd = ordinalMap.getFirstSegmentOrd(globalOrd);

View file

@ -189,6 +189,11 @@ public class MultiOrdinals extends Ordinals {
} }
} }
@Override
public long docValueCount() {
return currentEndOffset - currentOffset;
}
@Override @Override
public BytesRef lookupOrd(long ord) { public BytesRef lookupOrd(long ord) {
return values.lookupOrd(ord); return values.lookupOrd(ord);

View file

@ -459,6 +459,11 @@ class DocumentLeafReader extends LeafReader {
return i; return i;
} }
@Override
public long docValueCount() {
return values.size();
}
@Override @Override
public BytesRef lookupOrd(long ord) { public BytesRef lookupOrd(long ord) {
return values.get((int) ord); return values.get((int) ord);

View file

@ -209,6 +209,11 @@ public class KeyedFlattenedLeafFieldData implements LeafOrdinalsFieldData {
} }
} }
@Override
public long docValueCount() {
return delegate.docValueCount();
}
@Override @Override
public boolean advanceExact(int target) throws IOException { public boolean advanceExact(int target) throws IOException {
if (delegate.advanceExact(target)) { if (delegate.advanceExact(target)) {

View file

@ -275,6 +275,11 @@ public enum MissingValues {
} }
} }
@Override
public long docValueCount() {
return values.docValueCount();
}
@Override @Override
public boolean advanceExact(int doc) throws IOException { public boolean advanceExact(int doc) throws IOException {
hasOrds = values.advanceExact(doc); hasOrds = values.advanceExact(doc);
@ -309,6 +314,11 @@ public enum MissingValues {
} }
} }
@Override
public long docValueCount() {
return values.docValueCount();
}
@Override @Override
public long getValueCount() { public long getValueCount() {
return 1 + values.getValueCount(); return 1 + values.getValueCount();

View file

@ -199,6 +199,11 @@ public class KeyedFlattenedLeafFieldDataTests extends ESTestCase {
return documentOrds[index++]; return documentOrds[index++];
} }
@Override
public long docValueCount() {
return documentOrds.length;
}
@Override @Override
public BytesRef lookupOrd(long ord) { public BytesRef lookupOrd(long ord) {
return allTerms[(int) ord]; return allTerms[(int) ord];

View file

@ -723,6 +723,11 @@ public class MultiValueModeTests extends ESTestCase {
} }
} }
@Override
public long docValueCount() {
return array[doc].length;
}
@Override @Override
public boolean advanceExact(int docID) { public boolean advanceExact(int docID) {
this.doc = docID; this.doc = docID;

View file

@ -876,7 +876,7 @@ public class DateHistogramAggregatorTests extends DateHistogramAggregatorTestCas
.entry( .entry(
"filters", "filters",
matchesList().item( matchesList().item(
matchesMap().entry("query", "DocValuesFieldExistsQuery [field=f]") matchesMap().entry("query", "FieldExistsQuery [field=f]")
.entry("specialized_for", "docvalues_field_exists") .entry("specialized_for", "docvalues_field_exists")
.entry("results_from_metadata", greaterThan(0)) .entry("results_from_metadata", greaterThan(0))
) )

View file

@ -47,6 +47,11 @@ public class BinaryRangeAggregatorTests extends ESTestCase {
return ords[i++]; return ords[i++];
} }
@Override
public long docValueCount() {
return ords.length;
}
@Override @Override
public BytesRef lookupOrd(long ord) { public BytesRef lookupOrd(long ord) {
return terms[(int) ord]; return terms[(int) ord];

View file

@ -66,6 +66,11 @@ public class IncludeExcludeTests extends ESTestCase {
} }
} }
@Override
public long docValueCount() {
return 1;
}
@Override @Override
public BytesRef lookupOrd(long ord) { public BytesRef lookupOrd(long ord) {
assertEquals(0, ord); assertEquals(0, ord);

View file

@ -131,6 +131,11 @@ public class MissingValuesTests extends ESTestCase {
return NO_MORE_ORDS; return NO_MORE_ORDS;
} }
} }
@Override
public long docValueCount() {
return ords[doc].length;
}
}; };
final BytesRef existingMissing = RandomPicks.randomFrom(random(), values); final BytesRef existingMissing = RandomPicks.randomFrom(random(), values);
@ -228,6 +233,11 @@ public class MissingValuesTests extends ESTestCase {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public long docValueCount() {
throw new UnsupportedOperationException();
}
@Override @Override
public BytesRef lookupOrd(long ord) throws IOException { public BytesRef lookupOrd(long ord) throws IOException {
return values[Math.toIntExact(ord)]; return values[Math.toIntExact(ord)];

View file

@ -1 +0,0 @@
e9b429da553560fa0c363ffc04c774f957c56e14

View file

@ -0,0 +1 @@
1943e5a73bfed85067862388e931bb1702764547

View file

@ -98,6 +98,11 @@ public final class LegacySortedSetDocValuesWrapper extends SortedSetDocValues {
return result; return result;
} }
@Override
public long docValueCount() {
throw new UnsupportedOperationException();
}
@Override @Override
public BytesRef lookupOrd(long ord) { public BytesRef lookupOrd(long ord) {
return values.lookupOrd((int) ord); return values.lookupOrd((int) ord);

View file

@ -602,7 +602,7 @@ public class WildcardFieldMapperTests extends MapperTestCase {
String suboptimalTests[][] = { String suboptimalTests[][] = {
// TODO short wildcards like a* OR b* aren't great so we just drop them. // TODO short wildcards like a* OR b* aren't great so we just drop them.
// Ideally we would attach to successors to create (acd OR bcd) // Ideally we would attach to successors to create (acd OR bcd)
{ "[ab]cd", "+(+cc_ +c__) +*:*" } }; { "[ab]cd", "+cc_ +c__" } };
for (String[] test : suboptimalTests) { for (String[] test : suboptimalTests) {
String regex = test[0]; String regex = test[0];
String expectedAccelerationQueryString = test[1].replaceAll("_", "" + WildcardFieldMapper.TOKEN_START_OR_END_CHAR); String expectedAccelerationQueryString = test[1].replaceAll("_", "" + WildcardFieldMapper.TOKEN_START_OR_END_CHAR);