mayya-sharipova commented on code in PR #792:
URL: https://github.com/apache/lucene/pull/792#discussion_r854526400
##########
lucene/core/src/java/org/apache/lucene/codecs/lucene91/Lucene91HnswVectorsWriter.java:
##########
@@ -207,15 +210,41 @@ private void writeMeta(
// write docIDs
int count = docsWithField.cardinality();
meta.writeInt(count);
- if (count == maxDoc) {
- meta.writeByte((byte) -1); // dense marker, each document has a vector
value
+ if (count == 0) {
+ meta.writeLong(-2); // docsWithFieldOffset
+ meta.writeLong(0L); // docsWithFieldLength
+ meta.writeShort((short) -1); // jumpTableEntryCount
+ meta.writeByte((byte) -1); // denseRankPower
+ } else if (count == maxDoc) {
+ meta.writeLong(-1); // docsWithFieldOffset
+ meta.writeLong(0L); // docsWithFieldLength
+ meta.writeShort((short) -1); // jumpTableEntryCount
+ meta.writeByte((byte) -1); // denseRankPower
} else {
- meta.writeByte((byte) 0); // sparse marker, some documents don't have
vector values
- DocIdSetIterator iter = docsWithField.iterator();
- for (int doc = iter.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc
= iter.nextDoc()) {
- meta.writeInt(doc);
- }
+ long offset = vectorData.getFilePointer();
+ meta.writeLong(offset); // docsWithFieldOffset
+ final short jumpTableEntryCount =
+ IndexedDISI.writeBitSet(
+ docsWithField.iterator(), vectorData,
IndexedDISI.DEFAULT_DENSE_RANK_POWER);
+ meta.writeLong(vectorData.getFilePointer() - offset); //
docsWithFieldLength
+ meta.writeShort(jumpTableEntryCount);
+ meta.writeByte(IndexedDISI.DEFAULT_DENSE_RANK_POWER);
+ }
+
+ // write ordToDoc mapping
Review Comment:
Do we need to write `ordToDoc` mapping for the dense case, where is 1-1
mapping between ord and doc? May be, we can skip it in this case?
--
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]