-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Use direct IO when accessing raw vectors for BBQ (when rescoring) #125921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thecoop
merged 24 commits into
elastic:main
from
thecoop:modified-flat-vector-direct-io
Apr 24, 2025
Merged
Changes from 13 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a9be5ea
Copy Lucene99FlatVectorsReader allowing direct IO to be specified dir…
thecoop 359fe69
Merge branch 'main' into modified-flat-vector-direct-io
thecoop 991dd6d
Use DirectIODirectory implementation
thecoop a2ed4c8
Add entitlement
thecoop 08d2a76
Sometimes DirectIO is not available
thecoop 9294c04
Allow for subpaths
thecoop e2f3693
Specify buffer size
thecoop 446caf8
Merge branch 'main' into modified-flat-vector-direct-io
thecoop b0325ce
Only use direct IO in searches
thecoop dd3300f
Merge branch 'main' into modified-flat-vector-direct-io
thecoop 00682ca
Update copyright year and comments
thecoop b51548b
Update comment
thecoop 30092c8
Merge remote-tracking branch 'upstream/main' into modified-flat-vecto…
thecoop 9c86a05
Merge branch 'main' into modified-flat-vector-direct-io
thecoop 22f740d
Use a system property to turn off direct IO if needed
thecoop e258015
Merge branch 'main' into modified-flat-vector-direct-io
thecoop 2b8d4fd
Merge branch 'main' into modified-flat-vector-direct-io
thecoop c7149ff
Tweak the names
thecoop 94dbac0
Add comment
thecoop 521245e
Merge remote-tracking branch 'upstream/main' into modified-flat-vecto…
thecoop b8b714a
Merge branch 'main' into modified-flat-vector-direct-io
thecoop 93a9bdb
Merge branch 'main' into modified-flat-vector-direct-io
thecoop 27c96b3
Merge branch 'main' into modified-flat-vector-direct-io
thecoop 3f90ea5
Add conditions for new reader
thecoop File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...src/main/java/org/elasticsearch/index/codec/vectors/es818/DirectIOIndexInputSupplier.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
package org.elasticsearch.index.codec.vectors.es818; | ||
|
||
import org.apache.lucene.store.IOContext; | ||
import org.apache.lucene.store.IndexInput; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* A hook for {@link ES818FlatVectorsReader} to specify the input should be opened using DirectIO. | ||
* Remove when IOContext allows more extensible payloads to be specified. | ||
*/ | ||
public interface DirectIOIndexInputSupplier { | ||
IndexInput openInputDirect(String name, IOContext context) throws IOException; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
server/src/main/java/org/elasticsearch/index/codec/vectors/es818/ES818FlatVectorsFormat.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* @notice | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* Modifications copyright (C) 2024 Elasticsearch B.V. | ||
*/ | ||
package org.elasticsearch.index.codec.vectors.es818; | ||
|
||
import org.apache.lucene.codecs.hnsw.FlatVectorsFormat; | ||
import org.apache.lucene.codecs.hnsw.FlatVectorsReader; | ||
import org.apache.lucene.codecs.hnsw.FlatVectorsScorer; | ||
import org.apache.lucene.codecs.hnsw.FlatVectorsWriter; | ||
import org.apache.lucene.codecs.lucene99.Lucene99FlatVectorsWriter; | ||
import org.apache.lucene.index.SegmentReadState; | ||
import org.apache.lucene.index.SegmentWriteState; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Copied from Lucene99FlatVectorsFormat in Lucene 10.1 | ||
* | ||
* This is copied to change the implementation of {@link #fieldsReader} only. | ||
* The codec format itself is not changed, so we keep the original {@link #NAME} | ||
*/ | ||
public class ES818FlatVectorsFormat extends FlatVectorsFormat { | ||
thecoop marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
static final String NAME = "Lucene99FlatVectorsFormat"; | ||
static final String META_CODEC_NAME = "Lucene99FlatVectorsFormatMeta"; | ||
static final String VECTOR_DATA_CODEC_NAME = "Lucene99FlatVectorsFormatData"; | ||
static final String META_EXTENSION = "vemf"; | ||
static final String VECTOR_DATA_EXTENSION = "vec"; | ||
|
||
public static final int VERSION_START = 0; | ||
public static final int VERSION_CURRENT = VERSION_START; | ||
|
||
static final int DIRECT_MONOTONIC_BLOCK_SHIFT = 16; | ||
private final FlatVectorsScorer vectorsScorer; | ||
|
||
/** Constructs a format */ | ||
public ES818FlatVectorsFormat(FlatVectorsScorer vectorsScorer) { | ||
super(NAME); | ||
this.vectorsScorer = vectorsScorer; | ||
} | ||
|
||
@Override | ||
public FlatVectorsWriter fieldsWriter(SegmentWriteState state) throws IOException { | ||
return new Lucene99FlatVectorsWriter(state, vectorsScorer); | ||
} | ||
|
||
@Override | ||
public FlatVectorsReader fieldsReader(SegmentReadState state) throws IOException { | ||
return new ES818FlatVectorsReader(state, vectorsScorer); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ES818FlatVectorsFormat(" + "vectorsScorer=" + vectorsScorer + ')'; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.