You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "yahoNanJing (via GitHub)" <gi...@apache.org> on 2023/03/10 09:43:01 UTC
[GitHub] [arrow-rs] yahoNanJing opened a new pull request, #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
yahoNanJing opened a new pull request, #3839:
URL: https://github.com/apache/arrow-rs/pull/3839
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Closes #3838.
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!---
If there are any breaking changes to public APIs, please add the `breaking change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1480775873
I'm having a somewhat hard time understanding the code you've linked but please bear with me:
`CachedBasedObjectStoreRegistry`:
* Creates a `FileCacheObjectStore` combining a normal `ObjectStore` with a `FileCacheLayer`,
* Computes a cache key from the URL
* Creates a `ObjectStoreWithKey` to extend the `FileCacheObjectStore` with this key to wrap this construction
Calling get on this object store then:
* Calls through `ObjectStoreWithKey` to `FileCacheObjectStore`
* Looks up the value in the cache, passing the inner store as the `GetExtra` argument
* This propagates through to `FileCacheLoader::load`
* Which then calls `CacheMedium::get_mapping_location`
* Which finally calls through to `get_key` which attempts to downcast the provided `ObjectStore` to `ObjectStoreWithKey`
* This will always fail as the `ObjectStoreWithKey` is decorating the `FileCacheObjectStore` not the other way round
A simple fix might be to swap the decoration order, but taking a step back, I don't see the need for `ObjectStoreWithKey`. The cache key is known at the time `FileCacheObjectStore` is constructed by `CachedBasedObjectStoreRegistry`. I don't see a reason to not just store this key inside the `FileCacheObjectStore` and pass it along with the inner `ObjectStore` as the `GetExtra` argument to the cache. This would not only be simpler (and work) but would also avoid any need for downcasting?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] alamb commented on a diff in pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#discussion_r1133074897
##########
object_store/src/aws/mod.rs:
##########
@@ -169,6 +170,10 @@ impl std::fmt::Display for AmazonS3 {
#[async_trait]
impl ObjectStore for AmazonS3 {
+ fn as_any(&self) -> &dyn Any {
Review Comment:
👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] yahoNanJing commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "yahoNanJing (via GitHub)" <gi...@apache.org>.
yahoNanJing commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1480973508
Thanks @tustvold for reading the proto branch for cache layer. The process details you described above are exactly correct.
> However, it doesn't work as expected
I'm sorry I didn't explain it very clearly. Actually the process works well. The only expected thing is the function `get_key` in https://github.com/yahoNanJing/arrow-ballista/blob/dev-20230322/ballista/core/src/cache_layer/object_store/mod.rs#L31-L39. It seems it will always return "none". The unit test https://github.com/yahoNanJing/arrow-ballista/blob/dev-20230322/ballista/core/src/cache_layer/object_store/mod.rs#L169-L173 verifies that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] yahoNanJing commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "yahoNanJing (via GitHub)" <gi...@apache.org>.
yahoNanJing commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1466151086
> How would this work if there are say two different S3 buckets registered?
I don't know whether it's common for a cluster to access several S3 buckets. However, it's a common case for a cluster to access one S3 bucket, one HDFS cluster, or other different kinds of storages.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] alamb commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1470567752
Is there some reason we should hold off on merging this PR ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] alamb commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1464923448
> I would like to understand the use-case more before merging this,
I wonder if it is something like flushing the cache, or being able to take some different action if the item is not in the cache 🤔
> I'm not a massive fan of breaking encapsulation in this way, it undermines the decorator pattern, and would rather avoid making a breaking change if possible
I agree finding some way to avoid `as_any` might be preferable in most circumstances, but I don't see that as a reason to not add it to `as_any` if that is how the downstream project wants to structure their code.
In other words I see no harm in adding this API as it allows significant flexibility even if it is not a preferred pattern for some projects
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] yahoNanJing commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "yahoNanJing (via GitHub)" <gi...@apache.org>.
yahoNanJing commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1465404294
Thanks @alamb and @tustvold for reviewing this. The main reason for adding `as_any` is to identify different cache path for the corresponding `ObjectStore`. For example, in the https://github.com/apache/arrow-ballista/issues/645, we will introduce a cache layer with a root cache directory. The cache layer will be able to cache data from different `ObjectStore`s. Suppose `ObjectStore` A has a path `p`, while `ObjectStore` B has the same path `p`. Then how to cache them both becomes a problem if we are not able to identify different `ObjectStore`s.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1470570817
> I'll change my current implementation to adjust to it. Maybe we need to add a trait to extend the ObjectStore with providing get_url() method, since it's a datafusion specific concept.
I was waiting based on this feedback, I would rather not merge something, especially a breaking change, without a motivating use-case
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] alamb commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1464895729
There appears to be some CI errors.
I think adding a `as_any` function is probably fine> it would have wider support from older rust versions, and there are many existing examples of doing so
FWIW this seems like either approach is a breaking change (and would require releasing object_store 0.6.0), which is fine, but just something to keep in mind
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1465707677
> Then how to cache them both becomes a problem if we are not able to identify different ObjectStores.
How does as_any fit into this, the underlying stores don't expose or even know that information? I think you need to use the url that is used to register the store with the ObjectStoreRegistry?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] yahoNanJing commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "yahoNanJing (via GitHub)" <gi...@apache.org>.
yahoNanJing commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1465759350
> I think you need to use the url that is used to register the store with the ObjectStoreRegistry as a cache prefix?
If the `ObjectStore` exposes the url, then it would be better so that we can even use a different cache prefix for different `ObjectStore` instances instead of for different `ObjectStore` types. However, it's better not to expose the url with secrets, especially for S3 or other stores.
At the first stage, I think the cache prefix based on the `ObjectStore` types is enough since the `as_any` method is very common for a trait.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] alamb commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1465938563
Here is a PR in DataFusion that is perhaps related: https://github.com/apache/arrow-datafusion/pull/5543
> That is my point, the URL is a datafusion concept, the stores don't know the URL
So perhaps you are saying the caching should be done at a higher level? Like in `ObjectStoreRegistry` for example?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1487163171
I am going to close this for now, feel free to reopen should the need arise
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1464902004
I would like to understand the use-case more before merging this, I'm not a massive fan of breaking encapsulation in this way, it undermines the decorator pattern, and would rather avoid making a breaking change if possible
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1465870963
> If the object_store exposes the URL
That is my point, the URL is a datafusion concept, the stores don't know the URL
> cache prefix based on store types
How would this work if there are say two different S3 buckets registered?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold closed pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold closed pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
URL: https://github.com/apache/arrow-rs/pull/3839
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] yahoNanJing commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "yahoNanJing (via GitHub)" <gi...@apache.org>.
yahoNanJing commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1466179825
> That is my point, the URL is a datafusion concept, the stores don't know the URL
Thanks for pointing this out. Previously I thought the url is a necessary part of the `ObjectStore`. Although it's still very awkward to me not to include the url for `ObjectStore`, I respect your original design.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] yahoNanJing commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "yahoNanJing (via GitHub)" <gi...@apache.org>.
yahoNanJing commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1466182076
> So perhaps you are saying the caching should be done at a higher level? Like in ObjectStoreRegistry for example? Is this something you considered @yahoNanJing ?
Thanks @alamb. I still think it should be at the `ObjectStore` level. I'll change my current implementation to adjust to it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] yahoNanJing commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "yahoNanJing (via GitHub)" <gi...@apache.org>.
yahoNanJing commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1466149385
> How would this work if there are say two different S3 buckets registered?
I don't know whether it's common for a cluster to access several S3 buckets. However, it's a common case for a cluster to access one S3 bucket, one HDFS cluster, or other different kinds of storages.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] yahoNanJing commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "yahoNanJing (via GitHub)" <gi...@apache.org>.
yahoNanJing commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1480694002
> Now that rust supports trait upcasting you might be able to just make ObjectStore: Any
Hi @tustvold, I'm afraid we still need to add the as_any() interface to the trait. Based on https://github.com/apache/arrow-datafusion/pull/5543, I factored previous code. However, it doesn't work as expected. See the UT fails in https://github.com/yahoNanJing/arrow-ballista/blob/dev-20230322/ballista/core/src/cache_layer/object_store/mod.rs
Or maybe there are other correct way to downcast an `Arc<dyn ObjectStore>`. https://github.com/yahoNanJing/arrow-ballista/blob/dev-20230322/ballista/core/src/cache_layer/object_store/mod.rs?plain=1#L31-L39
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] yahoNanJing commented on pull request #3839: Add as_any() to the ObjectStore to make it able to identify which ObjectStore is using for the related trait object
Posted by "yahoNanJing (via GitHub)" <gi...@apache.org>.
yahoNanJing commented on PR #3839:
URL: https://github.com/apache/arrow-rs/pull/3839#issuecomment-1481063507
> Calling get on this object store then:
Calls through ObjectStoreWithKey to FileCacheObjectStore
Looks up the value in the cache, passing the inner store as the GetExtra argument
This propagates through to FileCacheLoader::load
Which then calls CacheMedium::get_mapping_location
Which finally calls through to get_key which attempts to downcast the provided ObjectStore to ObjectStoreWithKey
This will always fail as the ObjectStoreWithKey is decorating the FileCacheObjectStore not the other way round
Thanks @tustvold for providing this genius idea. It works now without introducing `as_any` to the `ObjectStore`. Related commit is here. https://github.com/yahoNanJing/arrow-ballista/commit/84a98d73a164b655b80f4391611de4c499b27f73
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org