From 0c44179aa924c60ea9942579627dfb3f06f6aef6 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 19 Jul 2021 09:38:58 -0400 Subject: [PATCH] feat: Add first/last write time on DbChunk To eventually be used in collect_rub --- server/src/db/chunk.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/server/src/db/chunk.rs b/server/src/db/chunk.rs index b31f9ef9a3..c006ab2ddd 100644 --- a/server/src/db/chunk.rs +++ b/server/src/db/chunk.rs @@ -1,6 +1,7 @@ use super::{ catalog::chunk::ChunkMetadata, pred::to_read_buffer_predicate, streams::ReadFilterResultsStream, }; +use chrono::{DateTime, Utc}; use data_types::partition_metadata; use datafusion::physical_plan::SendableRecordBatchStream; use datafusion_util::MemoryStream; @@ -201,6 +202,20 @@ impl DbChunk { pub fn table_name(&self) -> Arc { Arc::clone(&self.table_name) } + + pub fn time_of_first_write(&self) -> DateTime { + match &self.state { + State::MutableBuffer { chunk } => chunk.table_summary().time_of_first_write, + _ => unimplemented!(), + } + } + + pub fn time_of_last_write(&self) -> DateTime { + match &self.state { + State::MutableBuffer { chunk } => chunk.table_summary().time_of_last_write, + _ => unimplemented!(), + } + } } impl QueryChunk for DbChunk {