make it possible to reindex the persistent maps via system property
This commit is contained in:
@@ -6,7 +6,7 @@ import org.lucares.pdb.api.Tags;
|
||||
import org.lucares.pdb.datastore.Doc;
|
||||
import org.lucares.utils.byteencoder.VariableByteEncoder;
|
||||
|
||||
class DocEncoderDecoder implements PartitionAwareEncoderDecoder<Doc, Doc> {
|
||||
public class DocEncoderDecoder implements PartitionAwareEncoderDecoder<Doc, Doc> {
|
||||
|
||||
@Override
|
||||
public byte[] encode(final Doc doc) {
|
||||
@@ -44,6 +44,7 @@ class DocEncoderDecoder implements PartitionAwareEncoderDecoder<Doc, Doc> {
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getEmptyValue() {
|
||||
return new byte[] { 0 };
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import org.lucares.pdb.api.RuntimeIOException;
|
||||
import org.lucares.pdb.map.PersistentMap;
|
||||
import org.lucares.pdb.map.PersistentMap.EncoderDecoder;
|
||||
import org.lucares.pdb.map.Visitor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* A wrapper for {@link PersistentMap} that partitions the values into several
|
||||
@@ -25,6 +27,8 @@ import org.lucares.pdb.map.Visitor;
|
||||
*/
|
||||
public class PartitionPersistentMap<K, V, P> implements AutoCloseable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PartitionPersistentMap.class);
|
||||
|
||||
private final ConcurrentHashMap<ParititionId, PersistentMap<K, P>> maps = new ConcurrentHashMap<>();
|
||||
|
||||
private final Function<ParititionId, PersistentMap<K, P>> creator;
|
||||
@@ -47,7 +51,9 @@ public class PartitionPersistentMap<K, V, P> implements AutoCloseable {
|
||||
}
|
||||
return null;
|
||||
};
|
||||
final long start = System.nanoTime();
|
||||
preload(storageBasePath);
|
||||
LOGGER.info("preloading {} took {}ms", filename, (System.nanoTime() - start) / 1_000_000.0);
|
||||
}
|
||||
|
||||
private void preload(final Path storageBasePath) {
|
||||
|
||||
Reference in New Issue
Block a user