Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,14 @@ final class DocIdsWriter {
DocIdsWriter() {}

void writeDocIds(IntToIntFunction docIds, int count, DataOutput out) throws IOException {
// docs can be sorted either when all docs in a block have the same value
// or when a segment is sorted
if (count == 0) {
out.writeByte(CONTINUOUS_IDS);
return;
}
if (count > scratch.length) {
scratch = new int[count];
}
// docs can be sorted either when all docs in a block have the same value
// or when a segment is sorted
boolean strictlySorted = true;
int min = docIds.apply(0);
int max = min;
Expand Down Expand Up @@ -215,6 +214,9 @@ private static void writeIdsAsBitSet(IntToIntFunction docIds, int count, DataOut

/** Read {@code count} integers into {@code docIDs}. */
void readInts(IndexInput in, int count, int[] docIDs) throws IOException {
if (count == 0) {
return;
}
if (count > scratch.length) {
scratch = new int[count];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@

public class DocIdsWriterTests extends LuceneTestCase {

public void testNoDocs() throws Exception {
try (Directory dir = newDirectory()) {
test(dir, new int[0]);
}
}

public void testRandom() throws Exception {
int numIters = atLeast(100);
try (Directory dir = newDirectory()) {
Expand Down