values used in queries were added to the keys.csv

Due to a mistake in Tag which added all strings used
by Tag into the String dictionary, the dictionary
did contain all values that were used in queries.
This commit is contained in:
2019-02-09 08:28:23 +01:00
parent ea5884a5e6
commit 493971bcf3
13 changed files with 122 additions and 99 deletions

View File

@@ -64,7 +64,9 @@ public class CsvToEntryTransformer implements LineToEntryTransformer {
break;
default:
if (!StringUtils.isBlank(columns[i])) {
tagsBuilder.add(headers[i], columns[i]);
final int key = Tags.STRING_COMPRESSOR.put(headers[i]);
final int value = Tags.STRING_COMPRESSOR.put(columns[i]);
tagsBuilder.add(key, value);
}
break;
}

View File

@@ -10,6 +10,7 @@ import java.util.regex.Pattern;
import org.lucares.pdb.api.Entries;
import org.lucares.pdb.api.Entry;
import org.lucares.pdb.api.Tags;
import org.lucares.pdb.api.TagsBuilder;
import org.lucares.performance.db.PdbExport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -104,7 +105,23 @@ public class CustomExportFormatToEntryTransformer {
final String[] tagsIdToSerializedTags = line.split(Pattern.quote(PdbExport.SEPARATOR_TAG_ID));
final Long tagId = Long.parseLong(tagsIdToSerializedTags[0], 1, tagsIdToSerializedTags[0].length(), 10);
final Tags tags = Tags.fromCsv(tagsIdToSerializedTags[1]);
final Tags tags = tagsFromCsv(tagsIdToSerializedTags[1]);
tagsDictionary.put(tagId, tags);
}
public static Tags tagsFromCsv(final String line) {
final TagsBuilder tagsBuilder = new TagsBuilder();
final String[] tagsAsString = line.split(Pattern.quote(","));
for (final String tagAsString : tagsAsString) {
final String[] keyValue = tagAsString.split(Pattern.quote("="));
final int key = Tags.STRING_COMPRESSOR.put(keyValue[0]);
final int value = Tags.STRING_COMPRESSOR.put(keyValue[1]);
tagsBuilder.add(key, value);
}
return tagsBuilder.build();
}
}

View File

@@ -72,11 +72,16 @@ public class JsonToEntryTransformer implements LineToEntryTransformer {
// ignore: we only support key/value tags
break;
default:
final int keyAsInt = Tags.STRING_COMPRESSOR.put(key);
final int valueAsInt;
if (value instanceof String) {
tags.add(key, (String) value);
valueAsInt = Tags.STRING_COMPRESSOR.put((String) value);
} else if (value != null) {
tags.add(key, String.valueOf(value));
valueAsInt = Tags.STRING_COMPRESSOR.put(String.valueOf(value));
} else {
continue;
}
tags.add(keyAsInt, valueAsInt);
break;
}
}