introduce bitloops

This commit is contained in:
mike
2026-01-20 10:00:30 +01:00
parent 30ca46ac03
commit fde6f15b24
2 changed files with 5 additions and 7 deletions

View File

@@ -60,7 +60,7 @@ public class Meta {
}
// --- Read record i from shard.data (your format) ---
static ShardLem readRecord(Path shardFile, int i) throws IOException {
static ShardLem readRecord(Path shardFile, long w, int i) throws IOException {
try (FileChannel ch = FileChannel.open(shardFile, StandardOpenOption.READ)) {
ByteBuffer hdr = ByteBuffer.allocate(12).order(ORDER);
ch.read(hdr);
@@ -88,7 +88,6 @@ public class Meta {
String s = StandardCharsets.UTF_8.decode(buf).toString();
String[] parts = s.split("\t", 3);
long w = Lemma.from(normWord(parts[0]));
int simpel = Integer.parseInt(parts[1]);
String[] clues = GSON.fromJson(parts[2], String[].class);
return new ShardLem(w, simpel, clues);
@@ -106,11 +105,10 @@ public class Meta {
// --- Demo main ---
public static ShardLem lookup(long w) {
try {
int i = findIndexInMapMmap(shardMap, Lemma.pack43(w));
val qRaw = Lemma.asWord(w, new byte[8]);
System.out.println("\nQuery: " + qRaw + " w=" + w + " -> i=" + i);
int i = findIndexInMapMmap(shardMap, Lemma.pack43(w));
System.out.println("\nQuery: w=" + w + " -> i=" + i);
if (i >= 0) {
ShardLem rec = readRecord(shardData, i);
ShardLem rec = readRecord(shardData, w, i);
System.out.println(" simpel=" + rec.simpel());
System.out.println(" clues=" + Arrays.toString(rec.clues()));
return rec;

View File

@@ -98,7 +98,7 @@ public class BuildMeta2 {
System.out.println("\nQuery: " + qRaw + " (norm=" + q + ") w=" + w + " -> i=" + i);
if (i >= 0) {
ShardLem rec = Meta.readRecord(Meta.shardData, i);
ShardLem rec = Meta.readRecord(Meta.shardData, w, i);
System.out.println(" simpel=" + rec.simpel());
System.out.println(" clues=" + Arrays.toString(rec.clues()));
} else {