Skip to content

Commit

Permalink
Rename variables
Browse files Browse the repository at this point in the history
Signed-off-by: Vijayan Balasubramanian <[email protected]>
  • Loading branch information
VijayanB committed Oct 8, 2024
1 parent 0893e1f commit 76f8a41
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class NativeEngines990KnnVectorsFormat extends KnnVectorsFormat {
/** The format for storing, reading, merging vectors on disk */
private static FlatVectorsFormat flatVectorsFormat;
private static final String FORMAT_NAME = "NativeEngines990KnnVectorsFormat";
private static int buildVectorDatastructureThreshold;
private static int approximateThreshold;

public NativeEngines990KnnVectorsFormat() {
this(new Lucene99FlatVectorsFormat(new DefaultFlatVectorScorer()));
Expand All @@ -41,10 +41,10 @@ public NativeEngines990KnnVectorsFormat(final FlatVectorsFormat flatVectorsForma
this(flatVectorsFormat, KNNSettings.INDEX_KNN_ADVANCED_APPROXIMATE_THRESHOLD_DEFAULT_VALUE);
}

public NativeEngines990KnnVectorsFormat(final FlatVectorsFormat flatVectorsFormat, int buildVectorDatastructureThreshold) {
public NativeEngines990KnnVectorsFormat(final FlatVectorsFormat flatVectorsFormat, int approximateThreshold) {
super(FORMAT_NAME);
NativeEngines990KnnVectorsFormat.flatVectorsFormat = flatVectorsFormat;
NativeEngines990KnnVectorsFormat.buildVectorDatastructureThreshold = buildVectorDatastructureThreshold;
NativeEngines990KnnVectorsFormat.approximateThreshold = approximateThreshold;
}

/**
Expand All @@ -54,7 +54,7 @@ public NativeEngines990KnnVectorsFormat(final FlatVectorsFormat flatVectorsForma
*/
@Override
public KnnVectorsWriter fieldsWriter(final SegmentWriteState state) throws IOException {
return new NativeEngines990KnnVectorsWriter(state, flatVectorsFormat.fieldsWriter(state), buildVectorDatastructureThreshold);
return new NativeEngines990KnnVectorsWriter(state, flatVectorsFormat.fieldsWriter(state), approximateThreshold);
}

/**
Expand All @@ -73,8 +73,8 @@ public String toString() {
+ this.getClass().getSimpleName()
+ ", flatVectorsFormat="
+ flatVectorsFormat
+ ", buildVectorDatastructureThreshold"
+ buildVectorDatastructureThreshold
+ ", approximateThreshold="
+ approximateThreshold
+ ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ public class NativeEngines990KnnVectorsWriter extends KnnVectorsWriter {
private KNN990QuantizationStateWriter quantizationStateWriter;
private final List<NativeEngineFieldVectorsWriter<?>> fields = new ArrayList<>();
private boolean finished;
private final Integer buildVectorDataStructureThreshold;
private final Integer approximateThreshold;

public NativeEngines990KnnVectorsWriter(
SegmentWriteState segmentWriteState,
FlatVectorsWriter flatVectorsWriter,
Integer buildVectorDataStructureThreshold
Integer approximateThreshold
) {
this.segmentWriteState = segmentWriteState;
this.flatVectorsWriter = flatVectorsWriter;
this.buildVectorDataStructureThreshold = buildVectorDataStructureThreshold;
this.approximateThreshold = approximateThreshold;
}

/**
Expand Down Expand Up @@ -111,7 +111,7 @@ public void flush(int maxDoc, final Sorter.DocMap sortMap) throws IOException {
"Skip building vector data structure for field: {}, as liveDoc: {} is less than the threshold {} during flush",
fieldInfo.name,
totalLiveDocs,
buildVectorDataStructureThreshold
approximateThreshold
);
continue;
}
Expand Down Expand Up @@ -151,7 +151,7 @@ public void mergeOneField(final FieldInfo fieldInfo, final MergeState mergeState
"Skip building vector data structure for field: {}, as liveDoc: {} is less than the threshold {} during merge",
fieldInfo.name,
totalLiveDocs,
buildVectorDataStructureThreshold
approximateThreshold
);
return;
}
Expand Down Expand Up @@ -287,9 +287,9 @@ private void initQuantizationStateWriterIfNecessary() throws IOException {
}

private boolean shouldSkipBuildingVectorDataStructure(final long docCount) {
if (buildVectorDataStructureThreshold < 0) {
if (approximateThreshold < 0) {
return true;
}
return docCount < buildVectorDataStructureThreshold;
return docCount < approximateThreshold;
}
}
4 changes: 2 additions & 2 deletions src/testFixtures/java/org/opensearch/knn/KNNRestTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -775,12 +775,12 @@ protected Settings getKNNSegmentReplicatedIndexSettings() {
.build();
}

protected Settings buildKNNIndexSettings(int buildVectorDatastructureThreshold) {
protected Settings buildKNNIndexSettings(int approximateThreshold) {
return Settings.builder()
.put("number_of_shards", 1)
.put("number_of_replicas", 0)
.put(KNN_INDEX, true)
.put(INDEX_KNN_ADVANCED_APPROXIMATE_THRESHOLD, buildVectorDatastructureThreshold)
.put(INDEX_KNN_ADVANCED_APPROXIMATE_THRESHOLD, approximateThreshold)
.build();
}

Expand Down

0 comments on commit 76f8a41

Please sign in to comment.