Skip to content

Commit

Permalink
Slightly refactor LocalFileSystemExchangeStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
linzebing authored and arhimondr committed May 10, 2022
1 parent 6ed6160 commit 260a244
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ private static class LocalExchangeStorageReader
private static final int INSTANCE_SIZE = ClassLayout.parseClass(LocalExchangeStorageReader.class).instanceSize();

private final Queue<ExchangeSourceFile> sourceFiles;

@GuardedBy("this")
private InputStreamSliceInput sliceInput;
@GuardedBy("this")
Expand All @@ -185,18 +186,19 @@ public synchronized Slice read()
if (closed) {
return null;
}

if (sliceInput != null && sliceInput.isReadable()) {
return sliceInput.readSlice(sliceInput.readInt());
}

ExchangeSourceFile sourceFile = sourceFiles.poll();
if (sourceFile != null) {
sliceInput = getSliceInput(sourceFile);
return sliceInput.readSlice(sliceInput.readInt());
}
else {
if (sourceFile == null) {
close();
return null;
}
return null;

sliceInput = getSliceInput(sourceFile);
return sliceInput.readSlice(sliceInput.readInt());
}

@Override
Expand Down

0 comments on commit 260a244

Please sign in to comment.