refactor: Store first/last write on DbChunk snapshots

pull/24376/head
Carol (Nichols || Goulding) 2021-07-26 16:21:23 -04:00
parent bc2ec3338f
commit 0f5398c4b9
1 changed files with 8 additions and 10 deletions

View File

@ -82,6 +82,8 @@ pub struct DbChunk {
access_recorder: AccessRecorder, access_recorder: AccessRecorder,
state: State, state: State,
meta: Arc<ChunkMetadata>, meta: Arc<ChunkMetadata>,
time_of_first_write: DateTime<Utc>,
time_of_last_write: DateTime<Utc>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -159,6 +161,8 @@ impl DbChunk {
access_recorder: chunk.access_recorder().clone(), access_recorder: chunk.access_recorder().clone(),
state, state,
meta, meta,
time_of_first_write: chunk.time_of_first_write(),
time_of_last_write: chunk.time_of_last_write(),
}) })
} }
@ -186,6 +190,8 @@ impl DbChunk {
meta, meta,
state, state,
access_recorder: chunk.access_recorder().clone(), access_recorder: chunk.access_recorder().clone(),
time_of_first_write: chunk.time_of_first_write(),
time_of_last_write: chunk.time_of_last_write(),
}) })
} }
@ -204,19 +210,11 @@ impl DbChunk {
} }
pub fn time_of_first_write(&self) -> DateTime<Utc> { pub fn time_of_first_write(&self) -> DateTime<Utc> {
match &self.state { self.time_of_first_write
State::MutableBuffer { chunk } => chunk.table_summary().time_of_first_write,
State::ReadBuffer { chunk, .. } => chunk.table_summary().time_of_first_write,
State::ParquetFile { chunk } => chunk.table_summary().time_of_first_write,
}
} }
pub fn time_of_last_write(&self) -> DateTime<Utc> { pub fn time_of_last_write(&self) -> DateTime<Utc> {
match &self.state { self.time_of_last_write
State::MutableBuffer { chunk } => chunk.table_summary().time_of_last_write,
State::ReadBuffer { chunk, .. } => chunk.table_summary().time_of_last_write,
State::ParquetFile { chunk } => chunk.table_summary().time_of_last_write,
}
} }
} }