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

Example code for a simple node stream + buffer #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,30 @@ avoid leaking file descriptors.
await reader.close();
```

### Using Streams

Instead of using a file, a writeable stream can consume the parquet output. The stream needs a `close` method defined which is called when the parquetWriter is closed. To write to a `Buffer`, add it as part of the stream.

```js
let stream = require('stream');

let writeableStream = new stream.Writable();
let buffer = Buffer.from('');

writeableStream._write = (chunk, encoding, done) => {
buffer = Buffer.concat([buffer, chunk]);
done();
};
writeableStream.close = e => e(); // pass in an error if there was one

let parquetWriter = await parquet.ParquetWriter.openStream(schema, writeableStream);

parquetWriter.appendRow(<row>)
parquetWriter.close()

buffer // contains all appended rows in parquet format
```

Encodings
---------

Expand Down