MCPcopy Create free account
hub / github.com/apache/arrow-rs / try_push

Method try_push

parquet/src/arrow/buffer/offset_buffer.rs:64–84  ·  view source on GitHub ↗

If `validate_utf8` this verifies that the first character of `data` is the start of a UTF-8 codepoint Note: This does not verify that the entirety of `data` is valid UTF-8. This should be done by calling [`Self::check_valid_utf8`] after all data has been written

(&mut self, data: &[u8], validate_utf8: bool)

Source from the content-addressed store, hash-verified

62 /// UTF-8. This should be done by calling [`Self::check_valid_utf8`] after
63 /// all data has been written
64 pub fn try_push(&mut self, data: &[u8], validate_utf8: bool) -> Result<()> {
65 if validate_utf8 {
66 if let Some(&b) = data.first() {
67 // A valid code-point iff it does not start with 0b10xxxxxx
68 // Bit-magic taken from `std::str::is_char_boundary`
69 if (b as i8) < -0x40 {
70 return Err(ParquetError::General(
71 "encountered non UTF-8 data".to_string(),
72 ));
73 }
74 }
75 }
76
77 self.values.extend_from_slice(data);
78
79 let index_offset = I::from_usize(self.values.len())
80 .ok_or_else(|| general_err!("index overflow decoding byte array"))?;
81
82 self.offsets.push(index_offset);
83 Ok(())
84 }
85
86 /// Extends this buffer with a list of keys
87 ///

Callers 6

readMethod · 0.80
test_offset_bufferFunction · 0.80
test_utf8_validationFunction · 0.80
test_dictionary_bufferFunction · 0.80

Calls 4

firstMethod · 0.80
extend_from_sliceMethod · 0.80
lenMethod · 0.45
pushMethod · 0.45

Tested by 5

test_offset_bufferFunction · 0.64
test_utf8_validationFunction · 0.64
test_dictionary_bufferFunction · 0.64