Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEZ-4088: Create in-memory ifile writer for transferring small payload #50

Merged
merged 3 commits into from
Oct 11, 2019

Conversation

rbalamohan
Copy link
Contributor

No description provided.

Copy link
Contributor

@sidseth sidseth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have left some comments - nits, maybe avoid a buffer copy etc. Please pick and choose if you want to change any of those.
Other than that +1.

this.taskOutput = taskOutput;
this.bufferFull = (cacheStream == null);
this.cacheSize = (cacheStream == null) ? 0 :
Math.max(getBaseCacheSize(), cacheStream.available());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: CacheSize could be replaced by availableDataSize which combines this calculation along with the one done in shouldWriteToDisk. Will make the code a little easier to read.

return totalSize >= (cacheSize - (checksumSize +
          (2 * WritableUtils.getVIntSize(EOF_MARKER))));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, went through it one more time. Actually cacheSize itself is not needed. We can fix this with totalSize and cacheStream.getLimit(). I will fix this in next commit.

if (outputPath == null) {
outputPath = taskOutput.getOutputFileForWrite();
}
LOG.info("Creating file " + outputPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Add "Switching from mem stream to disk stream" to log message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix this in next commit.

outputPath = taskOutput.getOutputFileForWrite();
}
LOG.info("Creating file " + outputPath);
FSDataOutputStream newRawOut = fs.create(outputPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this is identical to what is done in the IFile constructor. Think it makes sense to break this out into a separate method, and re-use it, instead of repeating the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, makes sense to create setupOutputStream() in IFile itself.

*/
public byte[] getData() {
if (!isDataFlushedToDisk()) {
byte[] buf = new byte[cacheStream.size()];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Not sure if this really matters. Could avoid this copy by wrapping in a ByteBuffer (another copy is happening anyway when serializing to protobuf)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix this in next commit.

@rbalamohan
Copy link
Contributor Author

Fixed review comments in recent commit.

Copy link
Contributor

@sidseth sidseth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@rbalamohan rbalamohan merged commit 3dce6c9 into apache:master Oct 11, 2019
@rbalamohan
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants