Skip to content
Merged
Show file tree
Hide file tree
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 @@ -133,6 +133,10 @@ public IDeviceID next() {
return currentDeviceAndMeasurementNodeOffsetPair.getLeft();
}

public boolean hasCurrent() {
return this.currentDeviceAndMeasurementNodeOffsetPair != null;
}

public IDeviceID getCurrentDeviceID() {
if (currentDeviceAndMeasurementNodeOffsetPair == null) {
throw new IllegalStateException("next() must be called before accessing current device");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public TsFileDeviceIterator(
}

public Pair<IDeviceID, Boolean> current() throws IOException {
if (!lazyTsFileDeviceIterator.hasCurrent()) {
return null;
}
return new Pair<>(
lazyTsFileDeviceIterator.getCurrentDeviceID(),
lazyTsFileDeviceIterator.isCurrentDeviceAligned());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void test() throws IOException {
int deviceFromIterator = 0;
try (TsFileSequenceReader reader = new TsFileSequenceReader(FILE_PATH)) {
TsFileDeviceIterator deviceIterator = reader.getAllDevicesIteratorWithIsAligned();
Assert.assertNull(deviceIterator.current());
IDeviceID previous = null;
while (deviceIterator.hasNext()) {
Pair<IDeviceID, Boolean> next = deviceIterator.next();
Expand Down
Loading