Skip to content

Commit

Permalink
DRILL-4109 Fix NPE in RecordIterator.
Browse files Browse the repository at this point in the history
  • Loading branch information
amithadke committed Dec 3, 2015
1 parent 46c47a2 commit d44b889
Showing 1 changed file with 10 additions and 6 deletions.
Expand Up @@ -93,7 +93,7 @@ public void mark() {
// Release all batches before current batch. [0 to startBatchPosition).
final Map<Range<Long>,RecordBatchData> oldBatches = batches.subRangeMap(Range.closedOpen(0l, startBatchPosition)).asMapOfRanges();
for (Range<Long> range : oldBatches.keySet()) {
oldBatches.get(range.lowerEndpoint()).clear();
oldBatches.get(range).clear();
}
batches.remove(Range.closedOpen(0l, startBatchPosition));
markedInnerPosition = innerPosition;
Expand All @@ -113,8 +113,9 @@ public void reset() {
}
innerPosition = markedInnerPosition;
outerPosition = markedOuterPosition;
startBatchPosition = batches.getEntry(outerPosition).getKey().lowerEndpoint();
innerRecordCount = (int)(batches.getEntry(outerPosition).getKey().upperEndpoint() - startBatchPosition);
final Range<Long> markedBatchRange = batches.getEntry(outerPosition).getKey();
startBatchPosition = markedBatchRange.lowerEndpoint();
innerRecordCount = (int)(markedBatchRange.upperEndpoint() - startBatchPosition);
markedInnerPosition = -1;
markedOuterPosition = -1;
}
Expand All @@ -133,9 +134,10 @@ public void forward(long delta) {
// Get vectors from new position.
container.transferIn(rbdNew.getContainer());
outerPosition = nextOuterPosition;
startBatchPosition = batches.getEntry(outerPosition).getKey().lowerEndpoint();
final Range<Long> markedBatchRange = batches.getEntry(outerPosition).getKey();
startBatchPosition = markedBatchRange.lowerEndpoint();
innerPosition = (int)(outerPosition - startBatchPosition);
innerRecordCount = (int)(batches.getEntry(outerPosition).getKey().upperEndpoint() - startBatchPosition);
innerRecordCount = (int)(markedBatchRange.upperEndpoint() - startBatchPosition);
}

/**
Expand Down Expand Up @@ -239,7 +241,9 @@ public long getOuterPosition() {

public int getCurrentPosition() {
Preconditions.checkArgument(initialized);
Preconditions.checkArgument(innerPosition >= 0 && innerPosition < innerRecordCount);
Preconditions.checkArgument(innerPosition >= 0 && innerPosition < innerRecordCount,
String.format("innerPosition:%d, outerPosition:%d, innerRecordCount:%d, totalRecordCount:%d",
innerPosition, outerPosition, innerRecordCount, totalRecordCount));
return innerPosition;
}

Expand Down

0 comments on commit d44b889

Please sign in to comment.