|
76 | 76 | import org.apache.cassandra.index.sai.disk.format.Version;
|
77 | 77 | import org.apache.cassandra.index.sai.disk.v1.SegmentMetadata;
|
78 | 78 | import org.apache.cassandra.index.sai.disk.v2.V2VectorPostingsWriter;
|
79 |
| -import org.apache.cassandra.index.sai.disk.v3.V3OnDiskFormat; |
80 | 79 | import org.apache.cassandra.index.sai.disk.v5.V5OnDiskFormat;
|
81 | 80 | import org.apache.cassandra.index.sai.disk.v5.V5VectorPostingsWriter;
|
82 | 81 | import org.apache.cassandra.index.sai.disk.v5.V5VectorPostingsWriter.Structure;
|
@@ -211,23 +210,27 @@ else if (compressor instanceof BinaryQuantization)
|
211 | 210 | indexConfig.getNeighborhoodOverflow(1.2f),
|
212 | 211 | indexConfig.getAlpha(dimension > 3 ? 1.2f : 1.4f),
|
213 | 212 | indexConfig.isHierarchyEnabled() && jvectorVersion >= 4,
|
214 |
| - compactionSimdPool, compactionFjp); |
| 213 | + true, // We always refine during compaction |
| 214 | + compactionSimdPool, |
| 215 | + compactionFjp); |
215 | 216 |
|
216 | 217 | termsFile = perIndexComponents.addOrGet(IndexComponentType.TERMS_DATA).file();
|
217 | 218 | termsOffset = (termsFile.exists() ? termsFile.length() : 0)
|
218 | 219 | + SAICodecUtils.headerSize();
|
219 | 220 | // placeholder writer, will be replaced at flush time when we finalize the index contents
|
220 |
| - writer = createTermsWriterBuilder().withMapper(new OrdinalMapper.IdentityMapper(maxRowsInGraph)).build(); |
| 221 | + writer = createTermsWriter(new OrdinalMapper.IdentityMapper(maxRowsInGraph)); |
221 | 222 | writer.getOutput().seek(termsFile.length()); // position at the end of the previous segment before writing our own header
|
222 | 223 | SAICodecUtils.writeHeader(SAICodecUtils.toLuceneOutput(writer.getOutput()));
|
223 | 224 | }
|
224 | 225 |
|
225 |
| - private OnDiskGraphIndexWriter.Builder createTermsWriterBuilder() throws IOException |
| 226 | + private OnDiskGraphIndexWriter createTermsWriter(OrdinalMapper ordinalMapper) throws IOException |
226 | 227 | {
|
227 | 228 | return new OnDiskGraphIndexWriter.Builder(builder.getGraph(), termsFile.toPath())
|
228 | 229 | .withStartOffset(termsOffset)
|
229 | 230 | .with(new InlineVectors(dimension))
|
230 |
| - .withVersion(Version.current().onDiskFormat().jvectorFileFormatVersion()); |
| 231 | + .withVersion(Version.current().onDiskFormat().jvectorFileFormatVersion()) |
| 232 | + .withMapper(ordinalMapper) |
| 233 | + .build(); |
231 | 234 | }
|
232 | 235 |
|
233 | 236 | @Override
|
@@ -446,7 +449,7 @@ public SegmentMetadata.ComponentMetadataMap flush() throws IOException
|
446 | 449 | }
|
447 | 450 |
|
448 | 451 | // Recreate the writer with the final ordinalMapper
|
449 |
| - writer = createTermsWriterBuilder().withMapper(ordinalMapper.get()).build(); |
| 452 | + writer = createTermsWriter(ordinalMapper.get()); |
450 | 453 |
|
451 | 454 | // write the graph edge lists and optionally fused adc features
|
452 | 455 | var start = System.nanoTime();
|
|
0 commit comments