Search in sources :

Example 61 with DataPoint

use of com.srotya.sidewinder.core.storage.DataPoint in project sidewinder by srotya.

the class TestSingleValueAggregators method testFirstFunction.

@Test
public void testFirstFunction() {
    FirstFunction f = new FirstFunction();
    double[] values = { 2.2, 1.1, 3.3, 4.4 };
    List<DataPoint> dps = new ArrayList<>();
    long ts = System.currentTimeMillis();
    for (double d : values) {
        dps.add(MiscUtils.buildDataPoint(ts, d));
    }
    Series series = new Series();
    series.setDataPoints(dps);
    Series result = f.apply(series);
    assertEquals(2.2, result.getDataPoints().get(0).getValue(), 0);
// List<long[]> data = new ArrayList<>();
// for(double d:values) {
// data.add(new long[] {ts, Double.doubleToLongBits(d)});
// }
// List<long[]> aggregatePoints = f.aggregatePoints(data, true);
// assertEquals(1, aggregatePoints.size());
// assertEquals(2.2, Double.longBitsToDouble(aggregatePoints.get(0)[1]), 0);
}
Also used : Series(com.srotya.sidewinder.core.storage.Series) DataPoint(com.srotya.sidewinder.core.storage.DataPoint) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 62 with DataPoint

use of com.srotya.sidewinder.core.storage.DataPoint in project sidewinder by srotya.

the class TestSingleValueAggregators method testLastFunction.

@Test
public void testLastFunction() {
    LastFunction f = new LastFunction();
    double[] values = { 2.2, 1.1, 3.3, 4.4 };
    List<DataPoint> dps = new ArrayList<>();
    long ts = System.currentTimeMillis();
    for (double d : values) {
        dps.add(MiscUtils.buildDataPoint(ts, d));
    }
    Series series = new Series();
    series.setDataPoints(dps);
    Series result = f.apply(series);
    assertEquals(4.4, result.getDataPoints().get(0).getValue(), 0);
}
Also used : Series(com.srotya.sidewinder.core.storage.Series) DataPoint(com.srotya.sidewinder.core.storage.DataPoint) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 63 with DataPoint

use of com.srotya.sidewinder.core.storage.DataPoint in project sidewinder by srotya.

the class TestSingleValueAggregators method testFirstFunctionLong.

@Test
public void testFirstFunctionLong() {
    FirstFunction f = new FirstFunction();
    long[] values = { 2, 1, 3, 4 };
    List<DataPoint> dps = new ArrayList<>();
    long ts = System.currentTimeMillis();
    for (long d : values) {
        dps.add(MiscUtils.buildDataPoint(ts, d));
    }
    Series series = new Series();
    series.setDataPoints(dps);
    Series result = f.apply(series);
    assertEquals(2, result.getDataPoints().get(0).getLongValue());
}
Also used : Series(com.srotya.sidewinder.core.storage.Series) DataPoint(com.srotya.sidewinder.core.storage.DataPoint) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 64 with DataPoint

use of com.srotya.sidewinder.core.storage.DataPoint in project sidewinder by srotya.

the class GorillaReader method readPair.

@Override
public DataPoint readPair() throws IOException {
    if (counter < count) {
        DataPoint pair = decompressor.readPair();
        if (timePredicate != null && !timePredicate.test(pair.getTimestamp())) {
            return null;
        }
        if (valuePredicate != null && !valuePredicate.test(pair.getLongValue())) {
            return null;
        }
        counter++;
        return pair;
    } else {
        throw EOS_EXCEPTION;
    }
}
Also used : DataPoint(com.srotya.sidewinder.core.storage.DataPoint)

Example 65 with DataPoint

use of com.srotya.sidewinder.core.storage.DataPoint in project sidewinder by srotya.

the class ByzantineReader method readPair.

@Override
public DataPoint readPair() throws IOException {
    DataPoint dp = null;
    if (counter < count) {
        uncompressAndReadTimestamp();
        uncompressAndReadValue();
        counter++;
        if (timePredicate != null && !timePredicate.test(prevTs)) {
            return null;
        }
        if (valuePredicate != null && !valuePredicate.test(prevValue)) {
            return null;
        }
        dp = new DataPoint();
        dp.setTimestamp(prevTs);
        dp.setLongValue(prevValue);
        return dp;
    } else {
        throw EOS_EXCEPTION;
    }
}
Also used : DataPoint(com.srotya.sidewinder.core.storage.DataPoint)

Aggregations

DataPoint (com.srotya.sidewinder.core.storage.DataPoint)67 Test (org.junit.Test)52 Series (com.srotya.sidewinder.core.storage.Series)40 ArrayList (java.util.ArrayList)39 IOException (java.io.IOException)16 Reader (com.srotya.sidewinder.core.storage.compression.Reader)13 TimeSeries (com.srotya.sidewinder.core.storage.TimeSeries)12 ByteBuffer (java.nio.ByteBuffer)11 ReducingWindowedAggregator (com.srotya.sidewinder.core.functions.windowed.ReducingWindowedAggregator)10 HashMap (java.util.HashMap)10 LinkedHashMap (java.util.LinkedHashMap)10 RejectException (com.srotya.sidewinder.core.storage.RejectException)9 File (java.io.File)9 Point (com.srotya.sidewinder.core.rpc.Point)8 ItemNotFoundException (com.srotya.sidewinder.core.storage.ItemNotFoundException)8 List (java.util.List)8 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 Tag (com.srotya.sidewinder.core.filters.Tag)5 Writer (com.srotya.sidewinder.core.storage.compression.Writer)5 ByzantineWriter (com.srotya.sidewinder.core.storage.compression.byzantine.ByzantineWriter)4