mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 21:18:58 +00:00
(index) Backport bugfix from term-positions branch
The ordering of TermIdsList is assumed to be unchanged by the surrounding code, but the constructor sorts the dang list to be able to do contains() by binary search. This is no bueno. This is gonna be a merge conflict in the future, but it's too big of a bug to leave for another month.
This commit is contained in:
parent
ac67b6b5da
commit
2f38c95886
@ -3,7 +3,6 @@ package nu.marginalia.index.results.model.ids;
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayList;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.LongStream;
|
||||
|
||||
public final class TermIdList {
|
||||
@ -29,6 +28,24 @@ public final class TermIdList {
|
||||
return array;
|
||||
}
|
||||
|
||||
public long at(int i) {
|
||||
return array[i];
|
||||
}
|
||||
|
||||
public boolean contains(long id) {
|
||||
// array is typically small and unsorted, so linear search is fine
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
if (array[i] == id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int indexOf(long id) {
|
||||
return Arrays.binarySearch(array, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) return true;
|
||||
|
Loading…
Reference in New Issue
Block a user