use of com.srotya.sidewinder.core.storage.DataPointIterator in project sidewinder by srotya.
the class GrafanaOutputv2Iterator method next.
@Override
public GrafanaOutputv2 next() {
SeriesOutputv2 entry = iterator.next();
GrafanaOutputv2 tar = new GrafanaOutputv2(entry.toString(), entry.isFp());
DataPointIterator iterator = entry.getIterator();
if (iterator != null) {
tar.setPointsIterator(iterator);
}
return tar;
}
use of com.srotya.sidewinder.core.storage.DataPointIterator in project sidewinder by srotya.
the class FunctionIteratorFactory method build.
public DataPointIterator build(DataPointIterator iterator, boolean isFp) throws Exception {
DataPointIterator functionIterator = iterator;
// chain all the function outputs
for (FunctionTemplate template : templateChain) {
FunctionIterator temp = template.getConstructor().newInstance(functionIterator, isFp);
temp.init(template.getArgs());
functionIterator = temp;
}
return functionIterator;
}
use of com.srotya.sidewinder.core.storage.DataPointIterator in project sidewinder by srotya.
the class TestDownSamplingIFunction method testBasicSumDownSampling.
@Test
public void testBasicSumDownSampling() throws IOException {
Field tField = new TimeField(measurement, new LinkedByteString().concat(new ByteString("time")), 121213, new HashMap<>());
long ts = 1546755994280L;
for (int i = 0; i < 100; i++) {
tField.addDataPoint(measurement, ts + i * 1000);
}
Field vField = new ValueField(measurement, new LinkedByteString().concat(new ByteString("field1")), 121213, new HashMap<>());
for (int i = 0; i < 100; i++) {
vField.addDataPoint(measurement, i);
}
DataPointIterator itr = new DataPointIterator(tField.queryReader(null, new NoLock()), vField.queryReader(null, new NoLock()));
DownsampleFunction f = new DownsampleFunction(itr, 5, TimeUnit.SECONDS, ((x, y) -> (x + y)));
int c = 0;
while (f.hasNext()) {
DataPoint next = f.next();
if (c < 20) {
assertEquals(ts + c * 1000 * 5, next.getTimestamp());
}
c++;
}
assertEquals(21, c);
itr = new DataPointIterator(tField.queryReader(null, new NoLock()), vField.queryReader(null, new NoLock()));
f = new DownsampleFunction(itr, 10, TimeUnit.SECONDS, ((x, y) -> (x + y) / 2));
c = 0;
while (f.hasNext()) {
DataPoint next = f.next();
if (c < 10) {
assertEquals(ts + c * 1000 * 10, next.getTimestamp());
}
c++;
}
assertEquals(10, c, 1);
}
use of com.srotya.sidewinder.core.storage.DataPointIterator in project sidewinder by srotya.
the class TestBasicSingleFunctions method before.
@Before
public void before() throws IOException {
measurement = new MockMeasurement(32768, 100);
TimeField.compressionClass = CompressionFactory.getTimeClassByName("byzantine");
Field tField = new TimeField(measurement, new LinkedByteString().concat(new ByteString("time")), 121213, new HashMap<>());
long ts = 1546755991280L;
for (int i = 0; i < 200; i++) {
tField.addDataPoint(measurement, ts + i * 1000);
}
Field vField = new ValueField(measurement, new LinkedByteString().concat(new ByteString("field1")), 121213, new HashMap<>());
for (int i = 0; i < 100; i++) {
vField.addDataPoint(measurement, i * 1L);
}
for (int i = 100; i > 0; i--) {
vField.addDataPoint(measurement, i * 1L);
}
itr = new DataPointIterator(tField.queryReader(null, new NoLock()), vField.queryReader(null, new NoLock()));
}
use of com.srotya.sidewinder.core.storage.DataPointIterator in project sidewinder by srotya.
the class GrafanaStreamingOutput method serializeOutput.
private boolean serializeOutput(OutputStream os, Iterator<GrafanaOutputv2> itr) throws IOException {
GrafanaOutputv2 gOutput = itr.next();
if (gOutput.getPointsIterator() != null) {
DataPointIterator pointsIterator = gOutput.getPointsIterator();
if (pointsIterator.hasNext()) {
os.write(("{\"target\":\"" + gOutput.getTarget() + "\",\"datapoints\":[").getBytes());
serializePoint(os, pointsIterator, gOutput);
while (pointsIterator.hasNext()) {
os.write(',');
serializePoint(os, pointsIterator, gOutput);
}
os.write(']');
os.write('}');
return true;
} else {
return false;
}
} else {
return false;
}
}
Aggregations