alamb commented on code in PR #7535: URL: https://github.com/apache/arrow-rs/pull/7535#discussion_r2103231456
########## parquet-variant/src/variant.rs: ########## @@ -182,83 +183,127 @@ impl<'m> VariantMetadata<'m> { } /// Get the key-name by index - pub fn get_by(&self, index: usize) -> Result<&'m str, ArrowError> { + pub fn get_field_by_index(&self, index: usize) -> Result<&'m str, ArrowError> { match self.get_offset_by(index) { - Ok(range) => { - let bytes = slice_from_slice(self.bytes, 1 + range.start..1 + range.end)?; - let result = str::from_utf8(bytes).map_err(|_| invalid_utf8_err())?; - Ok(result) - } + Ok(range) => self.get_field_by_offset(range), Err(e) => Err(e), } } - pub fn header(&self) -> VariantMetadataHeader { - self.header - } - - // TODO: Fix this + next two - /// Get the offset_minus_one value from the header - pub fn offset_size_minus_one(&self) -> Result<u8, ArrowError> { - Ok(non_empty_slice(self.bytes)?[0] & (0b11 << 6)) // Grab the last 2 bits + /// Gets the field using an offset (Range) - helper method to keep consistent API. + pub fn get_field_by_offset(&self, offset: Range<usize>) -> Result<&'m str, ArrowError> { Review Comment: ```suggestion fn get_field_by_offset(&self, offset: Range<usize>) -> Result<&'m str, ArrowError> { ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org