Skip to content
Closed
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 @@ -127,7 +127,7 @@ private void testEchoServer(int serverPort,
}
Assert.assertFalse(reader.loadNextBatch());
assertEquals(0, reader.getVectorSchemaRoot().getRowCount());
assertEquals(reader.bytesRead() + 4, writer.bytesWritten());
assertEquals(reader.bytesRead(), writer.bytesWritten());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.arrow.vector.ipc.message.ArrowFooter;
import org.apache.arrow.vector.ipc.message.ArrowRecordBatch;
import org.apache.arrow.vector.ipc.message.IpcOption;
import org.apache.arrow.vector.ipc.message.MessageSerializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -74,11 +75,10 @@ protected ArrowBlock writeRecordBatch(ArrowRecordBatch batch) throws IOException

@Override
protected void endInternal(WriteChannel out) throws IOException {
if (option.write_legacy_ipc_format) {
out.writeIntLittleEndian(0);
} else {
out.writeLongLittleEndian(0);
if (!option.write_legacy_ipc_format) {
out.writeIntLittleEndian(MessageSerializer.IPC_CONTINUATION_TOKEN);
}
out.writeIntLittleEndian(0);

long footerStart = out.getCurrentPosition();
out.write(new ArrowFooter(schema, dictionaryBlocks, recordBlocks), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.arrow.vector.VectorSchemaRoot;
import org.apache.arrow.vector.dictionary.DictionaryProvider;
import org.apache.arrow.vector.ipc.message.IpcOption;
import org.apache.arrow.vector.ipc.message.MessageSerializer;

/**
* Writer for the Arrow stream format to send ArrowRecordBatches over a WriteChannel.
Expand Down Expand Up @@ -68,18 +69,18 @@ public ArrowStreamWriter(VectorSchemaRoot root, DictionaryProvider provider, Wri
* Write an EOS identifier to the WriteChannel.
*
* @param out Open WriteChannel with an active Arrow stream.
* @param option IPC write option
* @throws IOException on error
*/
public void writeEndOfStream(WriteChannel out) throws IOException {
if (option.write_legacy_ipc_format) {
out.writeIntLittleEndian(0);
} else {
out.writeLongLittleEndian(0);
public static void writeEndOfStream(WriteChannel out, IpcOption option) throws IOException {
Copy link
Member Author

Choose a reason for hiding this comment

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

if (!option.write_legacy_ipc_format) {
out.writeIntLittleEndian(MessageSerializer.IPC_CONTINUATION_TOKEN);
Copy link
Contributor

Choose a reason for hiding this comment

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

Also apply this change to ArrowFileWriter#endInternal and probably remove MessageSerializer#writeLongLitterEndian since it’s no use anymore?

Copy link
Member Author

@BryanCutler BryanCutler Sep 11, 2019

Choose a reason for hiding this comment

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

good catch, I forgot that also writes EOS. done.

}
out.writeIntLittleEndian(0);
}

@Override
protected void endInternal(WriteChannel out) throws IOException {
writeEndOfStream(out);
writeEndOfStream(out, option);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,6 @@ public long writeIntLittleEndian(int v) throws IOException {
return write(outBuffer);
}

/**
* Writes <code>v</code> in little-endian format to the underlying channel.
*/
public long writeLongLittleEndian(long v) throws IOException {
byte[] outBuffer = new byte[8];
MessageSerializer.longToBytes(v, outBuffer);
return write(outBuffer);
}

/**
* Writes the buffer to the underlying channel.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,6 @@ public void pipeTest() throws IOException, InterruptedException {
writer.join();

assertEquals(NUM_BATCHES, reader.getBatchesRead());
assertEquals(writer.bytesWritten(), reader.bytesRead() + 4);
assertEquals(writer.bytesWritten(), reader.bytesRead());
}
}