do tag to string conversion in StringCompressor instead of Tag

This commit is contained in:
2021-05-09 10:44:24 +02:00
parent 6dc335600e
commit 75857b553e
7 changed files with 22 additions and 30 deletions

View File

@@ -267,7 +267,8 @@ public class DataStore implements AutoCloseable {
final Tag keyPrefix = Tags.STRING_COMPRESSOR.createTag("", ""); // will find everything
final PartitionIdSource partitionIdSource = new DatePartitioner(dateRange);
tagToDocsId.visitValues(partitionIdSource, keyPrefix, (tags, __) -> keys.add(tags.getKeyAsString()));
tagToDocsId.visitValues(partitionIdSource, keyPrefix,
(tag, __) -> keys.add(Tags.STRING_COMPRESSOR.getKeyAsString(tag)));
keys.remove(ALL_DOCS_KEY);
final List<String> result = new ArrayList<>(keys);

View File

@@ -327,7 +327,7 @@ public class QueryCompletionIndex implements AutoCloseable {
// create indices of all tags and all fields
for (final Tag tag : listOfTagsA) {
fieldToValueIndex.putValue(partitionId, tag, Empty.INSTANCE);
fieldIndex.putValue(partitionId, tag.getKeyAsString(), Empty.INSTANCE);
fieldIndex.putValue(partitionId, Tags.STRING_COMPRESSOR.getKeyAsString(tag), Empty.INSTANCE);
}
}
@@ -356,10 +356,10 @@ public class QueryCompletionIndex implements AutoCloseable {
final PartitionIdSource partitionIdSource = new DatePartitioner(dateRange);
tagToTagIndex.visitValues(partitionIdSource, keyPrefix, (k, v) -> {
final String vA = k.getTagA().getValueAsString();
final String vA = Tags.STRING_COMPRESSOR.getValueAsString(k.getTagA());
if (valueA.matches(vA)) {
result.add(k.getTagB().getValueAsString());
result.add(Tags.STRING_COMPRESSOR.getValueAsString(k.getTagB()));
}
});
@@ -385,7 +385,7 @@ public class QueryCompletionIndex implements AutoCloseable {
final PartitionIdSource partitionIdSource = new DatePartitioner(dateRange);
tagToTagIndex.visitValues(partitionIdSource, keyPrefix, (k, v) -> {
result.add(k.getTagB().getValueAsString());
result.add(Tags.STRING_COMPRESSOR.getValueAsString(k.getTagB()));
});
return result;
@@ -406,7 +406,7 @@ public class QueryCompletionIndex implements AutoCloseable {
final PartitionIdSource partitionIdSource = new DatePartitioner(dateRange);
fieldToValueIndex.visitValues(partitionIdSource, keyPrefix, (k, v) -> {
result.add(k.getValueAsString());
result.add(Tags.STRING_COMPRESSOR.getValueAsString(k));
});
return result;
@@ -426,7 +426,7 @@ public class QueryCompletionIndex implements AutoCloseable {
final String field) {
final SortedSet<String> result = new TreeSet<>();
final TwoTags keyPrefix = new TwoTags(field, tag.getKeyAsString(), null, null);
final TwoTags keyPrefix = new TwoTags(field, Tags.STRING_COMPRESSOR.getKeyAsString(tag), null, null);
final int negatedValueA = tag.getValue();
final PartitionIdSource partitionIdSource = new DatePartitioner(dateRange);
@@ -434,7 +434,7 @@ public class QueryCompletionIndex implements AutoCloseable {
final int valueA = k.getTagA().getValue();
if (valueA != negatedValueA) {
result.add(k.getTagB().getValueAsString());
result.add(Tags.STRING_COMPRESSOR.getValueAsString(k.getTagB()));
}
});

View File

@@ -12,13 +12,13 @@ class TagEncoderDecoder implements EncoderDecoder<Tag> {
final LongList keyAndValueCompressed = new LongList(2);
final String key = tag.getKeyAsString();
final String key = Tags.STRING_COMPRESSOR.getKeyAsString(tag);
final byte[] result;
if (!key.isEmpty()) {
final Integer keyAsLong = Tags.STRING_COMPRESSOR.put(key);
keyAndValueCompressed.add(keyAsLong);
final String value = tag.getValueAsString();
final String value = Tags.STRING_COMPRESSOR.getValueAsString(tag);
if (!value.isEmpty()) {
final Integer valueAsLong = Tags.STRING_COMPRESSOR.put(value);
keyAndValueCompressed.add(valueAsLong);

View File

@@ -150,8 +150,8 @@ public class ExpressionToDocIdVisitor extends ExpressionVisitor<PartitionLongLis
for (final ParititionId partitionId : availablePartitionIds) {
final List<LongList> docIdsForPartition = new ArrayList<>();
keyToValueToDocId.visitValues(partitionId, Tags.STRING_COMPRESSOR.createTag(propertyName, ""),
(tags, blockOffsetToDocIds) -> {
if (valuePattern.matcher(tags.getValueAsString()).matches()) {
(tag, blockOffsetToDocIds) -> {
if (valuePattern.matcher(Tags.STRING_COMPRESSOR.getValueAsString(tag)).matches()) {
try (final LongStreamFile bsFile = diskStorage.streamExistingFile(blockOffsetToDocIds,
partitionId)) {