From fefcbf7532b40cbc04efc1e46f0a59639340857b Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Sat, 18 Sep 2021 18:53:50 +0200 Subject: [PATCH] make StringCompressor a field of DataStore --- .../org/lucares/pdb/datastore/internal/DataStore.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/data-store/src/main/java/org/lucares/pdb/datastore/internal/DataStore.java b/data-store/src/main/java/org/lucares/pdb/datastore/internal/DataStore.java index d0a68ec..7ca5192 100644 --- a/data-store/src/main/java/org/lucares/pdb/datastore/internal/DataStore.java +++ b/data-store/src/main/java/org/lucares/pdb/datastore/internal/DataStore.java @@ -118,10 +118,13 @@ public class DataStore implements AutoCloseable { private final PartitionDiskStore diskStorage; private final Path storageBasePath; + private final StringCompressor stringCompressor; + public DataStore(final Path dataDirectory) throws IOException { storageBasePath = storageDirectory(dataDirectory); - Tags.STRING_COMPRESSOR = StringCompressor.create(keyCompressionFile(storageBasePath)); + stringCompressor = StringCompressor.create(keyCompressionFile(storageBasePath)); + Tags.STRING_COMPRESSOR = stringCompressor; diskStorage = new PartitionDiskStore(storageBasePath, "data.bs"); @@ -262,11 +265,11 @@ public class DataStore implements AutoCloseable { final Set keys = new HashSet<>(); - final Tag keyPrefix = Tags.STRING_COMPRESSOR.createTag("", ""); // will find everything + final Tag keyPrefix = stringCompressor.createTag("", ""); // will find everything final PartitionIdSource partitionIdSource = new DatePartitioner(dateRange); tagToDocsId.visitValues(partitionIdSource, keyPrefix, - (tag, __) -> keys.add(Tags.STRING_COMPRESSOR.getKeyAsString(tag))); + (tag, __) -> keys.add(stringCompressor.getKeyAsString(tag))); keys.remove(StringCompressor.ALL_DOCS_KEY); final List result = new ArrayList<>(keys);