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

Streamed PBF reads #47

Open
brad-richardson opened this issue Aug 23, 2024 · 1 comment
Open

Streamed PBF reads #47

brad-richardson opened this issue Aug 23, 2024 · 1 comment

Comments

@brad-richardson
Copy link

I'm looking at adding support for streamed PBF reads from network sources (in my case, from S3). My current plan is to wrap a bytestream produced by object_store into something like an AsyncBlobReader. Are streamed reads something you'd be interested in for this library? If so, do you have any suggestions for implementation?

I did consider using something like mountpoint-s3 instead, but unfortunately I'm working in a managed container environment that doesn't support FUSE mountpoints so I'll need to manage the reads myself.

P.S. Thanks for the library, been using it with good results in a little PBF transcoder.

@b-r-u
Copy link
Owner

b-r-u commented Aug 31, 2024

A streaming reader sounds great. Do you think it would be possible to implement the needed functionality in this crate without adding a big dependency? Maybe it can also be done as an optional dependency or there are just some missing low-level pieces that can be added to the public interface, so that the AsyncBlobReader can be implemented in another crate.

I am not very familiar with the async ecosystem but it looks like you would need to collect the bytes of a stream until you get a full Blob (at most 32 MB in size). Here is the relevant function for that:

fn next(&mut self) -> Option<Self::Item> {

It reads a u32 header size and then reads the BlobHeader which includes the size of the following Blob.
I hope this helps!

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

2 participants