Skip to content

Commit c26d154

Browse files
authored
[Variant] Remove dead code, add comments (#7861)
# Which issue does this PR close? We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. - Part of #6736 # Rationale for this change The `allow_deadcode` has bothered me while reviewing PRs and it also is hiding actually dead code # What changes are included in this PR? 1. Remove clippy annotations to allow dead code 2. Remove code clippy found as dead 3. Add some docs (drive by docing) # Are these changes tested? By CI # Are there any user-facing changes? Just some more docs
1 parent 58b897b commit c26d154

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

parquet-variant/src/decoder.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ use crate::ShortString;
2222
use arrow_schema::ArrowError;
2323
use chrono::{DateTime, Duration, NaiveDate, NaiveDateTime, Utc};
2424

25-
use std::array::TryFromSliceError;
2625
use std::num::TryFromIntError;
2726

28-
// Makes the code a bit more readable
29-
pub(crate) const VARIANT_VALUE_HEADER_BYTES: usize = 1;
30-
27+
/// The basic type of a [`Variant`] value, encoded in the first two bits of the
28+
/// header byte.
29+
///
30+
/// See the [Variant Encoding specification] for details
31+
///
32+
/// [`Variant`]: crate::Variant
33+
/// [Variant Encoding specification]: https://github.com/apache/parquet-format/blob/master/VariantEncoding.md#encoding-types
3134
#[derive(Debug, Clone, Copy, PartialEq)]
3235
pub enum VariantBasicType {
3336
Primitive = 0,
@@ -36,6 +39,13 @@ pub enum VariantBasicType {
3639
Array = 3,
3740
}
3841

42+
/// The type of [`VariantBasicType::Primitive`], for a primitive [`Variant`]
43+
/// value.
44+
///
45+
/// See the [Variant Encoding specification] for details
46+
///
47+
/// [`Variant`]: crate::Variant
48+
/// [Variant Encoding specification]: https://github.com/apache/parquet-format/blob/master/VariantEncoding.md#encoding-types
3949
#[derive(Debug, Clone, Copy, PartialEq)]
4050
pub enum VariantPrimitiveType {
4151
Null = 0,
@@ -196,11 +206,6 @@ pub(crate) fn get_primitive_type(metadata: u8) -> Result<VariantPrimitiveType, A
196206
VariantPrimitiveType::try_from(metadata >> 2)
197207
}
198208

199-
/// To be used in `map_err` when unpacking an integer from a slice of bytes.
200-
fn map_try_from_slice_error(e: TryFromSliceError) -> ArrowError {
201-
ArrowError::InvalidArgumentError(e.to_string())
202-
}
203-
204209
/// Decodes an Int8 from the value section of a variant.
205210
pub(crate) fn decode_int8(data: &[u8]) -> Result<i8, ArrowError> {
206211
Ok(i8::from_le_bytes(array_from_slice(data, 0)?))

parquet-variant/src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,12 @@
2727
//!
2828
//! [Variant issue]: https://github.com/apache/arrow-rs/issues/6736
2929
30-
// TODO: dead code removal
31-
#[allow(dead_code)]
32-
mod decoder;
33-
mod variant;
34-
// TODO: dead code removal
3530
mod builder;
31+
mod decoder;
3632
mod from_json;
3733
mod to_json;
38-
#[allow(dead_code)]
3934
mod utils;
35+
mod variant;
4036

4137
pub use builder::*;
4238
pub use from_json::json_to_variant;

0 commit comments

Comments
 (0)