pub struct TapeDecoder {
elements: Vec<TapeElement>,
cur_row: usize,
batch_size: usize,
flatten_top_level_arrays: bool,
bytes: Vec<u8>,
offsets: Vec<usize>,
stack: Vec<DecoderState>,
}Expand description
Implements a state machine for decoding JSON to a tape
Fields§
§elements: Vec<TapeElement>The decoded elements
cur_row: usizeThe number of rows decoded, including any in progress if !stack.is_empty()
batch_size: usizeNumber of rows to read per batch
flatten_top_level_arrays: boolWhether to flatten top-level arrays into the stream of JSON rows, meaning that each of their elements will be treated as an individual row
When false (the default), the entire top-level array will be treated as one row
bytes: Vec<u8>A buffer of parsed string data
Note: if part way through a record, i.e. stack is not empty,
this may contain truncated UTF-8 data
offsets: Vec<usize>Offsets into data
stack: Vec<DecoderState>A stack of DecoderState
Implementations§
Source§impl TapeDecoder
impl TapeDecoder
Sourcepub fn new(options: TapeDecoderOptions) -> Self
pub fn new(options: TapeDecoderOptions) -> Self
Create a new TapeDecoder with the provided options
pub fn decode(&mut self, buf: &[u8]) -> Result<usize, ArrowError>
Sourcepub fn serialize<S: Serialize>(&mut self, rows: &[S]) -> Result<(), ArrowError>
pub fn serialize<S: Serialize>(&mut self, rows: &[S]) -> Result<(), ArrowError>
Writes any type that implements Serialize into this TapeDecoder
Sourcepub fn num_buffered_rows(&self) -> usize
pub fn num_buffered_rows(&self) -> usize
The number of buffered rows, including the partially decoded row (if any).
Sourcepub fn has_partial_row(&self) -> bool
pub fn has_partial_row(&self) -> bool
True if the decoder is part way through decoding a row. If so, calling Self::finish
would return an error.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears this TapeDecoder in preparation to read the next batch