Search in sources :

Example 1 with BetweenPredicate

use of com.srotya.sidewinder.core.predicates.BetweenPredicate in project sidewinder by srotya.

the class TestDiskStorageEngine method testSeriesToDataPointConversion.

@Test
public void testSeriesToDataPointConversion() throws IOException {
    List<DataPoint> points = new ArrayList<>();
    long headerTimestamp = System.currentTimeMillis();
    HashMap<String, String> map = new HashMap<>();
    map.put("metadata.dir", "target/db1/mdq");
    map.put("index.dir", "target/db1/index");
    map.put("data.dir", "target/db1/data");
    map.put(StorageEngine.PERSISTENCE_DISK, "true");
    ByteBuffer buf = ByteBuffer.allocate(100);
    Writer timeSeries = new ByzantineWriter();
    timeSeries.configure(map, buf, true, 1, false);
    timeSeries.setHeaderTimestamp(headerTimestamp);
    timeSeries.addValue(headerTimestamp, 1L);
    TimeSeries.seriesToDataPoints("value", Arrays.asList("test=1"), points, timeSeries, null, null, false);
    assertEquals(1, points.size());
    points.clear();
    Predicate timepredicate = new BetweenPredicate(Long.MAX_VALUE, Long.MAX_VALUE);
    TimeSeries.seriesToDataPoints("value", Arrays.asList("test=1"), points, timeSeries, timepredicate, null, false);
    assertEquals(0, points.size());
}
Also used : BetweenPredicate(com.srotya.sidewinder.core.predicates.BetweenPredicate) DataPoint(com.srotya.sidewinder.core.storage.DataPoint) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ByzantineWriter(com.srotya.sidewinder.core.storage.compression.byzantine.ByzantineWriter) ArrayList(java.util.ArrayList) ByteBuffer(java.nio.ByteBuffer) Writer(com.srotya.sidewinder.core.storage.compression.Writer) ByzantineWriter(com.srotya.sidewinder.core.storage.compression.byzantine.ByzantineWriter) BetweenPredicate(com.srotya.sidewinder.core.predicates.BetweenPredicate) Predicate(com.srotya.sidewinder.core.predicates.Predicate) Test(org.junit.Test)

Example 2 with BetweenPredicate

use of com.srotya.sidewinder.core.predicates.BetweenPredicate in project sidewinder by srotya.

the class TestMemStorageEngine method testSeriesToDataPointConversion.

@Test
public void testSeriesToDataPointConversion() throws IOException {
    List<DataPoint> points = new ArrayList<>();
    long headerTimestamp = System.currentTimeMillis();
    ByteBuffer buf = ByteBuffer.allocate(1024);
    Writer timeSeries = new ByzantineWriter();
    timeSeries.configure(conf, buf, true, 1, false);
    timeSeries.setHeaderTimestamp(headerTimestamp);
    timeSeries.addValue(headerTimestamp, 1L);
    TimeSeries.seriesToDataPoints("value", Arrays.asList("test=2"), points, timeSeries, null, null, false);
    assertEquals(1, points.size());
    points.clear();
    Predicate timepredicate = new BetweenPredicate(Long.MAX_VALUE, Long.MAX_VALUE);
    TimeSeries.seriesToDataPoints("value", Arrays.asList("test=2"), points, timeSeries, timepredicate, null, false);
    assertEquals(0, points.size());
}
Also used : BetweenPredicate(com.srotya.sidewinder.core.predicates.BetweenPredicate) DataPoint(com.srotya.sidewinder.core.storage.DataPoint) ByzantineWriter(com.srotya.sidewinder.core.storage.compression.byzantine.ByzantineWriter) ArrayList(java.util.ArrayList) ByteBuffer(java.nio.ByteBuffer) Writer(com.srotya.sidewinder.core.storage.compression.Writer) ByzantineWriter(com.srotya.sidewinder.core.storage.compression.byzantine.ByzantineWriter) Predicate(com.srotya.sidewinder.core.predicates.Predicate) BetweenPredicate(com.srotya.sidewinder.core.predicates.BetweenPredicate) Test(org.junit.Test)

Example 3 with BetweenPredicate

use of com.srotya.sidewinder.core.predicates.BetweenPredicate in project sidewinder by srotya.

the class TimeSeries method queryPoints.

public List<long[]> queryPoints(String appendFieldValueName, List<String> appendTags, long startTime, long endTime, Predicate valuePredicate) throws IOException {
    if (startTime > endTime) {
        // swap start and end times if they are off
        startTime = startTime ^ endTime;
        endTime = endTime ^ startTime;
        startTime = startTime ^ endTime;
    }
    BetweenPredicate timeRangePredicate = new BetweenPredicate(startTime, endTime);
    SortedMap<String, List<Writer>> series = correctTimeRangeScan(startTime, endTime);
    List<Reader> readers = new ArrayList<>();
    for (List<Writer> writers : series.values()) {
        for (Writer writer : writers) {
            readers.add(getReader(writer, timeRangePredicate, valuePredicate));
        }
    }
    List<long[]> points = new ArrayList<>();
    for (Reader reader : readers) {
        readerToPoints(points, reader);
    }
    return points;
}
Also used : BetweenPredicate(com.srotya.sidewinder.core.predicates.BetweenPredicate) ArrayList(java.util.ArrayList) Reader(com.srotya.sidewinder.core.storage.compression.Reader) ArrayList(java.util.ArrayList) List(java.util.List) Writer(com.srotya.sidewinder.core.storage.compression.Writer)

