Skip to content

Commit e3cba73

Browse files
committed
Fix #1050 by seeking to the start timestamp of the query when the
time zone aligned timestamp may be earlier than the start time. Signed-off-by: Chris Larsen <[email protected]>
1 parent 15978fb commit e3cba73

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/core/AggregationIterator.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public AggregationIterator(final SeekableView[] iterators,
361361
for (int i = 0; i < size; i++) {
362362
SeekableView it = iterators[i];
363363
it.seek(start_time);
364-
final DataPoint dp;
364+
DataPoint dp;
365365
if (!it.hasNext()) {
366366
++num_empty_spans;
367367
endReached(i);
@@ -374,12 +374,23 @@ public AggregationIterator(final SeekableView[] iterators,
374374
// + dp.timestamp() + " >= " + start_time);
375375
putDataPoint(size + i, dp);
376376
} else {
377-
if (LOG.isDebugEnabled()) {
378-
LOG.debug(String.format("No DP in range for #%d: %d < %d", i,
379-
dp.timestamp(), start_time));
377+
// if there is data, advance to the start time if applicable.
378+
while (dp != null && dp.timestamp() < start_time) {
379+
if (it.hasNext()) {
380+
dp = it.next();
381+
} else {
382+
dp = null;
383+
}
380384
}
381-
endReached(i);
382-
continue;
385+
if (dp == null) {
386+
if (LOG.isDebugEnabled()) {
387+
LOG.debug(String.format("No DP in range for #%d: start time %d", i,
388+
start_time));
389+
}
390+
endReached(i);
391+
continue;
392+
}
393+
putDataPoint(size + i, dp);
383394
}
384395
if (rate) {
385396
// The first rate against the time zero should be populated

0 commit comments

Comments
 (0)