From 386777e5766ed6f0e60b108447f9ad2c81c75c82 Mon Sep 17 00:00:00 2001 From: mike Date: Wed, 21 Jan 2026 05:40:14 +0100 Subject: [PATCH] introduce bitloops --- src/main/java/puzzle/Meta.java | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main/java/puzzle/Meta.java b/src/main/java/puzzle/Meta.java index 964ad72..18cfc89 100644 --- a/src/main/java/puzzle/Meta.java +++ b/src/main/java/puzzle/Meta.java @@ -26,10 +26,28 @@ public class Meta { static record ShardRec(String word, long w, int simpel, String[] clues) { } static final Path projectRoot = Path.of("").toAbsolutePath().normalize(); // current working dir - static final Path dir = projectRoot.resolve("src/main/resources/shards"); - static final Path shardData = dir.resolve("shard0.data"); - static final Path shardMap = dir.resolve("shard0.map"); + //static final Path dir = projectRoot.resolve("src/main/resources/shards"); + //static final Path shardData = dir.resolve("shard0.data"); + //static final Path shardMap = dir.resolve("shard0.map"); + static final Path dir = detectShardDir(); + static final Path shardData = dir.resolve("shard0.data"); + static final Path shardMap = dir.resolve("shard0.map"); + private static Path detectShardDir() { + // 1) optioneel override + String p = System.getProperty("puzzle.shards.dir"); + if (p != null && !p.isBlank()) return Path.of(p).toAbsolutePath().normalize(); + + // 2) default: naast classes output (CLASS_OUTPUT/shards) + try { + var url = Meta.class.getProtectionDomain().getCodeSource().getLocation(); // classes dir (niet jar) + Path classes = Path.of(url.toURI()); + return classes.resolve("shards"); + } catch (Exception e) { + // 3) fallback: oude dev-locatie + return Path.of("").toAbsolutePath().normalize().resolve("src/main/resources/shards"); + } + } // --- Lookup: w -> i using mmap --- static int findIndexInMapMmap(long target) throws IOException { try (var ch = FileChannel.open(Meta.shardMap, StandardOpenOption.READ)) {