make StringCompressor a field of DataStore

This commit is contained in:
2021-09-18 18:53:50 +02:00
parent edaba72c33
commit fefcbf7532

View File

@@ -118,10 +118,13 @@ public class DataStore implements AutoCloseable {
private final PartitionDiskStore diskStorage; private final PartitionDiskStore diskStorage;
private final Path storageBasePath; private final Path storageBasePath;
private final StringCompressor stringCompressor;
public DataStore(final Path dataDirectory) throws IOException { public DataStore(final Path dataDirectory) throws IOException {
storageBasePath = storageDirectory(dataDirectory); 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"); diskStorage = new PartitionDiskStore(storageBasePath, "data.bs");
@@ -262,11 +265,11 @@ public class DataStore implements AutoCloseable {
final Set<String> keys = new HashSet<>(); final Set<String> 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); final PartitionIdSource partitionIdSource = new DatePartitioner(dateRange);
tagToDocsId.visitValues(partitionIdSource, keyPrefix, tagToDocsId.visitValues(partitionIdSource, keyPrefix,
(tag, __) -> keys.add(Tags.STRING_COMPRESSOR.getKeyAsString(tag))); (tag, __) -> keys.add(stringCompressor.getKeyAsString(tag)));
keys.remove(StringCompressor.ALL_DOCS_KEY); keys.remove(StringCompressor.ALL_DOCS_KEY);
final List<String> result = new ArrayList<>(keys); final List<String> result = new ArrayList<>(keys);