use of com.srotya.sidewinder.core.storage.SeriesFieldMap in project sidewinder by srotya.
the class TestMappedBitmapTagIndex method testDiskTagIndexBasic.
@Test
public void testDiskTagIndexBasic() throws IOException, InterruptedException {
MiscUtils.delete(new File("target/s6"));
String indexDir = "target/s6";
new File(indexDir).mkdirs();
PersistentMeasurement m = new PersistentMeasurement();
Map<String, String> conf = new HashMap<>();
m.configure(conf, engine, "d", "m", "target/s6/i/bitmap", "target/s6/d/bitmap", new DBMetadata(), null);
MappedBitmapTagIndex index = new MappedBitmapTagIndex(indexDir, "s6", m);
long ts = System.currentTimeMillis();
for (int i = 0; i < 10_000; i++) {
index.index("key", String.valueOf(i), i);
String valueOf = String.valueOf(i);
m.getSeriesListAsList().add(new SeriesFieldMap(valueOf));
}
ts = System.currentTimeMillis() - ts;
System.out.println("Time:" + ts);
for (int i = 0; i < 10_000; i++) {
assertEquals(new HashSet<>(Arrays.asList(String.valueOf(i))), index.searchRowKeysForTagFilter(new SimpleTagFilter(FilterType.EQUALS, "key", String.valueOf(i))));
}
}
use of com.srotya.sidewinder.core.storage.SeriesFieldMap in project sidewinder by srotya.
the class TestMappedBitmapTagIndex method testDiskTagIndexFilterEvaluationNormalized.
@Test
public void testDiskTagIndexFilterEvaluationNormalized() throws IOException, InterruptedException {
MiscUtils.delete(new File("target/s8"));
String indexDir = "target/s8";
new File(indexDir).mkdirs();
PersistentMeasurement m = new PersistentMeasurement();
Map<String, String> conf = new HashMap<>();
m.configure(conf, engine, "d", "m", "target/s8/i/bitmap", "target/s8/d/bitmap", new DBMetadata(), null);
MappedBitmapTagIndex index = new MappedBitmapTagIndex(indexDir, "s8", m);
for (int i = 0; i < 10_000; i++) {
String format = String.format("%04d", i);
index.index("key", format, i);
m.getSeriesListAsList().add(new SeriesFieldMap(format));
}
TagFilter filter = new SimpleTagFilter(FilterType.GREATER_THAN, "key", "9990");
Set<String> keys = index.searchRowKeysForTagFilter(filter);
assertEquals(9, keys.size());
filter = new SimpleTagFilter(FilterType.GREATER_THAN_EQUALS, "key", "9990");
keys = index.searchRowKeysForTagFilter(filter);
assertEquals(10, keys.size());
filter = new SimpleTagFilter(FilterType.LESS_THAN, "key", "0010");
keys = index.searchRowKeysForTagFilter(filter);
assertEquals(10, keys.size());
filter = new SimpleTagFilter(FilterType.LESS_THAN_EQUALS, "key", "0010");
keys = index.searchRowKeysForTagFilter(filter);
assertEquals(11, keys.size());
filter = new ComplexTagFilter(ComplexFilterType.AND, Arrays.asList(new SimpleTagFilter(FilterType.EQUALS, "key", "9990"), new SimpleTagFilter(FilterType.EQUALS, "key", "9991")));
keys = index.searchRowKeysForTagFilter(filter);
assertEquals(0, keys.size());
filter = new ComplexTagFilter(ComplexFilterType.AND, Arrays.asList(new SimpleTagFilter(FilterType.EQUALS, "key1", "9990"), new SimpleTagFilter(FilterType.EQUALS, "key", "9991")));
keys = index.searchRowKeysForTagFilter(filter);
assertEquals(0, keys.size());
filter = new ComplexTagFilter(ComplexFilterType.AND, Arrays.asList(new SimpleTagFilter(FilterType.EQUALS, "key", "9990"), new SimpleTagFilter(FilterType.EQUALS, "key1", "9991")));
keys = index.searchRowKeysForTagFilter(filter);
assertEquals(0, keys.size());
filter = new ComplexTagFilter(ComplexFilterType.OR, Arrays.asList(new SimpleTagFilter(FilterType.EQUALS, "key1", "9990"), new SimpleTagFilter(FilterType.EQUALS, "key", "9991")));
keys = index.searchRowKeysForTagFilter(filter);
assertEquals(1, keys.size());
}
use of com.srotya.sidewinder.core.storage.SeriesFieldMap in project sidewinder by srotya.
the class TestMappedBitmapTagIndex method testBitmapIndexMultiTags.
@Test
public void testBitmapIndexMultiTags() throws IOException, InterruptedException {
MiscUtils.delete(new File("target/s9"));
String indexDir = "target/s9";
new File(indexDir).mkdirs();
PersistentMeasurement m = new PersistentMeasurement();
Map<String, String> conf = new HashMap<>();
m.configure(conf, engine, "d", "m", "target/s9/i/bitmap", "target/s9/d/bitmap", new DBMetadata(), null);
MappedBitmapTagIndex index = new MappedBitmapTagIndex(indexDir, "s9", m);
for (int i = 0; i < 10; i++) {
String format = String.format("%04d", i);
index.index("key", format, i / 2);
m.getSeriesListAsList().add(new SeriesFieldMap(format));
}
TagFilter filter = new ComplexTagFilter(ComplexFilterType.AND, Arrays.asList(new SimpleTagFilter(FilterType.EQUALS, "key", "0000"), new SimpleTagFilter(FilterType.EQUALS, "key", "0000")));
Set<String> keys = index.searchRowKeysForTagFilter(filter);
assertEquals(1, keys.size());
filter = new ComplexTagFilter(ComplexFilterType.AND, Arrays.asList(new SimpleTagFilter(FilterType.EQUALS, "key", "0000"), new SimpleTagFilter(FilterType.EQUALS, "key", "0002")));
keys = index.searchRowKeysForTagFilter(filter);
assertEquals(0, keys.size());
filter = new ComplexTagFilter(ComplexFilterType.AND, Arrays.asList(new SimpleTagFilter(FilterType.LESS_THAN, "key", "0004"), new SimpleTagFilter(FilterType.LESS_THAN_EQUALS, "key", "0005")));
keys = index.searchRowKeysForTagFilter(filter);
assertEquals(2, keys.size());
}
use of com.srotya.sidewinder.core.storage.SeriesFieldMap in project sidewinder by srotya.
the class TestMappedBitmapTagIndex method testIndexRecovery.
@Test
public void testIndexRecovery() throws IOException, InterruptedException {
MiscUtils.delete(new File("target/s9"));
String indexDir = "target/s9";
new File(indexDir).mkdirs();
PersistentMeasurement m = new PersistentMeasurement();
Map<String, String> conf = new HashMap<>();
m.configure(conf, engine, "d", "m", "target/s9/i/bitmap", "target/s9/d/bitmap", new DBMetadata(), null);
MappedBitmapTagIndex index = new MappedBitmapTagIndex(indexDir, "s9", m);
long ts = System.currentTimeMillis();
for (int i = 0; i < 10_000; i++) {
index.index("key", String.valueOf(i), i);
String valueOf = String.valueOf(i);
m.getSeriesListAsList().add(new SeriesFieldMap(valueOf));
}
ts = System.currentTimeMillis() - ts;
System.out.println("Time:" + ts);
for (int i = 0; i < 10_000; i++) {
assertEquals(new HashSet<>(Arrays.asList(String.valueOf(i))), index.searchRowKeysForTagFilter(new SimpleTagFilter(FilterType.EQUALS, "key", String.valueOf(i))));
}
for (int k = 0; k < 10; k++) {
index = new MappedBitmapTagIndex(indexDir, "s9", m);
for (int i = 0; i < 10_000; i++) {
assertEquals(new HashSet<>(Arrays.asList(String.valueOf(i))), index.searchRowKeysForTagFilter(new SimpleTagFilter(FilterType.EQUALS, "key", String.valueOf(i))));
}
}
}
use of com.srotya.sidewinder.core.storage.SeriesFieldMap in project sidewinder by srotya.
the class TestMappedSetTagIndex method testDiskTagIndexFilterEvaluationIdx.
@Test
public void testDiskTagIndexFilterEvaluationIdx() throws IOException, InterruptedException {
MiscUtils.delete(new File("target/i7"));
String indexDir = "target/i7";
new File(indexDir).mkdirs();
PersistentMeasurement m = new PersistentMeasurement();
Map<String, String> conf = new HashMap<>();
m.configure(conf, engine, "d", "m", "target/i7/i/bitmap", "target/i7/d/bitmap", new DBMetadata(), null);
MappedSetTagIndex index = new MappedSetTagIndex("target/i7/i/bitmap", "s7", true, m);
for (int i = 0; i < 10_000; i++) {
String valueOf = String.valueOf(i);
index.index("key", valueOf, i);
m.getSeriesListAsList().add(new SeriesFieldMap(valueOf));
}
TagFilter filter = new SimpleTagFilter(FilterType.GREATER_THAN, "key", "9");
Set<String> keys = index.searchRowKeysForTagFilter(filter);
assertEquals(1110, keys.size());
filter = new SimpleTagFilter(FilterType.GREATER_THAN_EQUALS, "key", "9");
keys = index.searchRowKeysForTagFilter(filter);
assertEquals(1111, keys.size());
filter = new SimpleTagFilter(FilterType.LESS_THAN, "key", "10");
keys = index.searchRowKeysForTagFilter(filter);
assertEquals(2, keys.size());
filter = new SimpleTagFilter(FilterType.LESS_THAN_EQUALS, "key", "1000");
keys = index.searchRowKeysForTagFilter(filter);
// keys.stream().forEach(System.out::println);
assertEquals(5, keys.size());
filter = new ComplexTagFilter(ComplexFilterType.AND, Arrays.asList(new SimpleTagFilter(FilterType.EQUALS, "key", "9990"), new SimpleTagFilter(FilterType.EQUALS, "key", "9991")));
keys = index.searchRowKeysForTagFilter(filter);
assertEquals(0, keys.size());
filter = new ComplexTagFilter(ComplexFilterType.AND, Arrays.asList(new SimpleTagFilter(FilterType.EQUALS, "key1", "9990"), new SimpleTagFilter(FilterType.EQUALS, "key", "9991")));
keys = index.searchRowKeysForTagFilter(filter);
assertEquals(0, keys.size());
filter = new ComplexTagFilter(ComplexFilterType.AND, Arrays.asList(new SimpleTagFilter(FilterType.EQUALS, "key", "9990"), new SimpleTagFilter(FilterType.EQUALS, "key1", "9991")));
keys = index.searchRowKeysForTagFilter(filter);
assertEquals(0, keys.size());
filter = new ComplexTagFilter(ComplexFilterType.OR, Arrays.asList(new SimpleTagFilter(FilterType.EQUALS, "key1", "9990"), new SimpleTagFilter(FilterType.EQUALS, "key", "9991")));
keys = index.searchRowKeysForTagFilter(filter);
assertEquals(1, keys.size());
}
Aggregations