jpountz commented on code in PR #13298: URL: https://github.com/apache/lucene/pull/13298#discussion_r1566470754
########## lucene/core/src/java/org/apache/lucene/codecs/lucene99/Lucene99ScalarQuantizedVectorsWriter.java: ########## @@ -98,18 +98,49 @@ public final class Lucene99ScalarQuantizedVectorsWriter extends FlatVectorsWrite private final FlatVectorsWriter rawVectorDelegate; private final byte bits; private final boolean compress; + private final int version; private boolean finished; public Lucene99ScalarQuantizedVectorsWriter( + SegmentWriteState state, Float confidenceInterval, FlatVectorsWriter rawVectorDelegate) + throws IOException { + this( + state, + confidenceInterval, + Lucene99ScalarQuantizedVectorsFormat.VERSION_START, + (byte) 7, + false, + rawVectorDelegate); + } + + public Lucene99ScalarQuantizedVectorsWriter( + SegmentWriteState state, + Float confidenceInterval, + byte bits, + boolean compress, + FlatVectorsWriter rawVectorDelegate) + throws IOException { + this( + state, + confidenceInterval, + Lucene99ScalarQuantizedVectorsFormat.VERSION_ADD_BITS, + bits, + compress, + rawVectorDelegate); + } + + private Lucene99ScalarQuantizedVectorsWriter( SegmentWriteState state, Float confidenceInterval, + int version, Review Comment: nit: it's a bit awkward to have the version between two higher-level configuration options of this writer, what about putting it just after the `SegmentWriteState`? ########## lucene/backward-codecs/src/test/org/apache/lucene/backward_codecs/lucene99/Lucene99RWHnswScalarQuantizationVectorsFormat.java: ########## @@ -0,0 +1,81 @@ +/* + * 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. + */ + +package org.apache.lucene.backward_codecs.lucene99; + +import java.io.IOException; +import org.apache.lucene.codecs.FlatVectorsFormat; +import org.apache.lucene.codecs.FlatVectorsReader; +import org.apache.lucene.codecs.FlatVectorsWriter; +import org.apache.lucene.codecs.KnnVectorsFormat; +import org.apache.lucene.codecs.KnnVectorsReader; +import org.apache.lucene.codecs.KnnVectorsWriter; +import org.apache.lucene.codecs.lucene99.Lucene99FlatVectorsFormat; +import org.apache.lucene.codecs.lucene99.Lucene99HnswScalarQuantizedVectorsFormat; +import org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsFormat; +import org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsReader; +import org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsWriter; +import org.apache.lucene.codecs.lucene99.Lucene99ScalarQuantizedVectorsReader; +import org.apache.lucene.codecs.lucene99.Lucene99ScalarQuantizedVectorsWriter; +import org.apache.lucene.index.SegmentReadState; +import org.apache.lucene.index.SegmentWriteState; + +class Lucene99RWHnswScalarQuantizationVectorsFormat extends KnnVectorsFormat { Review Comment: Nit: maybe extend `Lucene99HnswScalarQuantizationVectorsFormat` and not extend the read logic, this would help increase chances that changes to `Lucene99HnswScalarQuantizationVectorsFormat` would be reflected on this class? ########## lucene/core/src/java/org/apache/lucene/codecs/lucene99/Lucene99ScalarQuantizedVectorsWriter.java: ########## @@ -453,10 +492,6 @@ private ScalarQuantizedCloseableRandomVectorScorerSupplier mergeOneFieldToIndex( quantizationDataInput, quantizationDataInput.length() - CodecUtil.footerLength()); long vectorDataLength = quantizedVectorData.getFilePointer() - vectorDataOffset; CodecUtil.retrieveChecksum(quantizationDataInput); - float confidenceInterval = - this.confidenceInterval == null - ? calculateDefaultConfidenceInterval(fieldInfo.getVectorDimension()) - : this.confidenceInterval; Review Comment: I'm not sure why we can remove it now, is it unrelated to the rest of the change? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org