/// Create a DBChunk snapshot of the catalog chunk
Create a DBChunk snapshot of the catalog chunk
Create a DBChunk snapshot of the catalog chunk
pub fn snapshot(chunk: &super::catalog::chunk::Chunk) -> Arc<Self> {
        let partition_key = Arc::from(chunk.key());
        use super::catalog::chunk::{ChunkStage, ChunkStageFrozenRepr};
        let (state, meta) = match chunk.stage() {
            ChunkStage::Open { mb_chunk, .. } => {
                let snapshot = mb_chunk.snapshot();
                let state = State::MutableBuffer {
                    chunk: Arc::clone(&snapshot),
                };
                let meta = ChunkMetadata {
                    table_summary: Arc::new(mb_chunk.table_summary()),
                    schema: snapshot.full_schema(),
                };
                (state, Arc::new(meta))
            }
            ChunkStage::Frozen {
                representation,
                meta,
                ..
            } => {
                let state = match &representation {
                    ChunkStageFrozenRepr::MutableBufferSnapshot(snapshot) => State::MutableBuffer {
                        chunk: Arc::clone(snapshot),
                    },
                    ChunkStageFrozenRepr::ReadBuffer(repr) => State::ReadBuffer {
                        chunk: Arc::clone(repr),
                        partition_key,
                    },
                };
                (state, Arc::clone(&meta))
            }
            ChunkStage::Persisted {
                parquet,
                read_buffer,
                meta,
                ..
            } => {
                let state = if let Some(read_buffer) = &read_buffer {
                    State::ReadBuffer {
                        chunk: Arc::clone(read_buffer),
                        partition_key,
                    }
                } else {
                    State::ParquetFile {
                        chunk: Arc::clone(&parquet),
                    }
                };
                (state, Arc::clone(&meta))
            }
        };
        Arc::new(Self {
            id: chunk.id(),
            table_name: chunk.table_name(),
            state,
            meta,
        })
    }
pub fn snapshot ( chunk : & super :: catalog :: chunk :: Chunk ) -> Arc < Self > { let partition_key = Arc :: from ( chunk . key ( ) ) ; use super :: catalog :: chunk :: { ChunkStage , ChunkStageFrozenRepr } ; let ( state , meta ) = match chunk . stage ( ) { ChunkStage :: Open { mb_chunk , .. } => { let snapshot = mb_chunk . snapshot ( ) ; let state = State :: MutableBuffer { chunk : Arc :: clone ( & snapshot ) , } ; let meta = ChunkMetadata { table_summary : Arc :: new ( mb_chunk . table_summary ( ) ) , schema : snapshot . full_schema ( ) , } ; ( state , Arc :: new ( meta ) ) } ChunkStage :: Frozen { representation , meta , .. } => { let state = match & representation { ChunkStageFrozenRepr :: MutableBufferSnapshot ( snapshot ) => State :: MutableBuffer { chunk : Arc :: clone ( snapshot ) , } , ChunkStageFrozenRepr :: ReadBuffer ( repr ) => State :: ReadBuffer { chunk : Arc :: clone ( repr ) , partition_key , } , } ; ( state , Arc :: clone ( & meta ) ) } ChunkStage :: Persisted { parquet , read_buffer , meta , .. } => { let state = if let Some ( read_buffer ) = & read_buffer { State :: ReadBuffer { chunk : Arc :: clone ( read_buffer ) , partition_key , } } else { State :: ParquetFile { chunk : Arc :: clone ( & parquet ) , } } ; ( state , Arc :: clone ( & meta ) ) } } ; Arc :: new ( Self { id : chunk . id ( ) , table_name : chunk . table_name ( ) , state , meta , } ) }
Create a DBChunk snapshot of the catalog chunk
Create a DBChunk snapshot of the catalog chunk
chunk
&super::catalog::chunk::Chunk