kaivalnp commented on code in PR #15979: URL: https://github.com/apache/lucene/pull/15979#discussion_r3398774637
########## lucene/core/src/java/org/apache/lucene/codecs/dedup/DedupFlatVectorsFormat.java: ########## @@ -0,0 +1,133 @@ +/* + * 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.codecs.dedup; + +import java.io.IOException; +import org.apache.lucene.codecs.hnsw.FlatVectorScorerUtil; +import org.apache.lucene.codecs.hnsw.FlatVectorsFormat; +import org.apache.lucene.codecs.hnsw.FlatVectorsReader; +import org.apache.lucene.codecs.hnsw.FlatVectorsScorer; +import org.apache.lucene.codecs.hnsw.FlatVectorsWriter; +import org.apache.lucene.codecs.lucene90.IndexedDISI; +import org.apache.lucene.index.SegmentReadState; +import org.apache.lucene.index.SegmentWriteState; +import org.apache.lucene.search.DocIdSetIterator; +import org.apache.lucene.store.IndexOutput; + +/** + * Flat vector format that stores each unique vector exactly once per segment. Multiple documents + * (within the same field, and across fields with matching {@code (dimension, encoding)}) may share + * the same physical vector, dramatically reducing on-disk size when many docs/fields point at the + * same vector data. + * + * <p>The format groups fields into "pools" keyed by {@code (dimension, encoding)}. All fields in + * the same pool share unique-vector storage; per-field metadata records how each doc-ord maps to a + * vector-ord within the pool. + * + * <h2>.dvc (deduped vector data) file</h2> Review Comment: Makes sense, will change ########## lucene/core/src/java/org/apache/lucene/codecs/dedup/DedupFlatVectorsFormat.java: ########## @@ -0,0 +1,133 @@ +/* + * 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.codecs.dedup; + +import java.io.IOException; +import org.apache.lucene.codecs.hnsw.FlatVectorScorerUtil; +import org.apache.lucene.codecs.hnsw.FlatVectorsFormat; +import org.apache.lucene.codecs.hnsw.FlatVectorsReader; +import org.apache.lucene.codecs.hnsw.FlatVectorsScorer; +import org.apache.lucene.codecs.hnsw.FlatVectorsWriter; +import org.apache.lucene.codecs.lucene90.IndexedDISI; +import org.apache.lucene.index.SegmentReadState; +import org.apache.lucene.index.SegmentWriteState; +import org.apache.lucene.search.DocIdSetIterator; +import org.apache.lucene.store.IndexOutput; + +/** + * Flat vector format that stores each unique vector exactly once per segment. Multiple documents + * (within the same field, and across fields with matching {@code (dimension, encoding)}) may share + * the same physical vector, dramatically reducing on-disk size when many docs/fields point at the + * same vector data. + * + * <p>The format groups fields into "pools" keyed by {@code (dimension, encoding)}. All fields in + * the same pool share unique-vector storage; per-field metadata records how each doc-ord maps to a + * vector-ord within the pool. + * + * <h2>.dvc (deduped vector data) file</h2> + * + * <ul> + * <li>For each pool, in pool-id order: + * <ul> + * <li>64-byte aligned for FLOAT32 (4-byte aligned for BYTE) + * <li>{@code uniqueCount * dim * byteSize} raw vector bytes, addressed by vec-ord + * </ul> + * <li>For each field, in declaration order: + * <ul> + * <li>If sparse: DISI bitset for docsWithField, written by {@link + * IndexedDISI#writeBitSet(DocIdSetIterator, IndexOutput, byte)}, plus a {@link + * org.apache.lucene.util.packed.DirectMonotonicWriter} ord-to-doc table. + * <li>Packed {@code docOrd -> vecOrd} map, written by {@link + * org.apache.lucene.util.packed.DirectWriter} with {@code ceil(log2(poolUniqueCount))} + * bits per value. + * </ul> + * </ul> + * + * <h2>.dvm (deduped vector metadata) file</h2> Review Comment: Makes sense, will 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
