mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 13:09:00 +00:00
(slop) Add 32 bit read method for Varint along with the old 64 bit version
This commit is contained in:
parent
40f42bf654
commit
e585116dab
@ -52,7 +52,7 @@ public record IndexJournalPage(Path baseDir, int page) {
|
||||
return size.forPage(page).open(table, baseDir);
|
||||
}
|
||||
|
||||
public LongColumnReader openTermCounts(SlopTable table) throws IOException {
|
||||
public VarintColumnReader openTermCounts(SlopTable table) throws IOException {
|
||||
return termCounts.forPage(page).open(table, baseDir);
|
||||
}
|
||||
|
||||
|
@ -75,18 +75,32 @@ public class VarintColumn {
|
||||
return columnDesc;
|
||||
}
|
||||
|
||||
public long get() throws IOException {
|
||||
long value = 0;
|
||||
public int get() throws IOException {
|
||||
int value = 0;
|
||||
int shift = 0;
|
||||
byte b;
|
||||
|
||||
while (true) {
|
||||
long b = reader.getByte();
|
||||
do {
|
||||
b = reader.getByte();
|
||||
value |= (b & 0x7F) << shift;
|
||||
shift += 7;
|
||||
if ((b & 0x80) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while ((b & 0x80) != 0);
|
||||
|
||||
position++;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public long getLong() throws IOException {
|
||||
long value = 0;
|
||||
int shift = 0;
|
||||
byte b;
|
||||
|
||||
do {
|
||||
b = reader.getByte();
|
||||
value |= (long) (b & 0x7F) << shift;
|
||||
shift += 7;
|
||||
} while ((b & 0x80) != 0);
|
||||
|
||||
position++;
|
||||
|
||||
|
@ -1,10 +1,13 @@
|
||||
package nu.marginalia.slop.column.dynamic;
|
||||
|
||||
import nu.marginalia.slop.column.primitive.LongColumnReader;
|
||||
import nu.marginalia.slop.column.primitive.IntColumnReader;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface VarintColumnReader extends LongColumnReader {
|
||||
public interface VarintColumnReader extends IntColumnReader {
|
||||
|
||||
int get() throws IOException;
|
||||
long getLong() throws IOException;
|
||||
|
||||
@Override
|
||||
long position() throws IOException;
|
||||
|
Loading…
Reference in New Issue
Block a user