From 0f5398c4b949c0d3977f5b9553e8783d4426b72b Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 26 Jul 2021 16:21:23 -0400 Subject: [PATCH] refactor: Store first/last write on DbChunk snapshots --- server/src/db/chunk.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/server/src/db/chunk.rs b/server/src/db/chunk.rs index 22ffd15799..1ec2d62684 100644 --- a/server/src/db/chunk.rs +++ b/server/src/db/chunk.rs @@ -82,6 +82,8 @@ pub struct DbChunk { access_recorder: AccessRecorder, state: State, meta: Arc, + time_of_first_write: DateTime, + time_of_last_write: DateTime, } #[derive(Debug)] @@ -159,6 +161,8 @@ impl DbChunk { access_recorder: chunk.access_recorder().clone(), state, 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, state, 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 { - match &self.state { - 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, - } + self.time_of_first_write } pub fn time_of_last_write(&self) -> DateTime { - match &self.state { - 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, - } + self.time_of_last_write } }