introduce bitloops
This commit is contained in:
@@ -43,24 +43,16 @@ public class Meta {
|
||||
buf.flip();
|
||||
var string = StandardCharsets.UTF_8.decode(buf).toString();
|
||||
val parts = string.split("\t", 3);
|
||||
return new ShardLem(Lemma.pack(parts[0]), Integer.parseInt(parts[1]), GSON.fromJson(parts[2], String[].class));
|
||||
return new ShardLem(Lemma.from(parts[0]), Integer.parseInt(parts[1]), GSON.fromJson(parts[2], String[].class));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new ShardLem(Lemma.pack("XXX"), -1, new String[0]);
|
||||
return new ShardLem(Lemma.from("XXX"), -1, new String[0]);
|
||||
}
|
||||
}
|
||||
static final Path[] SHARDS = IntStream.range(0, 10).mapToObj(sId -> Path.of("src/main/generated-sources/puzzle").resolve(sId + ".idx")).toArray(
|
||||
Path[]::new);
|
||||
static Path shardKey(long word) {
|
||||
int L = Lemma.length(word);
|
||||
return SHARDS[L];
|
||||
}
|
||||
static String shardKey(String word) {
|
||||
int L = word.length();
|
||||
char ch = word.charAt(0);
|
||||
if (ch < 'A' || ch > 'Z') ch = '_';
|
||||
///return "" + L + ch; // e.g. "6Z"
|
||||
return "" + L; // e.g. "6Z"
|
||||
return SHARDS[Lemma.unpackSize(word) + 1];
|
||||
}
|
||||
static int readIntAt(FileChannel ch, long pos) throws IOException {
|
||||
ByteBuffer b = ByteBuffer.allocate(4);
|
||||
|
||||
Reference in New Issue
Block a user