@Override public TimeSeries<Long, Double> from(BinaryTimeSeries binaryTimeSeries, long queryStart, long queryEnd) { //This is a hack MetricTimeSeries metricTimeSeries = new MetricTimeSeriesConverter().from(binaryTimeSeries, queryStart, queryEnd); TimeSeries<Long, Double> timeSeries = new TimeSeries<>(map(metricTimeSeries.points())); metricTimeSeries.getAttributesReference().forEach(timeSeries::addAttribute); return timeSeries; }
@Override public BinaryTimeSeries to(TimeSeries<Long, Double> timeSeries) { //-oo is represented through the first element that is null, hence if the size is one the time series is empty if (timeSeries.size() == 1) { LOGGER.info("Empty time series detected. {}", timeSeries); //Create a builder with the minimal required fields BinaryTimeSeries.Builder builder = new BinaryTimeSeries.Builder() .data(new byte[]{}) .start(0) .end(0); return builder.build(); } else { return new MetricTimeSeriesConverter().to(map(timeSeries)); } }