Skip to main content

ColumnValueEncoder

Trait ColumnValueEncoder 

Source
pub trait ColumnValueEncoder {
    type T: ParquetValueType;
    type Values: ColumnValues + ?Sized;

Show 16 methods // Required methods fn try_new( descr: &ColumnDescPtr, props: &WriterProperties, column_props: &ResolvedColumnProperties, ) -> Result<Self> where Self: Sized; fn write( &mut self, values: &Self::Values, offset: usize, len: usize, ) -> Result<()>; fn write_gather( &mut self, values: &Self::Values, indices: &[usize], num_values_in_batch: usize, ) -> Result<()>; fn num_values(&self) -> usize; fn has_dictionary(&self) -> bool; fn estimated_memory_size(&self) -> usize; fn estimated_dict_page_size(&self) -> Option<usize>; fn estimated_data_page_size(&self) -> usize; fn flush_dict_page(&mut self) -> Result<Option<DictionaryPage>>; fn flush_data_page(&mut self) -> Result<DataPageValues<Self::T>>; fn flush_bloom_filter(&mut self) -> Option<Sbbf>; fn flush_geospatial_statistics( &mut self, ) -> Option<Box<GeospatialStatistics>>; // Provided methods fn count_values_within_byte_budget( _values: &Self::Values, _offset: usize, _len: usize, _byte_budget: usize, ) -> Option<usize> { ... } fn count_values_within_byte_budget_gather( _values: &Self::Values, _indices: &[usize], _byte_budget: usize, ) -> Option<usize> { ... } fn max_value_bytes(_values: &Self::Values) -> Option<usize> { ... } fn compresses_against_previous_value(&self) -> bool { ... }
}
Expand description

A generic encoder of ColumnValues to data and dictionary pages used by super::GenericColumnWriter

Required Associated Types§

Source

type T: ParquetValueType

The underlying value type of Self::Values

Note: this avoids needing to fully qualify <Self::Values as ColumnValues>::T

Source

type Values: ColumnValues + ?Sized

The values encoded by this encoder

Required Methods§

Source

fn try_new( descr: &ColumnDescPtr, props: &WriterProperties, column_props: &ResolvedColumnProperties, ) -> Result<Self>
where Self: Sized,

Create a new ColumnValueEncoder

column_props holds the settings in props that apply specifically to descr, already resolved by the caller.

Source

fn write( &mut self, values: &Self::Values, offset: usize, len: usize, ) -> Result<()>

Write the corresponding values to this ColumnValueEncoder

Source

fn write_gather( &mut self, values: &Self::Values, indices: &[usize], num_values_in_batch: usize, ) -> Result<()>

Write the values at the indexes in indices to this ColumnValueEncoder

num_values_in_batch is the number of non-null values in the whole write. The column writer may split one write into several calls of this method (for example by write_batch_size or the page size limit), so it can be larger than indices.len(). It is the length of the write’s full index list, which has one entry per non-null value. The byte array encoder uses it to decide whether a dictionary cache pays off.

Source

fn num_values(&self) -> usize

Returns the number of buffered values

Source

fn has_dictionary(&self) -> bool

Returns true if this encoder has a dictionary page

Source

fn estimated_memory_size(&self) -> usize

Returns the estimated total memory usage of the encoder

Source

fn estimated_dict_page_size(&self) -> Option<usize>

Returns an estimate of the encoded size of dictionary page size in bytes, or None if no dictionary

Source

fn estimated_data_page_size(&self) -> usize

Returns an estimate of the encoded data page size in bytes

This should include: <already_written_encoded_byte_size> + <estimated_encoded_size_of_unflushed_bytes>

Source

fn flush_dict_page(&mut self) -> Result<Option<DictionaryPage>>

Flush the dictionary page for this column chunk if any. Any subsequent calls to Self::write will not be dictionary encoded

Note: Self::flush_data_page must be called first, as this will error if there are any pending page values

Source

fn flush_data_page(&mut self) -> Result<DataPageValues<Self::T>>

Flush the next data page for this column chunk

Source

fn flush_bloom_filter(&mut self) -> Option<Sbbf>

Flushes bloom filter if enabled and returns it, otherwise returns None. Subsequent writes will not be tracked by the bloom filter as it is empty since. This should be called once near the end of encoding.

Source

fn flush_geospatial_statistics(&mut self) -> Option<Box<GeospatialStatistics>>

Computes [GeospatialStatistics], if any, and resets internal state such that any internal accumulator is prepared to accumulate statistics for the next column chunk.

Provided Methods§

Source

fn count_values_within_byte_budget( _values: &Self::Values, _offset: usize, _len: usize, _byte_budget: usize, ) -> Option<usize>

Counts how many leading values in values[offset..offset + len] belong in one page of byte_budget bytes.

Returns len if every value fits. Otherwise the result counts the values that fit, and may also count the first value that overflows. The variable-width implementations count that boundary value, so the page-flush check trips on the mini-batch that crosses the budget. The result is at least 1 when a single value alone exceeds the budget. This matches the parquet rule of at least one value per data page.

None means “no cheap estimate available”; the caller stays on the batched fast path and lets the post-write should_add_data_page check handle bounding.

Implementations should short-circuit aggressively: the typical case is “everything fits, return len”, and the next-most-common case is “one wide value, return 1.” The variable-width walk only needs to be precise when the chunk is genuinely near the budget.

Source

fn count_values_within_byte_budget_gather( _values: &Self::Values, _indices: &[usize], _byte_budget: usize, ) -> Option<usize>

As Self::count_values_within_byte_budget but using gather indices rather than a contiguous range. Returns the number of indices that fit, not the maximum index value.

Source

fn max_value_bytes(_values: &Self::Values) -> Option<usize>

Returns an upper bound on the bytes that any one value of values adds to a plain-encoded page, if the encoder knows one without reading the values.

The byte-budget chunker asks once per write call. The bound lets it prove that a run of values fits a page from the length of the run alone.

Source

fn compresses_against_previous_value(&self) -> bool

Returns true if the encoder compresses each value against the value immediately before it, within the current page.

For such encodings a page boundary is not free: flushing discards the previous value, so the first value of the next page is stored in full. GenericColumnWriter::should_add_data_page uses this to exempt a page’s mandatory first value from the data page byte limit.

Per encoding:

  • DELTA_BYTE_ARRAY: true. Each value is stored as the length of the prefix it shares with its predecessor plus the remaining suffix.
  • Everything else: false, the default. PLAIN and DELTA_LENGTH_BYTE_ARRAY store a value at the same cost wherever it lands, and a dictionary outlives the pages that index into it, so no page boundary makes a value more expensive.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§