LuXugang commented on code in PR #792:
URL: https://github.com/apache/lucene/pull/792#discussion_r856877670
##########
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:
Thanks @mayya-sharipova , it is indeed that there's no need to store
ordToMap in dense 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]