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 @@ -228,6 +228,8 @@ protected final int slowAdvance(int target) throws IOException {
*
* <p><b>Note</b>: It is important not to clear bits from {@code bitSet} that may be already set.
*
* <p><b>Note</b>: {@code offset} may be negative.
*
* @lucene.internal
*/
public void intoBitSet(int upTo, FixedBitSet bitSet, int offset) throws IOException {
Expand Down
15 changes: 15 additions & 0 deletions lucene/core/src/java/org/apache/lucene/util/IntArrayDocIdSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ public int advance(int target) throws IOException {
return doc = docs[i++];
}

@Override
public void intoBitSet(int upTo, FixedBitSet bitSet, int offset) throws IOException {
if (doc >= upTo) {
return;
}

int from = i - 1;
int to = VectorUtil.findNextGEQ(docs, upTo, from, length);
for (int i = from; i < to; ++i) {
bitSet.set(docs[i] - offset);
}
doc = docs[to];
i = to + 1;
}

@Override
public long cost() {
return length;
Expand Down
34 changes: 34 additions & 0 deletions lucene/core/src/java/org/apache/lucene/util/RoaringDocIdSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,20 @@ public int advance(int target) throws IOException {
return doc = docId(i);
}
}

@Override
public void intoBitSet(int upTo, FixedBitSet bitSet, int offset) throws IOException {
if (doc >= upTo) {
return;
}

int from = i;
advance(upTo);
int to = i;
for (int i = from; i < to; ++i) {
bitSet.set(docId(i) - offset);
}
}
};
}
}
Expand Down Expand Up @@ -312,6 +326,26 @@ private int firstDocFromNextBlock() throws IOException {
}
}

@Override
public void intoBitSet(int upTo, FixedBitSet bitSet, int offset) throws IOException {
for (; ; ) {
int subUpto = upTo - (block << 16);
if (subUpto < 0) {
break;
}
int subOffset = offset - (block << 16);
sub.intoBitSet(subUpto, bitSet, subOffset);
if (sub.docID() == NO_MORE_DOCS) {
if (firstDocFromNextBlock() == NO_MORE_DOCS) {
break;
}
} else {
doc = (block << 16) | sub.docID();
break;
}
}
}

@Override
public long cost() {
return cardinality;
Expand Down
Loading