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

Return BoxStream with 'static lifetime from ObjectStore::list #6619

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kylebarron
Copy link
Contributor

@kylebarron kylebarron commented Oct 23, 2024

To preface: not expecting this to be merged imminently, as it may be a while before object-store's next breaking release, and I figure there may be a cleaner way to change this. But it was useful to learn a bit more about streams, and I'll probably use this patch in my Python-facing object-store bindings.

Which issue does this PR close?

Closes #6587.

Rationale for this change

Easier wrapping of ObjectStore::list in bindings, e.g. to Python, that don't allow lifetime references.

What changes are included in this PR?

Change the return type of ObjectStore::list and ObjectStore::list_with_offset to

BoxStream<'static, Result<ObjectMeta>>

Are there any user-facing changes?

Yes.

@github-actions github-actions bot added the object-store Object Store Interface label Oct 23, 2024
@kylebarron
Copy link
Contributor Author

kylebarron commented Oct 23, 2024

In developmentseed/obstore#35 I verified that this does enable streaming list in Python bindings:

Screen.Recording.2024-10-23.at.12.25.19.PM.mov

@tustvold tustvold added api-change Changes to the arrow API next-major-release the PR has API changes and it waiting on the next major version labels Oct 23, 2024
@alamb alamb requested a review from tustvold November 7, 2024 22:46
@alamb
Copy link
Contributor

alamb commented Nov 7, 2024

Looks like @tustvold had a conversation on #6587 so I defer to him. However, I had a quick look at the code and it looks pretty good to me. Thank you @kylebarron

@@ -44,37 +44,38 @@ pub(crate) trait ListClientExt {
prefix: Option<&Path>,
delimiter: bool,
offset: Option<&Path>,
) -> BoxStream<'_, Result<ListResult>>;
) -> BoxStream<'static, Result<ListResult>>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the implications of this stream having static lifetime? I don't understand the implications on downstream crates

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my use case, Python bindings with pyo3 don't allow you to have any lifetime parameters shorter than 'static: https://pyo3.rs/v0.22.5/class.html#no-lifetime-parameters

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right -- I guess I am wondering does this effectively mean that the returned streams can't be borrowed (aka they effectively have to be Arc'd or something like that where the stream is owned 🤔 )

Basically I am trying to think about what usecases, if any, that this additional constrait would be break (I realize some people may need to update the type signatures, I am thinking of more fundamental changes)

One thing maybe we could do is try to update DataFusion (and our internal INfluxDB code) with this change and see what, if anything, breaks for us 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would only effect implementers of the trait, its a stronger contract on what the implementation chooses to return. The result is consumers of object_store shouldn't notice much

@tustvold
Copy link
Contributor

tustvold commented Nov 8, 2024

This change makes sense to me, and is definitely something we should consider when looking to make a breaking releas. However, I think we want to get a few more such changes lined up before taking the plunge, object_store breaking changes are quite disruptive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-change Changes to the arrow API next-major-release the PR has API changes and it waiting on the next major version object-store Object Store Interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use 'static lifetime in BoxFuture for all object-store APIs
3 participants