@@ -81,10 +81,24 @@ pub(crate) fn validate_frame_content_size(
8181pub 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.
104125pub 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}
0 commit comments