Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Enhancements
* Add script for loading vector data using Parquet [192](https://github.com/opensearch-project/opensearch-jvector/issues/192)
* Update script and main docs with minor fixes [196] (https://github.com/opensearch-project/opensearch-jvector/pull/196)
* Support deletes for incremental insertion [203](https://github.com/opensearch-project/opensearch-jvector/pull/203)
### Bug Fixes
### Infrastructure
### Documentation
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

version=1.0.0
systemProp.bwc.version=1.3.4
jvector_version=4.0.0-rc.4
jvector_version=4.0.0-rc.6
java_release_version=21

# org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ public GraphNodeIdToDocMap(IndexInput in) throws IOException {
for (int ord = 0; ord < size; ord++) {
final int docId = in.readVInt();
graphNodeIdsToDocIds[ord] = docId;
docIdsToGraphNodeIds[docId] = ord;
if (docId != -1) {
// ignore deleted documents
docIdsToGraphNodeIds[docId] = ord;
}
}
}

Expand All @@ -68,18 +71,19 @@ public GraphNodeIdToDocMap(int[] graphNodeIdsToDocIds) {
// We are going to assume that the number of ordinals is roughly the same as the number of documents in the segment, therefore,
// the mapping will not be sparse.
if (maxDocs < graphNodeIdsToDocIds.length) {
throw new IllegalStateException("Max docs " + maxDocs + " is less than the number of ordinals " + graphNodeIdsToDocIds.length);
}
if (maxDocId > graphNodeIdsToDocIds.length) {
log.warn(
"Max doc id {} is greater than the number of ordinals {}, this implies a lot of deleted documents. Or that some documents are missing vectors. Wasting a lot of memory",
maxDocId,
"Max docs {} is less than the number of ordinals {}, this implies a lot of deleted documents. Or that some documents are missing vectors. Wasting a lot of memory",
maxDocs,
graphNodeIdsToDocIds.length
);
}
this.docIdsToGraphNodeIds = new int[maxDocs];
Arrays.fill(this.docIdsToGraphNodeIds, -1); // -1 means no mapping to ordinal
for (int ord = 0; ord < graphNodeIdsToDocIds.length; ord++) {
// -1 means no mapping to docId since document was deleted
if (graphNodeIdsToDocIds[ord] == -1) {
continue;
}
this.docIdsToGraphNodeIds[graphNodeIdsToDocIds[ord]] = ord;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class JVectorFormat extends KnnVectorsFormat {
// Unfortunately, this can't be managed yet by the OpenSearch ThreadPool because it's not supporting {@link ForkJoinPool} types
public static final ForkJoinPool SIMD_POOL_MERGE = getPhysicalCoreExecutor();
public static final ForkJoinPool SIMD_POOL_FLUSH = getPhysicalCoreExecutor();
public static final ForkJoinPool PARALLELISM_POOL = ForkJoinPool.commonPool();

private final int maxConn;
private final int beamWidth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void search(String field, float[] target, KnnCollector knnCollector, Bits
// Logic works as follows: if acceptDocs is null, we accept all ordinals. Otherwise, we check if the jVector ordinal has a
// corresponding Lucene doc ID accepted by acceptDocs filter.
io.github.jbellis.jvector.util.Bits compatibleBits = ord -> acceptDocs == null
|| acceptDocs.get(jvectorLuceneDocMap.getLuceneDocId(ord));
|| (jvectorLuceneDocMap.getLuceneDocId(ord) != -1 && acceptDocs.get(jvectorLuceneDocMap.getLuceneDocId(ord)));

try (var graphSearcher = new GraphSearcher(index)) {
final var searchResults = graphSearcher.search(
Expand Down
Loading
Loading