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

@@ -43,7 +43,7 @@ public class PerformanceDbTest {
try (PerformanceDb db = new PerformanceDb(dataDirectory)) {
final long date = DateUtils.nowInUtc().toInstant().toEpochMilli();
final long value = 1;
final Tags tags = Tags.create("myKey", "myValue");
final Tags tags = Tags.createAndAddToDictionary("myKey", "myValue");
db.putEntry(new Entry(date, value, tags));
final Result result = db.get(Query.createQuery(tags));
@@ -63,7 +63,7 @@ public class PerformanceDbTest {
final long dayTwo = DateUtils.getDate(2016, 11, 2, 12, 34, 56).toInstant().toEpochMilli();
final long valueOne = 1;
final long valueTwo = 2;
final Tags tags = Tags.create("myKey", "myValue");
final Tags tags = Tags.createAndAddToDictionary("myKey", "myValue");
db.putEntry(new Entry(dayOne, valueOne, tags));
db.putEntry(new Entry(dayTwo, valueTwo, tags));
@@ -115,7 +115,7 @@ public class PerformanceDbTest {
final TimeRange timeRange = TimeRange.ofDay(DateUtils.getDate(year, month, day, 1, 1, 1));
final Tags tags = Tags.create("myKey", "one");
final Tags tags = Tags.createAndAddToDictionary("myKey", "one");
final List<Entry> entries = generateEntries(timeRange, numberOfEntries, 0, tags);
printEntries(entries, "");
@@ -156,7 +156,7 @@ public class PerformanceDbTest {
final int month = 1;
final int day = 2;
tags = Tags.create("myKey", "one");
tags = Tags.createAndAddToDictionary("myKey", "one");
final TimeRange timeRange = TimeRange.ofDay(DateUtils.getDate(year, month, day, 1, 1, 1));
final List<Entry> entries = generateEntries(timeRange, numberOfEntries, 0, tags);
@@ -191,18 +191,18 @@ public class PerformanceDbTest {
final TimeRange timeRange = new TimeRange(from, to);
final long numberOfEntries = timeRange.duration().toHours();
final Tags tagsCommon = Tags.create("commonKey", "commonValue");
final Tags tagsOne = Tags.create("myKey", "one", "commonKey", "commonValue");
final Tags tagsCommon = Tags.createAndAddToDictionary("commonKey", "commonValue");
final Tags tagsOne = Tags.createAndAddToDictionary("myKey", "one", "commonKey", "commonValue");
final List<Entry> entriesOne = generateEntries(timeRange, numberOfEntries, 1, tagsOne);
db.putEntries(entriesOne);
printEntries(entriesOne, "one");
final Tags tagsTwo = Tags.create("myKey", "two", "commonKey", "commonValue");
final Tags tagsTwo = Tags.createAndAddToDictionary("myKey", "two", "commonKey", "commonValue");
final List<Entry> entriesTwo = generateEntries(timeRange, numberOfEntries, 2, tagsTwo);
printEntries(entriesTwo, "two");
db.putEntries(entriesTwo);
final Tags tagsThree = Tags.create("myKey", "three", "commonKey", "commonValue");
final Tags tagsThree = Tags.createAndAddToDictionary("myKey", "three", "commonKey", "commonValue");
final List<Entry> entriesThree = generateEntries(timeRange, numberOfEntries, 3, tagsThree);
printEntries(entriesThree, "three");
db.putEntries(entriesThree);
@@ -238,9 +238,9 @@ public class PerformanceDbTest {
final long numberOfEntries = timeRange.duration().toHours();
final String key = "myKey";
final Tags tagsOne = Tags.create(key, "one", "commonKey", "commonValue");
final Tags tagsTwo = Tags.create(key, "two", "commonKey", "commonValue");
final Tags tagsThree = Tags.create("commonKey", "commonValue");
final Tags tagsOne = Tags.createAndAddToDictionary(key, "one", "commonKey", "commonValue");
final Tags tagsTwo = Tags.createAndAddToDictionary(key, "two", "commonKey", "commonValue");
final Tags tagsThree = Tags.createAndAddToDictionary("commonKey", "commonValue");
final LongList entriesOne = storeEntries(db, timeRange, numberOfEntries, tagsOne, 1);
final LongList entriesTwo = storeEntries(db, timeRange, numberOfEntries, tagsTwo, 2);
final LongList entriesThree = storeEntries(db, timeRange, numberOfEntries, tagsThree, 3);
@@ -252,9 +252,9 @@ public class PerformanceDbTest {
for (final GroupResult groupResult : groups) {
final Tags groupedBy = groupResult.getGroupedBy();
if (groupedBy.equals(Tags.create(key, "one"))) {
if (groupedBy.equals(Tags.createAndAddToDictionary(key, "one"))) {
Assert.assertEquals(groupResult.flatMap(), entriesOne);
} else if (groupedBy.equals(Tags.create(key, "two"))) {
} else if (groupedBy.equals(Tags.createAndAddToDictionary(key, "two"))) {
Assert.assertEquals(groupResult.flatMap(), entriesTwo);
} else if (groupedBy.isEmpty()) {
@@ -276,10 +276,10 @@ public class PerformanceDbTest {
final String key1 = "myKey1";
final String key2 = "myKey2";
final Tags tagsOne = Tags.create(key1, "one", key2, "aaa", "commonKey", "commonValue");
final Tags tagsTwoA = Tags.create(key1, "two", key2, "bbb", "commonKey", "commonValue");
final Tags tagsTwoB = Tags.create(key1, "two", key2, "bbb", "commonKey", "commonValue");
final Tags tagsThree = Tags.create(key1, "three", "commonKey", "commonValue");
final Tags tagsOne = Tags.createAndAddToDictionary(key1, "one", key2, "aaa", "commonKey", "commonValue");
final Tags tagsTwoA = Tags.createAndAddToDictionary(key1, "two", key2, "bbb", "commonKey", "commonValue");
final Tags tagsTwoB = Tags.createAndAddToDictionary(key1, "two", key2, "bbb", "commonKey", "commonValue");
final Tags tagsThree = Tags.createAndAddToDictionary(key1, "three", "commonKey", "commonValue");
final LongList entriesOne = storeEntries(db, timeRange, numberOfEntries, tagsOne, 1);
final LongList entriesTwo = storeEntries(db, timeRange, numberOfEntries, tagsTwoA, 2);
@@ -293,9 +293,9 @@ public class PerformanceDbTest {
for (final GroupResult groupResult : groups) {
final Tags groupedBy = groupResult.getGroupedBy();
if (groupedBy.equals(Tags.create(key1, "one", key2, "aaa"))) {
if (groupedBy.equals(Tags.createAndAddToDictionary(key1, "one", key2, "aaa"))) {
Assert.assertEquals(groupResult.flatMap(), entriesOne);
} else if (groupedBy.equals(Tags.create(key1, "two", key2, "bbb"))) {
} else if (groupedBy.equals(Tags.createAndAddToDictionary(key1, "two", key2, "bbb"))) {
// there is no defined order of the entries.
// eventually we might return them in ascending order, but
// that is not yet implemented
@@ -305,7 +305,7 @@ public class PerformanceDbTest {
actualEntries.sort();
Assert.assertEquals(actualEntries, entriesTwo);
} else if (groupedBy.equals(Tags.create(key1, "three"))) {
} else if (groupedBy.equals(Tags.createAndAddToDictionary(key1, "three"))) {
Assert.assertEquals(groupResult.flatMap(), entriesThree);
} else {
Assert.fail("unexpected group: " + groupedBy);

View File

@@ -36,7 +36,7 @@ public class TagsToFilesTest {
final TagsToFile tagsToFile = new TagsToFile(dataStore)) {
final OffsetDateTime date = OffsetDateTime.now(ZoneOffset.UTC);
final Tags tags = Tags.create("myKey", "myValue");
final Tags tags = Tags.createAndAddToDictionary("myKey", "myValue");
final PdbWriter newFileForTags = tagsToFile.getWriter(date.toInstant().toEpochMilli(), tags);
@@ -56,7 +56,7 @@ public class TagsToFilesTest {
final long dayB = DateUtils.getDate(2016, 1, 3, 1, 1, 1).toInstant().toEpochMilli();
final long dayC = DateUtils.getDate(2016, 1, 1, 1, 1, 1).toInstant().toEpochMilli();
final Tags tags = Tags.create("myKey", "myValue");
final Tags tags = Tags.createAndAddToDictionary("myKey", "myValue");
final PdbWriter writerForDayA = tagsToFile.getWriter(dayA, tags);
writerForDayA.write(new Entry(dayA, 1, tags));
@@ -78,7 +78,7 @@ public class TagsToFilesTest {
final long timestamp = DateUtils.getDate(2016, 1, 1, 13, 1, 1).toInstant().toEpochMilli();
final Tags tags = Tags.create("myKey", "myValue");
final Tags tags = Tags.createAndAddToDictionary("myKey", "myValue");
final PdbWriter fileA = tagsToFile.getWriter(timestamp, tags);
fileA.write(new Entry(timestamp, 1, tags));