rdfjs / N3.js

Lightning fast, spec-compatible, streaming RDF for JavaScript
http://rdf.js.org/N3.js/
Other
676 stars 127 forks source link

RDF Stream To Quads: Backpressure / Drain? #320

Closed tobiasschweizer closed 1 year ago

tobiasschweizer commented 1 year ago

Hi @RubenVerborgh

I have a question on reading data from an RDF stream. If this is not the right place for questions, please tell me where to post them.

In the README you write:

This solution is ideal if your consumer is slower, since source data is only read when the consumer is ready.

https://github.com/rdfjs/N3.js#from-an-rdf-stream-to-quads

Does this mean one does not have to worry about backpressure / drain events? All I have to do is to call the done callback from the consumer (implementation of _write, https://nodejs.org/api/stream.html#writablewritechunk-encoding-callback)?

Encoding won't ever be available since chunk is a quad object and not a string, correct?

Thanks and kind regards

RubenVerborgh commented 1 year ago

Hi @tobiasschweizer,

Does this mean one does not have to worry about backpressure / drain events? Exactly—the text you quoted above is basically expanding the term "backpressure".

All I have to do is to call the done callback from the consumer (implementation of _write, https://nodejs.org/api/stream.html#writablewritechunk-encoding-callback)?

That should indeed be enough!

Encoding won't ever be available since chunk is a quad object and not a string, correct?

Correct.

Good luck with your implementation!