mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-24 05:18:58 +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);
|
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);
|
return termCounts.forPage(page).open(table, baseDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,19 +75,33 @@ public class VarintColumn {
|
|||||||
return columnDesc;
|
return columnDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long get() throws IOException {
|
public int get() throws IOException {
|
||||||
long value = 0;
|
int value = 0;
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
|
byte b;
|
||||||
|
|
||||||
while (true) {
|
do {
|
||||||
long b = reader.getByte();
|
b = reader.getByte();
|
||||||
value |= (b & 0x7F) << shift;
|
value |= (b & 0x7F) << shift;
|
||||||
shift += 7;
|
shift += 7;
|
||||||
if ((b & 0x80) == 0) {
|
} while ((b & 0x80) != 0);
|
||||||
break;
|
|
||||||
}
|
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++;
|
position++;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package nu.marginalia.slop.column.dynamic;
|
package nu.marginalia.slop.column.dynamic;
|
||||||
|
|
||||||
import nu.marginalia.slop.column.primitive.LongColumnReader;
|
import nu.marginalia.slop.column.primitive.IntColumnReader;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public interface VarintColumnReader extends LongColumnReader {
|
public interface VarintColumnReader extends IntColumnReader {
|
||||||
|
|
||||||
|
int get() throws IOException;
|
||||||
|
long getLong() throws IOException;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
long position() throws IOException;
|
long position() throws IOException;
|
||||||
|
Loading…
Reference in New Issue
Block a user