skip reindex if average fill ratio over 90%

This commit is contained in:
2023-02-25 09:03:08 +01:00
parent 5e9e34d910
commit b223e650a0

View File

@@ -586,8 +586,21 @@ public class PersistentMap<K, V> 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<K, V> 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))) {