private Iterator<TimeValue> queryTimeSeries(MetricsScope scope, MetricsScanQuery scanQuery,
Interpolator interpolator) throws OperationException {
Map<TimeseriesId, Iterable<TimeValue>> timeValues = Maps.newHashMap();
MetricsScanner scanner = metricsTableCaches.get(scope).getUnchecked(1).scan(scanQuery);
while (scanner.hasNext()) {
MetricsScanResult res = scanner.next();
// if we get multiple scan results for the same logical timeseries, concatenate them together.
// Needed if we need to interpolate across scan results. Using the fact that the is a scan
// over an ordered table, so the earlier timeseries is guaranteed to come first.
TimeseriesId timeseriesId = new TimeseriesId(res.getContext(), res.getMetric(), res.getTag(), res.getRunId());
if (!timeValues.containsKey(timeseriesId)) {
timeValues.put(timeseriesId, res);
} else {
timeValues.put(timeseriesId, Iterables.concat(timeValues.get(timeseriesId), res));
}