Example 4 with BetweenPredicate

use of com.srotya.sidewinder.core.predicates.BetweenPredicate in project sidewinder by srotya.

the class TimeSeries method queryReader.

/**
 * Extract list of readers for the supplied time range and value predicate.
 *
 * Each {@link DataPoint} has the appendFieldValue and appendTags set in it.
 *
 * @param appendFieldValueName
 *            fieldname to append to each datapoint
 * @param appendTags
 *            tags to append to each datapoint
 * @param startTime
 *            time range beginning
 * @param endTime
 *            time range end
 * @param valuePredicate
 *            pushed down filter for values
 * @return list of readers
 * @throws IOException
 */
public List<Reader> queryReader(String appendFieldValueName, List<Tag> appendTags, long startTime, long endTime, Predicate valuePredicate) throws IOException {
    if (startTime > endTime) {
        // swap start and end times if they are off
        startTime = startTime ^ endTime;
        endTime = endTime ^ startTime;
        startTime = startTime ^ endTime;
    }
    List<Reader> readers = new ArrayList<>();
    BetweenPredicate timeRangePredicate = new BetweenPredicate(startTime, endTime);
    SortedMap<String, List<Writer>> series = correctTimeRangeScan(startTime, endTime);
    for (List<Writer> writers : series.values()) {
        for (Writer writer : writers) {
            readers.add(getReader(writer, timeRangePredicate, valuePredicate));
        }
    }
    return readers;
}
Also used : BetweenPredicate(com.srotya.sidewinder.core.predicates.BetweenPredicate) ArrayList(java.util.ArrayList) Reader(com.srotya.sidewinder.core.storage.compression.Reader) ArrayList(java.util.ArrayList) List(java.util.List) Writer(com.srotya.sidewinder.core.storage.compression.Writer)

Example 5 with BetweenPredicate

use of com.srotya.sidewinder.core.predicates.BetweenPredicate in project sidewinder by srotya.

the class TimeSeries method queryDataPoints.

/**
 * Extract {@link DataPoint}s for the supplied time range and value predicate.
 *
 * Each {@link DataPoint} has the appendFieldValue and appendTags set in it.
 *
 * @param appendFieldValueName
 *            fieldname to append to each datapoint
 * @param startTime
 *            time range beginning
 * @param endTime
 *            time range end
 * @param valuePredicate
 *            pushed down filter for values
 * @return list of datapoints
 * @throws IOException
 */
public List<DataPoint> queryDataPoints(String appendFieldValueName, long startTime, long endTime, Predicate valuePredicate) throws IOException {
    if (startTime > endTime) {
        // swap start and end times if they are off
        startTime = startTime ^ endTime;
        endTime = endTime ^ startTime;
        startTime = startTime ^ endTime;
    }
    BetweenPredicate timeRangePredicate = new BetweenPredicate(startTime, endTime);
    logger.fine(getSeriesId() + " " + bucketMap.size() + " " + bucketCount + " " + startTime + "  " + endTime + " " + valuePredicate + " " + timeRangePredicate + " diff:" + (endTime - startTime));
    SortedMap<String, List<Writer>> series = correctTimeRangeScan(startTime, endTime);
    List<Reader> readers = new ArrayList<>();
    for (List<Writer> writers : series.values()) {
        for (Writer writer : writers) {
            readers.add(getReader(writer, timeRangePredicate, valuePredicate));
        }
    }
    List<DataPoint> points = new ArrayList<>();
    for (Reader reader : readers) {
        readerToDataPoints(points, reader);
    }
    return points;
}
Also used : BetweenPredicate(com.srotya.sidewinder.core.predicates.BetweenPredicate) ArrayList(java.util.ArrayList) Reader(com.srotya.sidewinder.core.storage.compression.Reader) ArrayList(java.util.ArrayList) List(java.util.List) Writer(com.srotya.sidewinder.core.storage.compression.Writer)

Aggregations

BetweenPredicate (com.srotya.sidewinder.core.predicates.BetweenPredicate)5 Writer (com.srotya.sidewinder.core.storage.compression.Writer)5 ArrayList (java.util.ArrayList)5 Reader (com.srotya.sidewinder.core.storage.compression.Reader)3 List (java.util.List)3 Predicate (com.srotya.sidewinder.core.predicates.Predicate)2 DataPoint (com.srotya.sidewinder.core.storage.DataPoint)2 ByzantineWriter (com.srotya.sidewinder.core.storage.compression.byzantine.ByzantineWriter)2 ByteBuffer (java.nio.ByteBuffer)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1