Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ abstract class AbstractGapFillOperator implements ProcessOperator {
private final long endTime;

protected long currentTime;
private boolean timeIteratorExhausted;
private SortKey lastGroupKey = null;

AbstractGapFillOperator(
Expand Down Expand Up @@ -140,6 +141,14 @@ public TsBlock next() throws Exception {

private void resetTimeIterator() {
currentTime = startTime;
timeIteratorExhausted = false;
}

private void advanceTimeIterator() {
long previousTime = currentTime;
nextTime();
// Saturation leaves no later timestamp to mark the consumed window across next() calls.
timeIteratorExhausted |= currentTime <= previousTime;
}

private void writeCurrentRow(TsBlock block, int rowIndex) {
Expand All @@ -153,7 +162,7 @@ private void writeCurrentRow(TsBlock block, int rowIndex) {
columnBuilder.write(column, rowIndex);
}
}
nextTime();
advanceTimeIterator();
}

private void fillGaps(TsBlock block, int rowIndex, long currentEndTime) {
Expand All @@ -162,13 +171,10 @@ private void fillGaps(TsBlock block, int rowIndex, long currentEndTime) {

private void fillGaps(
TsBlock block, int rowIndex, long currentEndTime, boolean endTimeInclusive) {
while (currentTime < currentEndTime || (endTimeInclusive && currentTime == currentEndTime)) {
long previousTime = currentTime;
while (!timeIteratorExhausted
&& (currentTime < currentEndTime || (endTimeInclusive && currentTime == currentEndTime))) {
gapFillRow(currentTime, block, rowIndex);
nextTime();
if (currentTime <= previousTime) {
break;
}
advanceTimeIterator();
}
}

Expand Down Expand Up @@ -224,7 +230,7 @@ public boolean hasNext() throws Exception {
}

private boolean hasRemainingGapInPreviousGroup() {
return lastGroupKey != null && currentTime < endTime;
return lastGroupKey != null && !timeIteratorExhausted && currentTime <= endTime;
}

@Override
Expand Down
Loading