Path: blob/main/crates/polars-parquet/src/parquet/mod.rs
6940 views
#[macro_use]1pub mod error;2#[cfg(feature = "bloom_filter")]3pub mod bloom_filter;4pub mod compression;5pub mod encoding;6pub mod metadata;7pub mod page;8mod parquet_bridge;9pub mod read;10pub mod schema;11pub mod statistics;12pub mod types;13pub mod write;1415use std::ops::Deref;1617use polars_parquet_format as thrift_format;18use polars_utils::mmap::MemSlice;19pub use streaming_decompression::{FallibleStreamingIterator, fallible_streaming_iterator};2021pub const HEADER_SIZE: u64 = PARQUET_MAGIC.len() as u64;22pub const FOOTER_SIZE: u64 = 8;23pub const PARQUET_MAGIC: [u8; 4] = [b'P', b'A', b'R', b'1'];2425/// The number of bytes read at the end of the parquet file on first read26const DEFAULT_FOOTER_READ_SIZE: u64 = 64 * 1024;2728/// A copy-on-write buffer over bytes29#[derive(Debug, Clone)]30pub enum CowBuffer {31Borrowed(MemSlice),32Owned(Vec<u8>),33}3435impl Deref for CowBuffer {36type Target = [u8];3738#[inline(always)]39fn deref(&self) -> &Self::Target {40match self {41CowBuffer::Borrowed(v) => v.deref(),42CowBuffer::Owned(v) => v.deref(),43}44}45}4647impl CowBuffer {48pub fn to_mut(&mut self) -> &mut Vec<u8> {49match self {50CowBuffer::Borrowed(v) => {51*self = Self::Owned(v.clone().to_vec());52self.to_mut()53},54CowBuffer::Owned(v) => v,55}56}5758pub fn into_vec(self) -> Vec<u8> {59match self {60CowBuffer::Borrowed(v) => v.to_vec(),61CowBuffer::Owned(v) => v,62}63}64}656667