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());
}
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());
}
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;
}
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;
}
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;
}
Aggregations