Skip to content

Commit

Permalink
remove leftover
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczi committed Oct 15, 2024
1 parent d4969eb commit 9668f5e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private class SingletonDocValuesLoader implements DocValuesLoader, Values {
private final int[] docIdsInLeaf;
private final long[] values;
private final boolean[] hasValue;
private int idx = 0;
private int idx = -1;

private SingletonDocValuesLoader(int[] docIdsInLeaf, long[] values, boolean[] hasValue) {
this.docIdsInLeaf = docIdsInLeaf;
Expand All @@ -198,11 +198,12 @@ private SingletonDocValuesLoader(int[] docIdsInLeaf, long[] values, boolean[] ha

@Override
public boolean advanceToDoc(int docId) throws IOException {
int index = Arrays.binarySearch(docIdsInLeaf, idx, docIdsInLeaf.length, docId);
if (index < 0) {
throw new IllegalArgumentException(docId + " is not expected to be called");
idx++;
if (docIdsInLeaf[idx] != docId) {
throw new IllegalArgumentException(
"expected to be called with [" + docIdsInLeaf[idx] + "] but was called with " + docId + " instead"
);
}
idx = index;
return hasValue[idx];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private static class SingletonDocValuesLoader implements DocValuesLoader, DocVal
private final int[] uniqueOrds;
private final BytesRef[] converted;

private int idx = 0;
private int idx = -1;

private SingletonDocValuesLoader(int[] docIdsInLeaf, int[] ords, int[] uniqueOrds, BytesRef[] converted) {
this.docIdsInLeaf = docIdsInLeaf;
Expand All @@ -196,11 +196,12 @@ private SingletonDocValuesLoader(int[] docIdsInLeaf, int[] ords, int[] uniqueOrd

@Override
public boolean advanceToDoc(int docId) throws IOException {
int index = Arrays.binarySearch(docIdsInLeaf, idx, docIdsInLeaf.length, docId);
if (index < 0) {
throw new IllegalArgumentException(docId + " is not expected to be called");
idx++;
if (docIdsInLeaf[idx] != docId) {
throw new IllegalArgumentException(
"expected to be called with [" + docIdsInLeaf[idx] + "] but was called with " + docId + " instead"
);
}
idx = index;
return ords[idx] >= 0;
}

Expand Down

0 comments on commit 9668f5e

Please sign in to comment.