hy00nc commented on a change in pull request #222: [NEMO-350] Implement
Off-heap SerializedMemoryStore & [NEMO-384] Implement
DirectByteBufferInputStream for Off-heap SerializedMemoryStore
URL: https://github.com/apache/incubator-nemo/pull/222#discussion_r296089729
##########
File path:
runtime/executor/src/main/java/org/apache/nemo/runtime/executor/data/block/FileBlock.java
##########
@@ -83,11 +96,13 @@ public FileBlock(final String blockId,
*/
private void writeToFile(final Iterable<SerializedPartition<K>>
serializedPartitions)
throws IOException {
- try (FileOutputStream fileOutputStream = new FileOutputStream(filePath,
true)) {
+ try (FileChannel fileOutputChannel = new FileOutputStream(filePath,
true).getChannel()) {
for (final SerializedPartition<K> serializedPartition :
serializedPartitions) {
// Reserve a partition write and get the metadata.
metadata.writePartitionMetadata(serializedPartition.getKey(),
serializedPartition.getLength());
- fileOutputStream.write(serializedPartition.getData(), 0,
serializedPartition.getLength());
+ for (final ByteBuffer buffer: serializedPartition.getBuffer()) {
+ fileOutputChannel.write(buffer);
Review comment:
The previous implementation using the `DirectByteArrayOutputStream` included
invalid bytes in the `serializedPartition` so we needed to specify the valid
length in the data to only fetch the valid data. Data that is written with
`ByteBuffer`s using `DirectByteArrayOutputStream` has a `limit` which
automatically stops reading the data when it is not valid even without
specifying the length, so we no longer need one.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services