Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Improved pargquet nested null deserialization (#1477)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored May 8, 2023
1 parent c676340 commit bf1a3ce
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/io/parquet/read/deserialize/null/nested.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use super::super::nested_utils::*;
use super::super::utils;
use super::super::Pages;

impl<'a> utils::PageState<'a> for () {
impl<'a> utils::PageState<'a> for usize {
fn len(&self) -> usize {
0
*self
}
}

Expand All @@ -26,25 +26,28 @@ impl DecodedState for usize {
}

impl<'a> NestedDecoder<'a> for NullDecoder {
type State = ();
type Dictionary = ();
type State = usize;
type Dictionary = usize;
type DecodedState = usize;

fn build_state(
&self,
_page: &'a DataPage,
_dict: Option<&'a Self::Dictionary>,
dict: Option<&'a Self::Dictionary>,
) -> Result<Self::State> {
Ok(())
if let Some(n) = dict {
return Ok(*n);
}
Ok(1)
}

/// Initializes a new state
fn with_capacity(&self, _capacity: usize) -> Self::DecodedState {
0
}

fn push_valid(&self, _state: &mut Self::State, decoded: &mut Self::DecodedState) -> Result<()> {
*decoded += 1;
fn push_valid(&self, state: &mut Self::State, decoded: &mut Self::DecodedState) -> Result<()> {
*decoded += *state;
Ok(())
}

Expand All @@ -53,8 +56,8 @@ impl<'a> NestedDecoder<'a> for NullDecoder {
*length += 1;
}

fn deserialize_dict(&self, _page: &DictPage) -> Self::Dictionary {
unreachable!()
fn deserialize_dict(&self, page: &DictPage) -> Self::Dictionary {
page.num_values
}
}

Expand Down

0 comments on commit bf1a3ce

Please sign in to comment.