diff --git a/src/main/java/puzzle/Meta.java b/src/main/java/puzzle/Meta.java index 1011db6..807fedc 100644 --- a/src/main/java/puzzle/Meta.java +++ b/src/main/java/puzzle/Meta.java @@ -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; diff --git a/src/test/java/puzzle/BuildMeta2.java b/src/test/java/puzzle/BuildMeta2.java index 5adb2da..bad2b32 100644 --- a/src/test/java/puzzle/BuildMeta2.java +++ b/src/test/java/puzzle/BuildMeta2.java @@ -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 {