move StringCompressor initialization to StringCompressor
This commit is contained in:
@@ -37,8 +37,7 @@ public class Entry {
|
||||
public String toString() {
|
||||
|
||||
final OffsetDateTime date = Instant.ofEpochMilli(epochMilli).atOffset(ZoneOffset.UTC);
|
||||
return date.format(DateTimeFormatter.ISO_ZONED_DATE_TIME) + " = " + value + " ("
|
||||
+ Tags.STRING_COMPRESSOR.asString(tags) + ")";
|
||||
return date.format(DateTimeFormatter.ISO_ZONED_DATE_TIME) + " = " + value + " (" + tags + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,8 +40,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class DataStore implements AutoCloseable {
|
||||
private static final String ALL_DOCS_KEY = "\ue001allDocs"; // \ue001 is the second character in the private use
|
||||
// area
|
||||
|
||||
private static final Logger EXECUTE_QUERY_LOGGER = LoggerFactory
|
||||
.getLogger("org.lucares.metrics.dataStore.executeQuery");
|
||||
private static final Logger MAP_DOCS_TO_DOCID = LoggerFactory
|
||||
@@ -60,8 +59,6 @@ public class DataStore implements AutoCloseable {
|
||||
// ids when getting them from the BSFiles)
|
||||
private static final AtomicLong NEXT_DOC_ID = new AtomicLong(System.currentTimeMillis());
|
||||
|
||||
public static Tag TAG_ALL_DOCS = null;
|
||||
|
||||
private static final class PartitionedTagsCacheKey {
|
||||
private final Tags tags;
|
||||
private final ParititionId partitionId;
|
||||
@@ -125,11 +122,6 @@ public class DataStore implements AutoCloseable {
|
||||
storageBasePath = storageDirectory(dataDirectory);
|
||||
|
||||
Tags.STRING_COMPRESSOR = StringCompressor.create(keyCompressionFile(storageBasePath));
|
||||
Tags.STRING_COMPRESSOR.put(ALL_DOCS_KEY);
|
||||
Tags.STRING_COMPRESSOR.put("");
|
||||
TAG_ALL_DOCS = Tags.STRING_COMPRESSOR.createTag(ALL_DOCS_KEY, ""); // Tag(String, String) uses the
|
||||
// StringCompressor internally, so it
|
||||
// must be initialized after the string compressor has been created
|
||||
|
||||
diskStorage = new PartitionDiskStore(storageBasePath, "data.bs");
|
||||
|
||||
@@ -186,7 +178,7 @@ public class DataStore implements AutoCloseable {
|
||||
|
||||
// store mapping from tag to docId, so that we can find all docs for a given tag
|
||||
final List<Tag> ts = new ArrayList<>(tags.toTags());
|
||||
ts.add(TAG_ALL_DOCS);
|
||||
ts.add(StringCompressor.TAG_ALL_DOCS);
|
||||
for (final Tag tag : ts) {
|
||||
|
||||
Long diskStoreOffsetForDocIdsOfTag = tagToDocsId.getValue(partitionId, tag);
|
||||
@@ -276,7 +268,7 @@ public class DataStore implements AutoCloseable {
|
||||
tagToDocsId.visitValues(partitionIdSource, keyPrefix,
|
||||
(tag, __) -> keys.add(Tags.STRING_COMPRESSOR.getKeyAsString(tag)));
|
||||
|
||||
keys.remove(ALL_DOCS_KEY);
|
||||
keys.remove(StringCompressor.ALL_DOCS_KEY);
|
||||
final List<String> result = new ArrayList<>(keys);
|
||||
Collections.sort(result);
|
||||
return result;
|
||||
|
||||
@@ -9,10 +9,10 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.lucares.collections.LongList;
|
||||
import org.lucares.pdb.api.DateTimeRange;
|
||||
import org.lucares.pdb.api.StringCompressor;
|
||||
import org.lucares.pdb.api.Tag;
|
||||
import org.lucares.pdb.api.Tags;
|
||||
import org.lucares.pdb.blockstorage.LongStreamFile;
|
||||
import org.lucares.pdb.datastore.internal.DataStore;
|
||||
import org.lucares.pdb.datastore.internal.DatePartitioner;
|
||||
import org.lucares.pdb.datastore.internal.ParititionId;
|
||||
import org.lucares.pdb.datastore.internal.PartitionDiskStore;
|
||||
@@ -131,7 +131,7 @@ public class ExpressionToDocIdVisitor extends ExpressionVisitor<PartitionLongLis
|
||||
final Set<ParititionId> availablePartitionIds = keyToValueToDocId.getAvailablePartitionIds(datePartitioner);
|
||||
for (final ParititionId partitionId : availablePartitionIds) {
|
||||
|
||||
final Long blockOffset = keyToValueToDocId.getValue(partitionId, DataStore.TAG_ALL_DOCS);
|
||||
final Long blockOffset = keyToValueToDocId.getValue(partitionId, StringCompressor.TAG_ALL_DOCS);
|
||||
|
||||
if (blockOffset != null) {
|
||||
final LongStreamFile bsFile = diskStorage.streamExistingFile(blockOffset, partitionId);
|
||||
|
||||
Reference in New Issue
Block a user