Skip to content

Conversation

martijnvg
Copy link
Member

No description provided.

Comment on lines +262 to +281
if (isDense(firstDocId, doc, count)) {
try (var builder = factory.singletonBytesRefs(count)) {
long[] offsets = new long[count + 1];

// Normalize the offsets to check of bytes that is going to be fetched:
int j = 1;
long startOffset = addresses.get(firstDocId);
for (int i = offset; i < docs.count(); i++) {
int docId = docs.get(i);
long nextOffset = addresses.get(docId + 1) - startOffset;
offsets[j++] = nextOffset;
}

int lastDocId = docs.get(docs.count() - 1);
int length = Math.toIntExact(addresses.get(lastDocId + 1L) - startOffset);
byte[] bytes = new byte[length];
bytesSlice.readBytes(startOffset, bytes, 0, length);
builder.appendBytesRefs(bytes, offsets);
return builder.build();
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost 2x faster than the else branch. Tested on my local machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants