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

object_store: Implement ObjectStore for Arc #4502

Merged
merged 3 commits into from
Jul 10, 2023
Merged

Conversation

Turbo87
Copy link
Contributor

@Turbo87 Turbo87 commented Jul 10, 2023

Which issue does this PR close?

Addresses #4497 (comment)

Rationale for this change

In some situations it can be useful to have multiple instances of e.g. the InMemory store, sharing the same backing data. This can be achieved by putting the store in an Arc, but until now the ObjectStore trait was only implemented for the Box struct.

What changes are included in this PR?

This PR changes the ObjectStore for Box implementation to be generic over anything that implements AsRef<dyn ObjectStore> which covers Box and Arc, and potentially any user-implemented wrappers.

Are there any user-facing changes?

This could potentially be a breaking change for users that have an ObjectStore implementation on a custom struct which also implements AsRef since the compiler might now see two conflicting implementations.

/cc @tustvold

@github-actions github-actions bot added the object-store Object Store Interface label Jul 10, 2023
@Turbo87 Turbo87 changed the title Arcs object_store: Implement ObjectStore for Arc Jul 10, 2023
@@ -527,7 +527,10 @@ pub trait ObjectStore: std::fmt::Display + Send + Sync + Debug + 'static {
}

#[async_trait]
impl ObjectStore for Box<dyn ObjectStore> {
impl<T> ObjectStore for T
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of using a macro instead of a generic. As Rust lacks specialization support blanket implementations such as this have an annoying habit of causing annoying conflicts down the line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess that would avoid the potential conflicts with the tradeoff of not working for custom object store wrapper implementations. Let me know which way you prefer :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I would prefer the macro approach, less chance of unintended consequences

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done 👍

@tustvold tustvold merged commit 8da2f97 into apache:master Jul 10, 2023
12 checks passed
@Turbo87 Turbo87 deleted the arcs branch July 10, 2023 19:00
Turbo87 added a commit to Turbo87/crates.io that referenced this pull request Jul 11, 2023
This can be removed once apache/arrow-rs#4502 is released.
Turbo87 added a commit to Turbo87/crates.io that referenced this pull request Jul 11, 2023
This can be removed once apache/arrow-rs#4502 is released.
Turbo87 added a commit to Turbo87/crates.io that referenced this pull request Jul 11, 2023
This can be removed once apache/arrow-rs#4502 is released.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
object-store Object Store Interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants