Search in sources :

Example 1 with SeriesFieldMap

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))));
    }
}
Also used : DBMetadata(com.srotya.sidewinder.core.storage.DBMetadata) HashMap(java.util.HashMap) SimpleTagFilter(com.srotya.sidewinder.core.filters.SimpleTagFilter) File(java.io.File) SeriesFieldMap(com.srotya.sidewinder.core.storage.SeriesFieldMap) Test(org.junit.Test)

Example 2 with SeriesFieldMap

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());
}
Also used : DBMetadata(com.srotya.sidewinder.core.storage.DBMetadata) ComplexTagFilter(com.srotya.sidewinder.core.filters.ComplexTagFilter) HashMap(java.util.HashMap) TagFilter(com.srotya.sidewinder.core.filters.TagFilter) SimpleTagFilter(com.srotya.sidewinder.core.filters.SimpleTagFilter) ComplexTagFilter(com.srotya.sidewinder.core.filters.ComplexTagFilter) SimpleTagFilter(com.srotya.sidewinder.core.filters.SimpleTagFilter) SeriesFieldMap(com.srotya.sidewinder.core.storage.SeriesFieldMap) File(java.io.File) Test(org.junit.Test)

Example 3 with SeriesFieldMap

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());
}
Also used : DBMetadata(com.srotya.sidewinder.core.storage.DBMetadata) ComplexTagFilter(com.srotya.sidewinder.core.filters.ComplexTagFilter) HashMap(java.util.HashMap) TagFilter(com.srotya.sidewinder.core.filters.TagFilter) SimpleTagFilter(com.srotya.sidewinder.core.filters.SimpleTagFilter) ComplexTagFilter(com.srotya.sidewinder.core.filters.ComplexTagFilter) SimpleTagFilter(com.srotya.sidewinder.core.filters.SimpleTagFilter) SeriesFieldMap(com.srotya.sidewinder.core.storage.SeriesFieldMap) File(java.io.File) Test(org.junit.Test)

Example 4 with SeriesFieldMap

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))));
        }
    }
}
Also used : DBMetadata(com.srotya.sidewinder.core.storage.DBMetadata) HashMap(java.util.HashMap) SimpleTagFilter(com.srotya.sidewinder.core.filters.SimpleTagFilter) File(java.io.File) SeriesFieldMap(com.srotya.sidewinder.core.storage.SeriesFieldMap) Test(org.junit.Test)

Example 5 with SeriesFieldMap

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());
}
Also used : DBMetadata(com.srotya.sidewinder.core.storage.DBMetadata) ComplexTagFilter(com.srotya.sidewinder.core.filters.ComplexTagFilter) HashMap(java.util.HashMap) TagFilter(com.srotya.sidewinder.core.filters.TagFilter) SimpleTagFilter(com.srotya.sidewinder.core.filters.SimpleTagFilter) ComplexTagFilter(com.srotya.sidewinder.core.filters.ComplexTagFilter) SimpleTagFilter(com.srotya.sidewinder.core.filters.SimpleTagFilter) SeriesFieldMap(com.srotya.sidewinder.core.storage.SeriesFieldMap) File(java.io.File) Test(org.junit.Test)

Aggregations

SeriesFieldMap (com.srotya.sidewinder.core.storage.SeriesFieldMap)12 File (java.io.File)7 SimpleTagFilter (com.srotya.sidewinder.core.filters.SimpleTagFilter)6 DBMetadata (com.srotya.sidewinder.core.storage.DBMetadata)6 HashMap (java.util.HashMap)6 Test (org.junit.Test)6 ComplexTagFilter (com.srotya.sidewinder.core.filters.ComplexTagFilter)4 TagFilter (com.srotya.sidewinder.core.filters.TagFilter)4 TimeSeries (com.srotya.sidewinder.core.storage.TimeSeries)3 Measurement (com.srotya.sidewinder.core.storage.Measurement)2 IOException (java.io.IOException)2 BufferObject (com.srotya.sidewinder.core.storage.BufferObject)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Entry (java.util.Map.Entry)1