You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by cu...@apache.org on 2018/09/28 22:35:24 UTC
[arrow] branch master updated: ARROW-3281: [Java] Make sure that
WritableByteChannel in WriteChannel writes
This is an automated email from the ASF dual-hosted git repository.
cutlerb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 86497f3 ARROW-3281: [Java] Make sure that WritableByteChannel in WriteChannel writes
86497f3 is described below
commit 86497f37a6feff069995a7f338591635f8cfd02a
Author: Animesh Trivedi <at...@apache.org>
AuthorDate: Fri Sep 28 15:35:15 2018 -0700
ARROW-3281: [Java] Make sure that WritableByteChannel in WriteChannel writes
out complete bytes
Author: Animesh Trivedi <at...@apache.org>
Loop around the write call to make sure that all remaining
bytes in a ByteBuffer is consumed by the write call.
Author: Animesh Trivedi <at...@apache.org>
Closes #2594 from animeshtrivedi/master and squashes the following commits:
bf6c9d6 <Animesh Trivedi> (i) space after while; (ii) typos in the comment
74d2bd5 <Animesh Trivedi> adding a note in the class doc about the write semantics
069f6d4 <Animesh Trivedi> use hasRemaining instead of remaining() > 0 condition check
98dd63b <Animesh Trivedi> ARROW-3281: Make sure that WritableByteChannel in WriteChannel writes out complete bytes
---
.../src/main/java/org/apache/arrow/vector/ipc/WriteChannel.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/java/vector/src/main/java/org/apache/arrow/vector/ipc/WriteChannel.java b/java/vector/src/main/java/org/apache/arrow/vector/ipc/WriteChannel.java
index 7d2315e..c8de08a 100644
--- a/java/vector/src/main/java/org/apache/arrow/vector/ipc/WriteChannel.java
+++ b/java/vector/src/main/java/org/apache/arrow/vector/ipc/WriteChannel.java
@@ -34,6 +34,10 @@ import io.netty.buffer.ArrowBuf;
/**
* Wrapper around a WritableByteChannel that maintains the position as well adding
* some common serialization utilities.
+ *
+ * All write methods in this class follow full write semantics, i.e., write calls
+ * only return after requested data has been fully written. Note this is different
+ * from java WritableByteChannel interface where partial write is allowed
*/
public class WriteChannel implements AutoCloseable {
private static final Logger LOGGER = LoggerFactory.getLogger(WriteChannel.class);
@@ -73,7 +77,9 @@ public class WriteChannel implements AutoCloseable {
public long write(ByteBuffer buffer) throws IOException {
long length = buffer.remaining();
LOGGER.debug("Writing buffer with size: " + length);
- out.write(buffer);
+ while (buffer.hasRemaining()) {
+ out.write(buffer);
+ }
currentPosition += length;
return length;
}