Skip to content

Commit 5a164c0

Browse files
committed
fix: Use proper IPC file format.
1 parent 80d6fcd commit 5a164c0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/encode/encode-ipc.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ export function encodeIPC(data, { sink, format = STREAM } = {}) {
3030

3131
if (file) {
3232
builder.addBuffer(MAGIC);
33-
} else if (schema) {
33+
}
34+
35+
// both stream and file start with the schema
36+
if (schema) {
3437
writeMessage(
3538
builder,
3639
MessageHeader.Schema,
@@ -39,6 +42,7 @@ export function encodeIPC(data, { sink, format = STREAM } = {}) {
3942
);
4043
}
4144

45+
// write dictionary messages
4246
for (const dict of dictionaries) {
4347
const { data } = dict;
4448
writeMessage(
@@ -51,6 +55,7 @@ export function encodeIPC(data, { sink, format = STREAM } = {}) {
5155
writeBuffers(builder, data.buffers);
5256
}
5357

58+
// write record batch messages
5459
for (const batch of records) {
5560
writeMessage(
5661
builder,
@@ -62,10 +67,11 @@ export function encodeIPC(data, { sink, format = STREAM } = {}) {
6267
writeBuffers(builder, batch.buffers);
6368
}
6469

70+
// both stream and file include end-of-stream message
71+
builder.addBuffer(EOS);
72+
6573
if (file) {
6674
writeFooter(builder, schema, dictBlocks, recordBlocks, metadata);
67-
} else {
68-
builder.addBuffer(EOS);
6975
}
7076

7177
return builder.sink;

0 commit comments

Comments
 (0)