kaivalnp commented on code in PR #15979:
URL: https://github.com/apache/lucene/pull/15979#discussion_r3647753172


##########
lucene/core/src/java/org/apache/lucene/codecs/lucene106/dedup/DedupUtil.java:
##########
@@ -0,0 +1,562 @@
+/*
+ * 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.lucene106.dedup;
+
+import static org.apache.lucene.index.VectorEncoding.BYTE;
+import static org.apache.lucene.index.VectorEncoding.FLOAT32;
+import static org.apache.lucene.util.StringHelper.GOOD_FAST_HASH_SEED;
+import static org.apache.lucene.util.StringHelper.murmurhash3_x64_128;
+
+import java.io.IOException;
+import org.apache.lucene.codecs.hnsw.FlatVectorsScorer;
+import org.apache.lucene.codecs.lucene95.OffHeapByteVectorValues;
+import org.apache.lucene.codecs.lucene95.OffHeapFloatVectorValues;
+import org.apache.lucene.codecs.lucene95.OrdToDocDISIReaderConfiguration;
+import org.apache.lucene.index.ByteVectorValues;
+import org.apache.lucene.index.DocsWithFieldSet;
+import org.apache.lucene.index.FieldInfo;
+import org.apache.lucene.index.FloatVectorValues;
+import org.apache.lucene.index.KnnVectorValues;
+import org.apache.lucene.index.VectorEncoding;
+import org.apache.lucene.index.VectorSimilarityFunction;
+import org.apache.lucene.internal.hppc.IntArrayList;
+import org.apache.lucene.search.DocIdSetIterator;
+import org.apache.lucene.search.VectorScorer;
+import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.store.IndexOutput;
+import org.apache.lucene.store.RandomAccessInput;
+import org.apache.lucene.util.ArrayUtil;
+import org.apache.lucene.util.LongValues;
+import org.apache.lucene.util.hnsw.RandomVectorScorer;
+import org.apache.lucene.util.packed.DirectReader;
+import org.apache.lucene.util.packed.DirectWriter;
+
+/**
+ * Shared helpers for the de-duplicating flat format: reading / writing field 
and group metadata,
+ * vector hashing and alignment, and the {@link DedupVectorValues} views used 
on the read path.
+ *
+ * @lucene.experimental
+ */
+final class DedupUtil {
+
+  private static final int DIRECT_MONOTONIC_BLOCK_SHIFT = 16;
+
+  private static final int END_MARKER = -1;
+
+  private static final int ORD_TO_VEC_ALIGN_BYTES = 4;
+
+  // TODO: Evaluate using fewer bits.

Review Comment:
   Today, the `ordToVecOrd` mapping is maintained off-heap, and 
[written](https://github.com/kaivalnp/lucene/blob/91936b9b43d7244b2663de254ef1c0715c59d754/lucene/core/src/java/org/apache/lucene/codecs/lucene106/dedup/DedupUtil.java#L172-L173)
 using a 
[`DirectWriter`](https://github.com/kaivalnp/lucene/blob/91936b9b43d7244b2663de254ef1c0715c59d754/lucene/core/src/java/org/apache/lucene/util/packed/DirectWriter.java#L25-L44).
   
   This specifies the number of bits used to encode each of those packed 
values, which I set to `32` to avoid bit manipulation / unaligned reads, 
because it is on a hot path (needed before _each_ vector score).
   
   This TODO is to evaluate if we can use fewer bits (based on the max value of 
vector ordinals) to encode the mapping (while paying a higher cost for each 
retrieval).



-- 
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]

Reply via email to