harmos_storage/writes/
decoded.rs1use super::DataBatch;
22use crate::arrow::ArrowBatch;
23use crate::{MemorySize, Result};
24
25pub struct DecodedBatch {
35 pub destination: crate::Identifier,
36 pub schema: crate::storage::SchemaKey,
37 pub data: ArrowBatch,
38}
39
40impl DecodedBatch {
47 pub fn of(batch: &DataBatch) -> Result<Self> {
48 Ok(Self { data: ArrowBatch::from_ipc(batch.data.bytes())?, destination: batch.destination.clone(), schema: batch.schema.clone() })
49 }
50}
51
52impl MemorySize for DecodedBatch {
53 fn memory_size(&self) -> usize {
54 std::mem::size_of::<Self>()
55 .saturating_add(self.destination.memory_size().saturating_sub(std::mem::size_of_val(&self.destination)))
56 .saturating_add(self.schema.memory_size().saturating_sub(std::mem::size_of_val(&self.schema)))
57 .saturating_add(self.data.memory_size().saturating_sub(std::mem::size_of_val(&self.data)))
58 }
59}
60
61