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

Implement a streaming API, and read input lazily #15

Open
richkadel opened this issue Apr 7, 2021 · 0 comments
Open

Implement a streaming API, and read input lazily #15

richkadel opened this issue Apr 7, 2021 · 0 comments

Comments

@richkadel
Copy link
Collaborator

Depending on the formatter configuration, some nested levels will not be streamable, but for any layer that does not reorder its elements, that layer can be streamed.

In particular, the top level ParsedDocument is represented as an outermost Array, most commonly consisting of Object-typed elements, which are typically not reordered.

In a fairly common scenario, some very large documents are large because they contain 100s or 1000s of top-level objects, but any individual object is more than likely of a much more manageable size. With streaming, we should be able to format each object as its parsed, which will be much better for large documents than the current implementation that requires reading the entire document into memory before formatting.

Only read from the input to the parser as needed (lazily) as the formatter completes formatting the previously streamed content. (This is sometimes referred to as "backpressure" provided by the formatter, to limit the flow of input from the parser.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant