Skip to main content

MemoryMappedCsvReader

Struct MemoryMappedCsvReader 

Source
pub struct MemoryMappedCsvReader { /* private fields */ }
Expand description

Memory-mapped CSV reader for efficient processing of large files.

Implementations§

Source§

impl MemoryMappedCsvReader

Source

pub fn new(path: &Path) -> Result<Self>

Source

pub fn new_with_tracker( path: &Path, memory_tracker: MemoryTracker, ) -> Result<Self>

Source

pub fn file_size(&self) -> u64

Get file size in bytes.

Source

pub fn read_chunk( &self, offset: u64, chunk_size: usize, ) -> Result<(Vec<String>, usize)>

Read a chunk of the file starting at the given byte offset.

Returns (lines, actual_bytes_consumed) where actual_bytes_consumed accounts for line-boundary trimming and may be less than chunk_size.

Source

pub fn read_csv_chunk( &self, offset: u64, chunk_size: usize, has_headers: bool, csv_config: Option<&CsvParserConfig>, ) -> Result<(Option<StringRecord>, Vec<StringRecord>, usize)>

Parse CSV records from memory-mapped data in chunks.

Returns (headers, records, actual_bytes_consumed).

Source

pub fn ends_inside_quotes( &self, offset: u64, csv_config: Option<&CsvParserConfig>, ) -> bool

Whether the file ends inside a quoted field, scanning from offset on.

offset must be a record boundary, such as the offset of a chunk Self::read_csv_chunk returned. Passing the last chunk’s offset keeps the scan to that chunk. The CSV parser accepts a quote that is never closed as a field running to the end of the file, so this is the only sign of it.

Source

pub fn estimate_row_count(&self) -> Result<usize>

Estimate the number of logical CSV records using the default parser configuration.

Retained as the backwards-compatible form of Self::estimate_csv_record_count.

Source

pub fn estimate_csv_record_count( &self, csv_config: Option<&CsvParserConfig>, ) -> Result<usize>

Estimate the number of logical CSV records in the file by sampling.

The sample uses Self::read_csv_chunk, so quoted multiline fields, CR/LF/CRLF terminators, delimiters, and blank-record handling match the records that incremental profiling will actually consume.

Source

pub fn check_memory_leaks(&self) -> String

Check for memory leaks in the memory tracker.

Source

pub fn get_memory_stats(&self) -> (usize, usize, usize)

Get memory usage statistics.

Trait Implementations§

Source§

impl Drop for MemoryMappedCsvReader

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V