use of com.srotya.sidewinder.core.storage.compression.Reader in project sidewinder by srotya.
the class TimeSeries method getReader.
/**
* Get {@link Reader} with time and value filter predicates pushed-down to it.
*
* @param timePredicate
* @param valuePredicate
* @return point in time instance of reader
* @throws IOException
*/
public static Reader getReader(Writer writer, Predicate timePredicate, Predicate valuePredicate) throws IOException {
Reader reader = writer.getReader();
reader.setTimePredicate(timePredicate);
reader.setValuePredicate(valuePredicate);
return reader;
}
use of com.srotya.sidewinder.core.storage.compression.Reader 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;
}
use of com.srotya.sidewinder.core.storage.compression.Reader in project sidewinder by srotya.
the class TimeSeries method seriesToDataPoints.
/**
* Converts timeseries to a list of datapoints appended to the supplied list
* object. Datapoints are filtered by the supplied predicates before they are
* returned. These predicates are pushed down to the reader for efficiency and
* performance as it prevents unnecessary object creation.
*
* @param appendFieldValueName
* @param appendTags
*
* @param points
* list data points are appended to
* @param writer
* to extract the data points from
* @param timePredicate
* time range filter
* @param valuePredicate
* value filter
* @return the points argument
* @throws IOException
*/
public static List<DataPoint> seriesToDataPoints(String appendFieldValueName, List<String> appendTags, List<DataPoint> points, Writer writer, Predicate timePredicate, Predicate valuePredicate, boolean isFp) throws IOException {
Reader reader = getReader(writer, timePredicate, valuePredicate);
DataPoint point = null;
while (true) {
try {
point = reader.readPair();
if (point != null) {
points.add(point);
}
} catch (IOException e) {
if (e instanceof RejectException) {
} else {
e.printStackTrace();
}
break;
}
}
return points;
}
use of com.srotya.sidewinder.core.storage.compression.Reader in project sidewinder by srotya.
the class Measurement method queryReadersWithMap.
public default void queryReadersWithMap(String valueFieldName, long startTime, long endTime, LinkedHashMap<Reader, List<Tag>> readers) throws IOException {
for (String entry : getSeriesKeys()) {
SeriesFieldMap m = getSeriesFromKey(entry);
TimeSeries series = m.get(valueFieldName);
if (series == null) {
continue;
}
List<Tag> seriesTags = decodeStringToTags(getTagIndex(), entry);
for (Reader reader : series.queryReader(valueFieldName, seriesTags, startTime, endTime, null)) {
readers.put(reader, seriesTags);
}
}
}
use of com.srotya.sidewinder.core.storage.compression.Reader in project sidewinder by srotya.
the class Measurement method queryReaders.
public default void queryReaders(String valueFieldName, long startTime, long endTime, LinkedHashMap<Reader, Boolean> readers) throws IOException {
for (String entry : getSeriesKeys()) {
SeriesFieldMap m = getSeriesFromKey(entry);
TimeSeries series = m.get(valueFieldName);
if (series == null) {
continue;
}
List<Tag> seriesTags = decodeStringToTags(getTagIndex(), entry);
for (Reader reader : series.queryReader(valueFieldName, seriesTags, startTime, endTime, null)) {
readers.put(reader, series.isFp());
}
}
}
Aggregations