Skip to content
This repository was archived by the owner on Jul 27, 2022. It is now read-only.

feat: Implement copy and rename - #14

Merged
kodiakhq[bot] merged 11 commits into
influxdata:mainfrom
wjones127:rename-no-replace
Jun 4, 2022
Merged

kodiakhq[bot] merged 11 commits into
influxdata:mainfrom
wjones127:rename-no-replace

Conversation

@wjones127

@wjones127 wjones127 commented May 21, 2022 •

Copy link
Copy Markdown
Contributor

Based on discussion in #10, we may wish to do this instead of #11.

Adds three new methods to the ObjectStore trait:

  • copy(from, to)
  • rename(from, to) (with default implementation)
  • rename_no_replace(from, to)

This doesn't implement them for all stores, but here is what I have done:

  • Local
    • copy()
    • rename()
    • rename_no_replace() (Added better Windows support)
  • In-memory + Throttled
    • copy()
    • rename()
    • rename_no_replace()
  • AWS
    • copy()
    • rename() (default copy and then delete)
    • rename_no_replace() (will need to use dynamodb-lock)
  • Azure - Maybe @roeap wants to tackle this?
    • copy()
    • rename()
    • rename_no_replace()
  • GCP
    • copy()
    • rename() (default copy and then delete)
    • rename_no_replace() (GCS supports this, but need to add precondition support to cloud-storage-rs)

@wjones127
wjones127 force-pushed the rename-no-replace branch 2 times, most recently from db729c2 to 4c097b8 Compare May 22, 2022 22:56
@wjones127 wjones127 changed the title Implement copy and rename feat: Implement copy and rename May 22, 2022
@roeap

roeap commented May 26, 2022 •

Copy link
Copy Markdown
Contributor

@wjones127 - I'd be happy to pick up Azure support.

@wjones127
wjones127 force-pushed the rename-no-replace branch from 4c097b8 to bb0b0c0 Compare May 30, 2022 23:44
@wjones127
wjones127 marked this pull request as ready for review May 30, 2022 23:45
Comment thread src/local.rs Outdated
}
}

#[cfg(windows)]

@tustvold tustvold Jun 2, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if we could use https://doc.rust-lang.org/std/fs/fn.hard_link.html instead? I think this should be atomic on all sane platforms, and avoids a lot of non-trivial code? This would have the obvious caveat that it wouldn't allow cross-filesystem copies, but I'm inclined to think that doesn't really matter...

Edit: In fact the renameat function used below will error with EXDEV if used across mount points anyway, so this caveat doesn't apply

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll try that.

Comment thread src/aws.rs Outdated
Ok(())
}

async fn rename_no_replace(&self, _source: &Path, _dest: &Path) -> Result<()> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As mentioned below, I wonder if rather than a rename_no_replace, which no object stores actually support, if copy_if_not_exists would be sufficient?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah that makes sense. copy_if_not_exist is sufficient for delta-rs.

@wjones127
wjones127 force-pushed the rename-no-replace branch from bb0b0c0 to 28d4ae9 Compare June 2, 2022 23:26
@wjones127
wjones127 force-pushed the rename-no-replace branch from 28d4ae9 to 16f0c0c Compare June 2, 2022 23:27

@tustvold tustvold left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is stellar work, I left some minor suggestions, e.g. moving todo!() to return NotImplemented errors, but otherwise this looks good to go 😄

Comment thread src/azure.rs Outdated
Comment thread src/local.rs Outdated
Comment thread src/throttle.rs Outdated
Comment thread src/throttle.rs Outdated
@roeap

roeap commented Jun 3, 2022

Copy link
Copy Markdown
Contributor

I have a draft ready for the azure support. Once this gets merged, I'll rebase and open a new PR.

@tustvold tustvold added kodiak: merge.method = 'squash' Instruct kodiak to perform a squash merge and removed kodiak: merge.method = 'squash' Instruct kodiak to perform a squash merge labels Jun 3, 2022
@tustvold

tustvold commented Jun 3, 2022

Copy link
Copy Markdown
Contributor

Hmm... I think CI should kick in if you push another commit, e.g. merge master

@tustvold tustvold left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks great, if you could please sign the CLA, I can get this in 😄

@wjones127

Copy link
Copy Markdown
Contributor Author

@tustvold I've signed the CLA 👍

@tustvold tustvold added kodiak: merge.method = 'squash' Instruct kodiak to perform a squash merge automerge Put in the merge queue labels Jun 4, 2022
@kodiakhq
kodiakhq Bot merged commit febf83e into influxdata:main Jun 4, 2022
@tustvold

tustvold commented Jun 4, 2022

Copy link
Copy Markdown
Contributor

Thanks again 🎉

@wjones127
wjones127 deleted the rename-no-replace branch June 4, 2022 17:45
@tustvold tustvold mentioned this pull request Jun 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

automerge Put in the merge queue kodiak: merge.method = 'squash' Instruct kodiak to perform a squash merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants