-
Notifications
You must be signed in to change notification settings - Fork 869
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
Make InMemory object store track last modified time for each entry #3796
Conversation
4ebc9bb
to
7fd6fb1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd argue that the copy
/copy_if_not_exists
methods should also alter the last modified timestamps if we're going to emulate local FS behavior:
$ touch test
$ date -r test
Fri Mar 3 09:32:25 CET 2023
$ cp test test_cp
$ date -r test_cp
Fri Mar 3 09:33:50 CET 2023
That said, rename
also uses copy
(and likewise for rename_if_not_exists
), but it probably shouldn't affect the timestamp:
$ mv test test_mv
$ date -r test_mv
Fri Mar 3 09:32:25 CET 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be returning this timestamp as the last_modified when we return ObjectMeta, and possibly verify that we are setting it consistently in all the mutating methods (such as copy)
object_store/src/memory.rs
Outdated
@@ -273,22 +278,23 @@ impl InMemory { | |||
} | |||
} | |||
|
|||
async fn get_bytes(&self, location: &Path) -> Result<Bytes> { | |||
async fn get_bytes(&self, location: &Path) -> Result<(Bytes, DateTime<Utc>)> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async fn get_bytes(&self, location: &Path) -> Result<(Bytes, DateTime<Utc>)> { | |
async fn entry(&self, location: &Path) -> Result<(Bytes, DateTime<Utc>)> { |
object_store/src/memory.rs
Outdated
@@ -33,6 +33,8 @@ use std::sync::Arc; | |||
use std::task::Poll; | |||
use tokio::io::AsyncWrite; | |||
|
|||
type StorageType = Arc<RwLock<BTreeMap<Path, (Bytes, DateTime<Utc>)>>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type StorageType = Arc<RwLock<BTreeMap<Path, (Bytes, DateTime<Utc>)>>>; | |
type Entry = (Bytes, DateTime<Utc>); | |
type StorageType = Arc<RwLock<BTreeMap<Path, Entry>>>; |
object_store/src/memory.rs
Outdated
@@ -150,7 +155,7 @@ impl ObjectStore for InMemory { | |||
Ok(ObjectMeta { | |||
location: location.clone(), | |||
last_modified, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should return the timestamp from the entry?
object_store/src/memory.rs
Outdated
@@ -181,7 +186,7 @@ impl ObjectStore for InMemory { | |||
Ok(ObjectMeta { | |||
location: key.clone(), | |||
last_modified, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be the value from the entry?
object_store/src/memory.rs
Outdated
@@ -225,7 +230,7 @@ impl ObjectStore for InMemory { | |||
let object = ObjectMeta { | |||
location: k.clone(), | |||
last_modified, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here
7fd6fb1
to
c11ec79
Compare
object_store/src/memory.rs
Outdated
@@ -273,22 +275,23 @@ impl InMemory { | |||
} | |||
} | |||
|
|||
async fn get_bytes(&self, location: &Path) -> Result<Bytes> { | |||
async fn enty(&self, location: &Path) -> Result<(Bytes, DateTime<Utc>)> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async fn enty(&self, location: &Path) -> Result<(Bytes, DateTime<Utc>)> { | |
async fn entry(&self, location: &Path) -> Result<(Bytes, DateTime<Utc>)> { |
c11ec79
to
697a504
Compare
@@ -238,13 +240,13 @@ impl ObjectStore for InMemory { | |||
} | |||
|
|||
async fn copy(&self, from: &Path, to: &Path) -> Result<()> { | |||
let data = self.get_bytes(from).await?; | |||
let data = self.entry(from).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should probably generate a new last modified timestamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like this self.storage.write().insert(to.clone(), (data.0, Utc::now()));
?
self.storage.write().insert(to.clone(), data); | ||
Ok(()) | ||
} | ||
|
||
async fn copy_if_not_exists(&self, from: &Path, to: &Path) -> Result<()> { | ||
let data = self.get_bytes(from).await?; | ||
let data = self.entry(from).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here
aaaf49a
to
3f6a920
Compare
Thanks again |
Benchmark runs are scheduled for baseline = 6cd0917 and contender = 79518cf. 79518cf is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Which issue does this PR close?
Closes #3782
Rationale for this change
Explain in #3782
What changes are included in this PR?
In
struct InMemoryUpload
, it can store btye with timestampAre there any user-facing changes?