diff --git a/block-storage/src/main/java/org/lucares/pdb/map/PersistentMap.java b/block-storage/src/main/java/org/lucares/pdb/map/PersistentMap.java index ea23aee..ae757f3 100644 --- a/block-storage/src/main/java/org/lucares/pdb/map/PersistentMap.java +++ b/block-storage/src/main/java/org/lucares/pdb/map/PersistentMap.java @@ -586,8 +586,21 @@ public class PersistentMap implements AutoCloseable { public synchronized void reindex() throws IOException { final long start = System.nanoTime(); - final AtomicLong countValues = new AtomicLong(); final PersistentMapStats previousStats = stats(); + + if (previousStats.getAverageFill() > 0.9) { + LOGGER.info("skip reindexing because average fill ratio is > 0.9 file: {}, version: {} stats: \n{}", path, + version, previousStats); + return; + } + + if (previousStats.getInnerNodes() < 1) { + LOGGER.info("skip reindexing because no inner nodes file: {}, version: {} stats: \n{}", path, version, + previousStats); + return; + } + + final AtomicLong countValues = new AtomicLong(); LOGGER.info("start reindexing file: {}, version: {}", path, version); final Path newFile = path.getParent().resolve(path.getFileName() + ".tmp"); @@ -706,7 +719,7 @@ public class PersistentMap implements AutoCloseable { try { if (version < 1) { reindex(); - } else if (false) { + } else if (true) { final String reindexProperty = System.getProperty("pdb.reindex", "false"); if (!isNew && (reindexProperty.equals("true") || path.getParent().getFileName().toString().equals(reindexProperty))) {