Skip to content

Commit

Permalink
Clean Code
Browse files Browse the repository at this point in the history
Signed-off-by: Vikasht34 <[email protected]>
  • Loading branch information
Vikasht34 committed Feb 13, 2025
1 parent b1afdef commit dad6872
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public ScalarQuantizationParams getQuantizationParams() {
*/
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(Version.CURRENT.id); // Write the versionF
out.writeVInt(Version.CURRENT.id); // Write the version
quantizationParams.writeTo(out);
out.writeFloatArray(meanThresholds);
out.writeOptionalArray(belowThresholdMeans != null ? new FloatArrayWrapper[] { new FloatArrayWrapper(belowThresholdMeans) } : null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
*/
@UtilityClass
class QuantizerHelper {

//This value can change based on Experiments.
private static final double ROTATION_MATRIX_THRESHOLD = 0.6;
/**
* Calculates the quantization state using the provided training data and sampled indices.
* <p>
Expand Down Expand Up @@ -48,7 +51,7 @@ static OneBitScalarQuantizationState calculateQuantizationState(
double averageL2L1Ratio = meanAndL2L1.getB();
// Apply random rotation if L2/L1 ratio is greater than 0.6
float[][] rotationMatrix = null;
if (averageL2L1Ratio > 0.6) {
if (averageL2L1Ratio > ROTATION_MATRIX_THRESHOLD) {
int dimensions = meanThresholds.length;
rotationMatrix = RandomGaussianRotation.generateRotationMatrix(dimensions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public void testFlush_WithQuantization() {
final Long expectedTimesGetVectorValuesIsCalled = vectorsPerField.stream().filter(Predicate.not(Map::isEmpty)).count();
knnVectorValuesFactoryMockedStatic.verify(
() -> KNNVectorValuesFactory.getVectorValues(any(VectorDataType.class), any(DocsWithFieldSet.class), any()),
times(Math.toIntExact(expectedTimesGetVectorValuesIsCalled) * 1)
times(Math.toIntExact(expectedTimesGetVectorValuesIsCalled))
);
}
}
Expand Down

0 comments on commit dad6872

Please sign in to comment.