mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 21:18:58 +00:00
(gamma) Fix readCount() behavior in EGC
This commit is contained in:
parent
dae22ccbe0
commit
b805f6daa8
@ -37,12 +37,12 @@ public class EliasGammaCodec implements IntIterator {
|
||||
public static int readCount(ByteBuffer buffer) {
|
||||
var reader = new BitReader(buffer);
|
||||
|
||||
if (reader.getCurrentValue() > 0) {
|
||||
int bits = reader.takeWhileZero();
|
||||
return reader.get(bits);
|
||||
int bits = reader.takeWhileZero();
|
||||
if (!reader.hasMore()) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
return reader.get(bits);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,13 @@ class EliasGammaCodecTest {
|
||||
assertEquals(expected, decoded);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valueCount() {
|
||||
var ret = EliasGammaCodec.encode(work, new int[] { 1, 3, 5, 16, 32, 64 });
|
||||
var count = EliasGammaCodec.readCount(ret);
|
||||
assertEquals(6, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCodec2() {
|
||||
var ret = EliasGammaCodec.encode(work, new int[] { 1, 256 });
|
||||
|
Loading…
Reference in New Issue
Block a user