private Sequence<Result<TimeseriesResultValue>> toFilteredQueryableTimeseriesResults(
TimeseriesQuery query,
List<SegmentId> segmentIds,
List<Interval> queryIntervals,
List<Iterable<Result<TimeseriesResultValue>>> results
)
{
MultipleSpecificSegmentSpec spec = (MultipleSpecificSegmentSpec) query.getQuerySegmentSpec();
List<Result<TimeseriesResultValue>> ret = new ArrayList<>();
for (SegmentDescriptor descriptor : spec.getDescriptors()) {
SegmentId id = SegmentId.dummy(
StringUtils.format("%s_%s", queryIntervals.indexOf(descriptor.getInterval()), descriptor.getPartitionNumber())
);
int index = segmentIds.indexOf(id);
if (index != -1) {
Result result = new Result(
results.get(index).iterator().next().getTimestamp(),
new BySegmentResultValueClass(
Lists.newArrayList(results.get(index)),
id.toString(),
descriptor.getInterval()
)
);
ret.add(result);
} else {
throw new ISE("Descriptor %s not found in server", id);
}
}
return Sequences.simple(ret);
}