Skip to content

Commit 68d9f68

Browse files
authored
Make protobuf metadata fields crate-private
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
1 parent 423354d commit 68d9f68

20 files changed

Lines changed: 98 additions & 85 deletions

File tree

‎encodings/datetime-parts/src/array.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ pub struct DateTimePartsMetadata {
6464
// Validity lives in the days array
6565
// TODO(ngates): we should actually model this with a Tuple array when we have one.
6666
#[prost(enumeration = "PType", tag = "1")]
67-
pub days_ptype: i32,
67+
pub(crate) days_ptype: i32,
6868
#[prost(enumeration = "PType", tag = "2")]
69-
pub seconds_ptype: i32,
69+
pub(crate) seconds_ptype: i32,
7070
#[prost(enumeration = "PType", tag = "3")]
71-
pub subseconds_ptype: i32,
71+
pub(crate) subseconds_ptype: i32,
7272
}
7373

7474
impl DateTimePartsMetadata {

‎encodings/fastlanes/src/rle/vtable/mod.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ pub type RLEArray = Array<RLE>;
4949
#[derive(Clone, prost::Message)]
5050
pub struct RLEMetadata {
5151
#[prost(uint64, tag = "1")]
52-
pub values_len: u64,
52+
pub(crate) values_len: u64,
5353
#[prost(uint64, tag = "2")]
54-
pub indices_len: u64,
54+
pub(crate) indices_len: u64,
5555
#[prost(int32, tag = "3")]
56-
pub indices_ptype: i32,
56+
pub(crate) indices_ptype: i32,
5757
#[prost(uint64, tag = "4")]
58-
pub values_idx_offsets_len: u64,
58+
pub(crate) values_idx_offsets_len: u64,
5959
#[prost(int32, tag = "5")]
60-
pub values_idx_offsets_ptype: i32,
60+
pub(crate) values_idx_offsets_ptype: i32,
6161
#[prost(uint64, tag = "6", default = "0")]
62-
pub offset: u64,
62+
pub(crate) offset: u64,
6363
}
6464

6565
impl RLEMetadata {

‎encodings/onpair/src/array.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,24 @@ pub type OnPairArray = Array<OnPair>;
8181
pub struct OnPairMetadata {
8282
/// Width of the per-row primitive `uncompressed_lengths` child.
8383
#[prost(enumeration = "PType", tag = "1")]
84-
pub uncompressed_lengths_ptype: i32,
84+
pub(crate) uncompressed_lengths_ptype: i32,
8585
/// Number of dictionary tokens. `dict_offsets` has length `dict_size + 1`.
8686
#[prost(uint32, tag = "3")]
87-
pub dict_size: u32,
87+
pub(crate) dict_size: u32,
8888
/// Length of the `codes` slot child. A sliced array may retain codes that
8989
/// fall outside its visible row range.
9090
#[prost(uint64, tag = "4")]
91-
pub codes_len: u64,
91+
pub(crate) codes_len: u64,
9292
/// PType of the `dict_offsets` slot child (defaults to U32, may be
9393
/// narrowed to U16/U8 by the cascading compressor when values fit).
9494
#[prost(enumeration = "PType", tag = "5")]
95-
pub dict_offsets_ptype: i32,
95+
pub(crate) dict_offsets_ptype: i32,
9696
/// PType of the `codes` slot child.
9797
#[prost(enumeration = "PType", tag = "6")]
98-
pub codes_ptype: i32,
98+
pub(crate) codes_ptype: i32,
9999
/// PType of the `codes_offsets` slot child.
100100
#[prost(enumeration = "PType", tag = "7")]
101-
pub codes_offsets_ptype: i32,
101+
pub(crate) codes_offsets_ptype: i32,
102102
}
103103

104104
impl OnPairMetadata {

‎encodings/parquet-variant/src/vtable.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ pub struct ParquetVariant;
6767
struct ParquetVariantMetadataProto {
6868
/// Whether the un-shredded `value` child is present.
6969
#[prost(bool, tag = "1")]
70-
pub has_value: bool,
70+
pub(crate) has_value: bool,
7171
/// DType of the shredded `typed_value`, if present.
7272
#[prost(message, optional, tag = "2")]
73-
pub typed_value_dtype: Option<pb::DType>,
73+
pub(crate) typed_value_dtype: Option<pb::DType>,
7474
/// Whether the `value` child is nullable.
7575
#[prost(bool, tag = "3")]
76-
pub value_nullable: bool,
76+
pub(crate) value_nullable: bool,
7777
}
7878

7979
/// A [`ParquetVariant`]-encoded Vortex array.

‎encodings/pco/src/lib.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct PcoPageInfo {
3434
// count of values.
3535
/// Number of valid primitive values stored in this page.
3636
#[prost(uint32, tag = "1")]
37-
pub n_values: u32,
37+
pub(crate) n_values: u32,
3838
}
3939

4040
// We're calling this Info instead of Metadata because ChunkMeta refers to a specific
@@ -44,7 +44,7 @@ pub struct PcoPageInfo {
4444
pub struct PcoChunkInfo {
4545
/// Pages contained in this chunk.
4646
#[prost(message, repeated, tag = "1")]
47-
pub pages: Vec<PcoPageInfo>,
47+
pub(crate) pages: Vec<PcoPageInfo>,
4848
}
4949

5050
#[derive(Clone, prost::Message)]
@@ -54,10 +54,10 @@ pub struct PcoMetadata {
5454
// no issue duplicating it here per PcoArray
5555
/// Pco file header bytes.
5656
#[prost(bytes, tag = "1")]
57-
pub header: Vec<u8>,
57+
pub(crate) header: Vec<u8>,
5858
/// Metadata for each compressed chunk.
5959
#[prost(message, repeated, tag = "2")]
60-
pub chunks: Vec<PcoChunkInfo>,
60+
pub(crate) chunks: Vec<PcoChunkInfo>,
6161
}
6262

6363
#[cfg(test)]

‎encodings/runend/src/array.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ pub type RunEndArray = Array<RunEnd>;
6363
#[derive(Clone, prost::Message)]
6464
pub struct RunEndMetadata {
6565
#[prost(int32, tag = "1")]
66-
pub ends_ptype: i32,
66+
pub(crate) ends_ptype: i32,
6767
#[prost(uint64, tag = "2")]
68-
pub num_runs: u64,
68+
pub(crate) num_runs: u64,
6969
#[prost(uint64, tag = "3")]
70-
pub offset: u64,
70+
pub(crate) offset: u64,
7171
}
7272

7373
impl RunEndMetadata {

‎encodings/zstd/src/lib.rs‎

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,24 @@ pub(crate) fn validate_frame_content_size(
8181
pub struct ZstdFrameMetadata {
8282
/// Uncompressed byte size of this frame.
8383
#[prost(uint64, tag = "1")]
84-
pub uncompressed_size: u64,
84+
pub(crate) uncompressed_size: u64,
8585
/// Number of valid values stored in this frame.
8686
#[prost(uint64, tag = "2")]
87-
pub n_values: u64,
87+
pub(crate) n_values: u64,
88+
}
89+
90+
impl ZstdFrameMetadata {
91+
/// Returns the uncompressed byte size of this frame.
92+
///
93+
/// Returns an error if the stored size does not fit in [`usize`].
94+
pub fn get_uncompressed_size(&self) -> VortexResult<usize> {
95+
usize::try_from(self.uncompressed_size).map_err(|_| {
96+
vortex_err!(
97+
"ZstdFrameMetadata uncompressed_size must fit in usize, got {}",
98+
self.uncompressed_size
99+
)
100+
})
101+
}
88102
}
89103

90104
#[derive(Clone, prost::Message)]
@@ -93,40 +107,47 @@ pub struct ZstdMetadata {
93107
// optional, will be 0 if there's no dictionary
94108
/// Dictionary size in bytes, or `0` when no dictionary is present.
95109
#[prost(uint32, tag = "1")]
96-
pub dictionary_size: u32,
110+
pub(crate) dictionary_size: u32,
97111
/// Metadata for each compressed frame.
98112
#[prost(message, repeated, tag = "2")]
99-
pub frames: Vec<ZstdFrameMetadata>,
113+
pub(crate) frames: Vec<ZstdFrameMetadata>,
114+
}
115+
116+
impl ZstdMetadata {
117+
/// Returns the metadata for the compressed frames in storage order.
118+
pub fn frames(&self) -> &[ZstdFrameMetadata] {
119+
&self.frames
120+
}
100121
}
101122

102123
#[derive(Clone, prost::Message)]
103124
/// Serialized metadata for the unstable `ZstdBuffers` encoding.
104125
pub struct ZstdBuffersMetadata {
105126
/// Encoding id of the inner array whose buffers were compressed.
106127
#[prost(string, tag = "1")]
107-
pub inner_encoding_id: String,
128+
pub(crate) inner_encoding_id: String,
108129
/// Serialized metadata of the inner array.
109130
#[prost(bytes = "vec", tag = "2")]
110-
pub inner_metadata: Vec<u8>,
131+
pub(crate) inner_metadata: Vec<u8>,
111132
/// Uncompressed byte size of each compressed buffer.
112133
#[prost(uint64, repeated, tag = "3")]
113-
pub uncompressed_sizes: Vec<u64>,
134+
pub(crate) uncompressed_sizes: Vec<u64>,
114135
/// Alignment of each buffer in bytes (must be a power of two).
115136
#[prost(uint32, repeated, tag = "4")]
116-
pub buffer_alignments: Vec<u32>,
137+
pub(crate) buffer_alignments: Vec<u32>,
117138
/// DType of child arrays. Children belong to inner encodings, and their
118139
/// dtypes don't persist after serialization, so we need to retrieve them
119140
/// from metadata.
120141
#[prost(message, repeated, tag = "5")]
121-
pub child_dtypes: Vec<pb::DType>,
142+
pub(crate) child_dtypes: Vec<pb::DType>,
122143
/// Length of each child array, ordered as "child_dtypes"
123144
#[prost(uint64, repeated, tag = "6")]
124-
pub child_lens: Vec<u64>,
145+
pub(crate) child_lens: Vec<u64>,
125146
/// Number of leading children that belong to the inner array. Any child after them holds
126147
/// the validity. Absent in arrays written before the validity was stored separately.
127148
#[prost(uint32, optional, tag = "7")]
128-
pub inner_child_count: Option<u32>,
149+
pub(crate) inner_child_count: Option<u32>,
129150
/// Index of the child holding the validity, if it is not implied by the dtype.
130151
#[prost(uint32, optional, tag = "8")]
131-
pub validity_child: Option<u32>,
152+
pub(crate) validity_child: Option<u32>,
132153
}

‎vortex-array/src/arrays/bool/vtable/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub(crate) fn initialize(session: &VortexSession) {
5252
pub struct BoolMetadata {
5353
// The offset in bits must be <8
5454
#[prost(uint32, tag = "1")]
55-
pub offset: u32,
55+
pub(crate) offset: u32,
5656
}
5757

5858
impl ArrayHash for BoolData {

‎vortex-array/src/arrays/variant/vtable/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub struct Variant;
5151
#[derive(Clone, prost::Message)]
5252
struct VariantMetadataProto {
5353
#[prost(message, optional, tag = "1")]
54-
pub shredded_dtype: Option<pb::DType>,
54+
pub(crate) shredded_dtype: Option<pb::DType>,
5555
}
5656

5757
impl VTable for Variant {

‎vortex-bench/src/conversions.rs‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,7 @@ fn geoparquet_columns(metadata: &ParquetMetaData) -> HashSet<String> {
471471

472472
/// The erased `vortex.st.wkb` extension dtype over a binary `storage` dtype.
473473
fn wkb_ext_dtype(storage: &DType) -> VortexResult<ExtDTypeRef> {
474-
Ok(
475-
ExtDType::<WellKnownBinary>::try_new(SpatialMetadata { crs: None }, storage.clone())?
476-
.erased(),
477-
)
474+
Ok(ExtDType::<WellKnownBinary>::try_new(SpatialMetadata::default(), storage.clone())?.erased())
478475
}
479476

480477
/// Re-type the named binary columns of a struct `dtype` as `vortex.st.wkb`, so the column

0 commit comments

Comments
 (0)