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

[Docs][HTTP] Clarify when to use batch-at-a-time vs. one-shot approach for receiving data #40613

Open
Tracked by #40465
ianmcook opened this issue Mar 17, 2024 · 1 comment
Labels

Comments

@ianmcook
Copy link
Member

ianmcook commented Mar 17, 2024

Describe the usage question you have. Please include as many useful details as possible.

Among the simple HTTP GET client examples in arrow-experiments/http/get_simple:

  • Some iterate over the record batches as they stream in from the server (i.e. "streaming" approach).
  • Some just make a single function call that collects the full data (i.e. "one-shot" approach).

For example:

  • The Python client example shows how to iterate over the batches calling reader.read_next_batch(), whereas it could have just called reader.read_all() which would be simpler.
  • The Ruby client example goes for the simpler all-at-once approach, whereas it could have used a batch-at-a-time approach like in this example.

For many use cases, it makes no difference which approach is used, and we should just prioritize whatever is syntactically simplest.

But for some use cases, the batch-at-a-time approach will be preferred or needed for specific reasons, such as:

  • The receiver wants to start processing batches before the final batch is received.
  • The receiver wants to stream the received data to a sink without accumulating it in memory.

We should clarify this in the Arrow-over-HTTP conventions doc, and wherever possible we should provide examples showing both approaches.

Component(s)

Documentation

@felipecrv
Copy link
Contributor

It depends on what the client is going to do with the data. I think showing that data can be loaded batch by batch is more interesting. It's a streaming protocol after all.

A client performing some kind of aggregation can go through the batches updating its state and finalizing when all batches are read (e.g. calculating some weighted average on the stream).

People naturally tend to write code that buffers everything, so having the examples showing that batch-by-batch is possible only helps.

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

No branches or pull requests

2 participants