Add ObjectStore::put_opts / Conditional Put (#4879) #4984
Add ObjectStore::put_opts / Conditional Put (#4879) #4984tustvold merged 12 commits intoapache:masterfrom
Conversation
object_store/src/lib.rs
Outdated
There was a problem hiding this comment.
This is kind of annoying, but is necessary because GCS doesn't support etag-based preconditions on put, only ifGenerationMatch
deb80bd to
f88574b
Compare
7617bad to
be34993
Compare
| let get_opts = storage.get_opts(&path, options).await.unwrap(); | ||
| let old = get_opts.bytes().await.unwrap(); | ||
| assert_eq!(old, b"foo".as_slice()); | ||
| assert_eq!(old, b"test".as_slice()); |
| if let Some(version) = &options.version { | ||
| request = request.query(&[("generation", version)]); | ||
| } |
| } | ||
| } | ||
|
|
||
| #[derive(serde::Deserialize, Debug)] |
There was a problem hiding this comment.
These are moved to be shared with S3 (as they are the same)
| })?; | ||
| .context(CompleteMultipartRequestSnafu)?; | ||
|
|
||
| let etag = get_etag(result.headers()).context(MetadataSnafu)?; |
There was a problem hiding this comment.
This was a mistake introduced in #4971, this needs to extract the etag from the XML payload
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Deserialize)] |
There was a problem hiding this comment.
These are moved to be shared with GCS
| async fn put(&self, location: &Path, bytes: Bytes) -> Result<PutResult> { | ||
| async fn put_opts(&self, location: &Path, bytes: Bytes, opts: PutOptions) -> Result<PutResult> { | ||
| if opts.mode != PutMode::Overwrite { | ||
| // TODO: Add support for If header - https://datatracker.ietf.org/doc/html/rfc2518#section-9.4 |
There was a problem hiding this comment.
I couldn't actually find an easy to run WebDav implementation that respected this header, I don't have a use-case for this currently so punted on this
| async fn put(&self, location: &Path, bytes: Bytes) -> Result<PutResult> { | ||
| async fn put_opts(&self, location: &Path, bytes: Bytes, opts: PutOptions) -> Result<PutResult> { | ||
| if matches!(opts.mode, PutMode::Update(_)) { | ||
| return Err(crate::Error::NotImplemented); |
There was a problem hiding this comment.
I intend to add support for this as a follow up PR
* Add version to PutResult * Conditional Put (#4879) * Don't support HttpStore * Add R2 Support * Update Azure StatusCode * Fixes * Clippy * Clippy * PutRequestBuilder * Clippy * Add stress test * Clippy
Which issue does this PR close?
Closes apache/arrow-rs-object-store#129
Relates to apache/arrow-rs-object-store#145
Rationale for this change
Allows optimistic concurrency control based transactions against object storage
What changes are included in this PR?
Are there any user-facing changes?