parquet/
format.rs

1//! See [`crate::file`] for easier to use APIs.
2// Autogenerated by Thrift Compiler (0.21.0)
3// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
4
5#![allow(dead_code)]
6#![allow(unused_imports)]
7#![allow(unused_extern_crates)]
8#![allow(clippy::too_many_arguments, clippy::type_complexity, clippy::vec_box, clippy::wrong_self_convention)]
9// Fix unexpected `cfg` condition name: `rustfmt` https://github.com/apache/arrow-rs/issues/5725
10//#![cfg_attr(rustfmt, rustfmt_skip)]
11
12use std::cell::RefCell;
13use std::collections::{BTreeMap, BTreeSet};
14use std::convert::{From, TryFrom};
15use std::default::Default;
16use std::error::Error;
17use std::fmt;
18use std::fmt::{Display, Formatter};
19use std::rc::Rc;
20
21use thrift::OrderedFloat;
22use thrift::{ApplicationError, ApplicationErrorKind, ProtocolError, ProtocolErrorKind, TThriftClient};
23use thrift::protocol::{TFieldIdentifier, TListIdentifier, TMapIdentifier, TMessageIdentifier, TMessageType, TInputProtocol, TOutputProtocol, TSerializable, TSetIdentifier, TStructIdentifier, TType};
24use thrift::protocol::field_id;
25use thrift::protocol::verify_expected_message_type;
26use thrift::protocol::verify_expected_sequence_number;
27use thrift::protocol::verify_expected_service_call;
28use thrift::protocol::verify_required_field_exists;
29
30/// Types supported by Parquet.  These types are intended to be used in combination
31/// with the encodings to control the on disk storage format.
32/// For example INT16 is not included as a type since a good encoding of INT32
33/// would handle this.
34#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct Type(pub i32);
36
37impl Type {
38  pub const BOOLEAN: Type = Type(0);
39  pub const INT32: Type = Type(1);
40  pub const INT64: Type = Type(2);
41  pub const INT96: Type = Type(3);
42  pub const FLOAT: Type = Type(4);
43  pub const DOUBLE: Type = Type(5);
44  pub const BYTE_ARRAY: Type = Type(6);
45  pub const FIXED_LEN_BYTE_ARRAY: Type = Type(7);
46  pub const ENUM_VALUES: &'static [Self] = &[
47    Self::BOOLEAN,
48    Self::INT32,
49    Self::INT64,
50    Self::INT96,
51    Self::FLOAT,
52    Self::DOUBLE,
53    Self::BYTE_ARRAY,
54    Self::FIXED_LEN_BYTE_ARRAY,
55  ];
56}
57
58impl crate::thrift::TSerializable for Type {
59  #[allow(clippy::trivially_copy_pass_by_ref)]
60  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
61    o_prot.write_i32(self.0)
62  }
63  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<Type> {
64    let enum_value = i_prot.read_i32()?;
65    Ok(Type::from(enum_value))
66  }
67}
68
69impl From<i32> for Type {
70  fn from(i: i32) -> Self {
71    match i {
72      0 => Type::BOOLEAN,
73      1 => Type::INT32,
74      2 => Type::INT64,
75      3 => Type::INT96,
76      4 => Type::FLOAT,
77      5 => Type::DOUBLE,
78      6 => Type::BYTE_ARRAY,
79      7 => Type::FIXED_LEN_BYTE_ARRAY,
80      _ => Type(i)
81    }
82  }
83}
84
85impl From<&i32> for Type {
86  fn from(i: &i32) -> Self {
87    Type::from(*i)
88  }
89}
90
91impl From<Type> for i32 {
92  fn from(e: Type) -> i32 {
93    e.0
94  }
95}
96
97impl From<&Type> for i32 {
98  fn from(e: &Type) -> i32 {
99    e.0
100  }
101}
102
103/// DEPRECATED: Common types used by frameworks(e.g. hive, pig) using parquet.
104/// ConvertedType is superseded by LogicalType.  This enum should not be extended.
105/// 
106/// See LogicalTypes.md for conversion between ConvertedType and LogicalType.
107#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
108pub struct ConvertedType(pub i32);
109
110impl ConvertedType {
111  /// a BYTE_ARRAY actually contains UTF8 encoded chars
112  pub const UTF8: ConvertedType = ConvertedType(0);
113  /// a map is converted as an optional field containing a repeated key/value pair
114  pub const MAP: ConvertedType = ConvertedType(1);
115  /// a key/value pair is converted into a group of two fields
116  pub const MAP_KEY_VALUE: ConvertedType = ConvertedType(2);
117  /// a list is converted into an optional field containing a repeated field for its
118  /// values
119  pub const LIST: ConvertedType = ConvertedType(3);
120  /// an enum is converted into a BYTE_ARRAY field
121  pub const ENUM: ConvertedType = ConvertedType(4);
122  /// A decimal value.
123  /// 
124  /// This may be used to annotate BYTE_ARRAY or FIXED_LEN_BYTE_ARRAY primitive
125  /// types. The underlying byte array stores the unscaled value encoded as two's
126  /// complement using big-endian byte order (the most significant byte is the
127  /// zeroth element). The value of the decimal is the value * 10^{-scale}.
128  /// 
129  /// This must be accompanied by a (maximum) precision and a scale in the
130  /// SchemaElement. The precision specifies the number of digits in the decimal
131  /// and the scale stores the location of the decimal point. For example 1.23
132  /// would have precision 3 (3 total digits) and scale 2 (the decimal point is
133  /// 2 digits over).
134  pub const DECIMAL: ConvertedType = ConvertedType(5);
135  /// A Date
136  /// 
137  /// Stored as days since Unix epoch, encoded as the INT32 physical type.
138  /// 
139  pub const DATE: ConvertedType = ConvertedType(6);
140  /// A time
141  /// 
142  /// The total number of milliseconds since midnight.  The value is stored
143  /// as an INT32 physical type.
144  pub const TIME_MILLIS: ConvertedType = ConvertedType(7);
145  /// A time.
146  /// 
147  /// The total number of microseconds since midnight.  The value is stored as
148  /// an INT64 physical type.
149  pub const TIME_MICROS: ConvertedType = ConvertedType(8);
150  /// A date/time combination
151  /// 
152  /// Date and time recorded as milliseconds since the Unix epoch.  Recorded as
153  /// a physical type of INT64.
154  pub const TIMESTAMP_MILLIS: ConvertedType = ConvertedType(9);
155  /// A date/time combination
156  /// 
157  /// Date and time recorded as microseconds since the Unix epoch.  The value is
158  /// stored as an INT64 physical type.
159  pub const TIMESTAMP_MICROS: ConvertedType = ConvertedType(10);
160  /// An unsigned integer value.
161  /// 
162  /// The number describes the maximum number of meaningful data bits in
163  /// the stored value. 8, 16 and 32 bit values are stored using the
164  /// INT32 physical type.  64 bit values are stored using the INT64
165  /// physical type.
166  /// 
167  pub const UINT_8: ConvertedType = ConvertedType(11);
168  pub const UINT_16: ConvertedType = ConvertedType(12);
169  pub const UINT_32: ConvertedType = ConvertedType(13);
170  pub const UINT_64: ConvertedType = ConvertedType(14);
171  /// A signed integer value.
172  /// 
173  /// The number describes the maximum number of meaningful data bits in
174  /// the stored value. 8, 16 and 32 bit values are stored using the
175  /// INT32 physical type.  64 bit values are stored using the INT64
176  /// physical type.
177  /// 
178  pub const INT_8: ConvertedType = ConvertedType(15);
179  pub const INT_16: ConvertedType = ConvertedType(16);
180  pub const INT_32: ConvertedType = ConvertedType(17);
181  pub const INT_64: ConvertedType = ConvertedType(18);
182  /// An embedded JSON document
183  /// 
184  /// A JSON document embedded within a single UTF8 column.
185  pub const JSON: ConvertedType = ConvertedType(19);
186  /// An embedded BSON document
187  /// 
188  /// A BSON document embedded within a single BYTE_ARRAY column.
189  pub const BSON: ConvertedType = ConvertedType(20);
190  /// An interval of time
191  /// 
192  /// This type annotates data stored as a FIXED_LEN_BYTE_ARRAY of length 12
193  /// This data is composed of three separate little endian unsigned
194  /// integers.  Each stores a component of a duration of time.  The first
195  /// integer identifies the number of months associated with the duration,
196  /// the second identifies the number of days associated with the duration
197  /// and the third identifies the number of milliseconds associated with
198  /// the provided duration.  This duration of time is independent of any
199  /// particular timezone or date.
200  pub const INTERVAL: ConvertedType = ConvertedType(21);
201  pub const ENUM_VALUES: &'static [Self] = &[
202    Self::UTF8,
203    Self::MAP,
204    Self::MAP_KEY_VALUE,
205    Self::LIST,
206    Self::ENUM,
207    Self::DECIMAL,
208    Self::DATE,
209    Self::TIME_MILLIS,
210    Self::TIME_MICROS,
211    Self::TIMESTAMP_MILLIS,
212    Self::TIMESTAMP_MICROS,
213    Self::UINT_8,
214    Self::UINT_16,
215    Self::UINT_32,
216    Self::UINT_64,
217    Self::INT_8,
218    Self::INT_16,
219    Self::INT_32,
220    Self::INT_64,
221    Self::JSON,
222    Self::BSON,
223    Self::INTERVAL,
224  ];
225}
226
227impl crate::thrift::TSerializable for ConvertedType {
228  #[allow(clippy::trivially_copy_pass_by_ref)]
229  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
230    o_prot.write_i32(self.0)
231  }
232  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<ConvertedType> {
233    let enum_value = i_prot.read_i32()?;
234    Ok(ConvertedType::from(enum_value))
235  }
236}
237
238impl From<i32> for ConvertedType {
239  fn from(i: i32) -> Self {
240    match i {
241      0 => ConvertedType::UTF8,
242      1 => ConvertedType::MAP,
243      2 => ConvertedType::MAP_KEY_VALUE,
244      3 => ConvertedType::LIST,
245      4 => ConvertedType::ENUM,
246      5 => ConvertedType::DECIMAL,
247      6 => ConvertedType::DATE,
248      7 => ConvertedType::TIME_MILLIS,
249      8 => ConvertedType::TIME_MICROS,
250      9 => ConvertedType::TIMESTAMP_MILLIS,
251      10 => ConvertedType::TIMESTAMP_MICROS,
252      11 => ConvertedType::UINT_8,
253      12 => ConvertedType::UINT_16,
254      13 => ConvertedType::UINT_32,
255      14 => ConvertedType::UINT_64,
256      15 => ConvertedType::INT_8,
257      16 => ConvertedType::INT_16,
258      17 => ConvertedType::INT_32,
259      18 => ConvertedType::INT_64,
260      19 => ConvertedType::JSON,
261      20 => ConvertedType::BSON,
262      21 => ConvertedType::INTERVAL,
263      _ => ConvertedType(i)
264    }
265  }
266}
267
268impl From<&i32> for ConvertedType {
269  fn from(i: &i32) -> Self {
270    ConvertedType::from(*i)
271  }
272}
273
274impl From<ConvertedType> for i32 {
275  fn from(e: ConvertedType) -> i32 {
276    e.0
277  }
278}
279
280impl From<&ConvertedType> for i32 {
281  fn from(e: &ConvertedType) -> i32 {
282    e.0
283  }
284}
285
286/// Representation of Schemas
287#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
288pub struct FieldRepetitionType(pub i32);
289
290impl FieldRepetitionType {
291  /// This field is required (can not be null) and each row has exactly 1 value.
292  pub const REQUIRED: FieldRepetitionType = FieldRepetitionType(0);
293  /// The field is optional (can be null) and each row has 0 or 1 values.
294  pub const OPTIONAL: FieldRepetitionType = FieldRepetitionType(1);
295  /// The field is repeated and can contain 0 or more values
296  pub const REPEATED: FieldRepetitionType = FieldRepetitionType(2);
297  pub const ENUM_VALUES: &'static [Self] = &[
298    Self::REQUIRED,
299    Self::OPTIONAL,
300    Self::REPEATED,
301  ];
302}
303
304impl crate::thrift::TSerializable for FieldRepetitionType {
305  #[allow(clippy::trivially_copy_pass_by_ref)]
306  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
307    o_prot.write_i32(self.0)
308  }
309  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<FieldRepetitionType> {
310    let enum_value = i_prot.read_i32()?;
311    Ok(FieldRepetitionType::from(enum_value))
312  }
313}
314
315impl From<i32> for FieldRepetitionType {
316  fn from(i: i32) -> Self {
317    match i {
318      0 => FieldRepetitionType::REQUIRED,
319      1 => FieldRepetitionType::OPTIONAL,
320      2 => FieldRepetitionType::REPEATED,
321      _ => FieldRepetitionType(i)
322    }
323  }
324}
325
326impl From<&i32> for FieldRepetitionType {
327  fn from(i: &i32) -> Self {
328    FieldRepetitionType::from(*i)
329  }
330}
331
332impl From<FieldRepetitionType> for i32 {
333  fn from(e: FieldRepetitionType) -> i32 {
334    e.0
335  }
336}
337
338impl From<&FieldRepetitionType> for i32 {
339  fn from(e: &FieldRepetitionType) -> i32 {
340    e.0
341  }
342}
343
344/// Edge interpolation algorithm for Geography logical type
345#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
346pub struct EdgeInterpolationAlgorithm(pub i32);
347
348impl EdgeInterpolationAlgorithm {
349  pub const SPHERICAL: EdgeInterpolationAlgorithm = EdgeInterpolationAlgorithm(0);
350  pub const VINCENTY: EdgeInterpolationAlgorithm = EdgeInterpolationAlgorithm(1);
351  pub const THOMAS: EdgeInterpolationAlgorithm = EdgeInterpolationAlgorithm(2);
352  pub const ANDOYER: EdgeInterpolationAlgorithm = EdgeInterpolationAlgorithm(3);
353  pub const KARNEY: EdgeInterpolationAlgorithm = EdgeInterpolationAlgorithm(4);
354  pub const ENUM_VALUES: &'static [Self] = &[
355    Self::SPHERICAL,
356    Self::VINCENTY,
357    Self::THOMAS,
358    Self::ANDOYER,
359    Self::KARNEY,
360  ];
361}
362
363impl crate::thrift::TSerializable for EdgeInterpolationAlgorithm {
364  #[allow(clippy::trivially_copy_pass_by_ref)]
365  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
366    o_prot.write_i32(self.0)
367  }
368  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<EdgeInterpolationAlgorithm> {
369    let enum_value = i_prot.read_i32()?;
370    Ok(EdgeInterpolationAlgorithm::from(enum_value))
371  }
372}
373
374impl From<i32> for EdgeInterpolationAlgorithm {
375  fn from(i: i32) -> Self {
376    match i {
377      0 => EdgeInterpolationAlgorithm::SPHERICAL,
378      1 => EdgeInterpolationAlgorithm::VINCENTY,
379      2 => EdgeInterpolationAlgorithm::THOMAS,
380      3 => EdgeInterpolationAlgorithm::ANDOYER,
381      4 => EdgeInterpolationAlgorithm::KARNEY,
382      _ => EdgeInterpolationAlgorithm(i)
383    }
384  }
385}
386
387impl From<&i32> for EdgeInterpolationAlgorithm {
388  fn from(i: &i32) -> Self {
389    EdgeInterpolationAlgorithm::from(*i)
390  }
391}
392
393impl From<EdgeInterpolationAlgorithm> for i32 {
394  fn from(e: EdgeInterpolationAlgorithm) -> i32 {
395    e.0
396  }
397}
398
399impl From<&EdgeInterpolationAlgorithm> for i32 {
400  fn from(e: &EdgeInterpolationAlgorithm) -> i32 {
401    e.0
402  }
403}
404
405/// Encodings supported by Parquet.  Not all encodings are valid for all types.  These
406/// enums are also used to specify the encoding of definition and repetition levels.
407/// See the accompanying doc for the details of the more complicated encodings.
408#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
409pub struct Encoding(pub i32);
410
411impl Encoding {
412  /// Default encoding.
413  /// BOOLEAN - 1 bit per value. 0 is false; 1 is true.
414  /// INT32 - 4 bytes per value.  Stored as little-endian.
415  /// INT64 - 8 bytes per value.  Stored as little-endian.
416  /// FLOAT - 4 bytes per value.  IEEE. Stored as little-endian.
417  /// DOUBLE - 8 bytes per value.  IEEE. Stored as little-endian.
418  /// BYTE_ARRAY - 4 byte length stored as little endian, followed by bytes.
419  /// FIXED_LEN_BYTE_ARRAY - Just the bytes.
420  pub const PLAIN: Encoding = Encoding(0);
421  /// Deprecated: Dictionary encoding. The values in the dictionary are encoded in the
422  /// plain type.
423  /// in a data page use RLE_DICTIONARY instead.
424  /// in a Dictionary page use PLAIN instead
425  pub const PLAIN_DICTIONARY: Encoding = Encoding(2);
426  /// Group packed run length encoding. Usable for definition/repetition levels
427  /// encoding and Booleans (on one bit: 0 is false; 1 is true.)
428  pub const RLE: Encoding = Encoding(3);
429  /// Bit packed encoding.  This can only be used if the data has a known max
430  /// width.  Usable for definition/repetition levels encoding.
431  pub const BIT_PACKED: Encoding = Encoding(4);
432  /// Delta encoding for integers. This can be used for int columns and works best
433  /// on sorted data
434  pub const DELTA_BINARY_PACKED: Encoding = Encoding(5);
435  /// Encoding for byte arrays to separate the length values and the data. The lengths
436  /// are encoded using DELTA_BINARY_PACKED
437  pub const DELTA_LENGTH_BYTE_ARRAY: Encoding = Encoding(6);
438  /// Incremental-encoded byte array. Prefix lengths are encoded using DELTA_BINARY_PACKED.
439  /// Suffixes are stored as delta length byte arrays.
440  pub const DELTA_BYTE_ARRAY: Encoding = Encoding(7);
441  /// Dictionary encoding: the ids are encoded using the RLE encoding
442  pub const RLE_DICTIONARY: Encoding = Encoding(8);
443  /// Encoding for fixed-width data (FLOAT, DOUBLE, INT32, INT64, FIXED_LEN_BYTE_ARRAY).
444  /// K byte-streams are created where K is the size in bytes of the data type.
445  /// The individual bytes of a value are scattered to the corresponding stream and
446  /// the streams are concatenated.
447  /// This itself does not reduce the size of the data but can lead to better compression
448  /// afterwards.
449  /// 
450  /// Added in 2.8 for FLOAT and DOUBLE.
451  /// Support for INT32, INT64 and FIXED_LEN_BYTE_ARRAY added in 2.11.
452  pub const BYTE_STREAM_SPLIT: Encoding = Encoding(9);
453  pub const ENUM_VALUES: &'static [Self] = &[
454    Self::PLAIN,
455    Self::PLAIN_DICTIONARY,
456    Self::RLE,
457    Self::BIT_PACKED,
458    Self::DELTA_BINARY_PACKED,
459    Self::DELTA_LENGTH_BYTE_ARRAY,
460    Self::DELTA_BYTE_ARRAY,
461    Self::RLE_DICTIONARY,
462    Self::BYTE_STREAM_SPLIT,
463  ];
464}
465
466impl crate::thrift::TSerializable for Encoding {
467  #[allow(clippy::trivially_copy_pass_by_ref)]
468  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
469    o_prot.write_i32(self.0)
470  }
471  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<Encoding> {
472    let enum_value = i_prot.read_i32()?;
473    Ok(Encoding::from(enum_value))
474  }
475}
476
477impl From<i32> for Encoding {
478  fn from(i: i32) -> Self {
479    match i {
480      0 => Encoding::PLAIN,
481      2 => Encoding::PLAIN_DICTIONARY,
482      3 => Encoding::RLE,
483      4 => Encoding::BIT_PACKED,
484      5 => Encoding::DELTA_BINARY_PACKED,
485      6 => Encoding::DELTA_LENGTH_BYTE_ARRAY,
486      7 => Encoding::DELTA_BYTE_ARRAY,
487      8 => Encoding::RLE_DICTIONARY,
488      9 => Encoding::BYTE_STREAM_SPLIT,
489      _ => Encoding(i)
490    }
491  }
492}
493
494impl From<&i32> for Encoding {
495  fn from(i: &i32) -> Self {
496    Encoding::from(*i)
497  }
498}
499
500impl From<Encoding> for i32 {
501  fn from(e: Encoding) -> i32 {
502    e.0
503  }
504}
505
506impl From<&Encoding> for i32 {
507  fn from(e: &Encoding) -> i32 {
508    e.0
509  }
510}
511
512/// Supported compression algorithms.
513/// 
514/// Codecs added in format version X.Y can be read by readers based on X.Y and later.
515/// Codec support may vary between readers based on the format version and
516/// libraries available at runtime.
517/// 
518/// See Compression.md for a detailed specification of these algorithms.
519#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
520pub struct CompressionCodec(pub i32);
521
522impl CompressionCodec {
523  pub const UNCOMPRESSED: CompressionCodec = CompressionCodec(0);
524  pub const SNAPPY: CompressionCodec = CompressionCodec(1);
525  pub const GZIP: CompressionCodec = CompressionCodec(2);
526  pub const LZO: CompressionCodec = CompressionCodec(3);
527  pub const BROTLI: CompressionCodec = CompressionCodec(4);
528  pub const LZ4: CompressionCodec = CompressionCodec(5);
529  pub const ZSTD: CompressionCodec = CompressionCodec(6);
530  pub const LZ4_RAW: CompressionCodec = CompressionCodec(7);
531  pub const ENUM_VALUES: &'static [Self] = &[
532    Self::UNCOMPRESSED,
533    Self::SNAPPY,
534    Self::GZIP,
535    Self::LZO,
536    Self::BROTLI,
537    Self::LZ4,
538    Self::ZSTD,
539    Self::LZ4_RAW,
540  ];
541}
542
543impl crate::thrift::TSerializable for CompressionCodec {
544  #[allow(clippy::trivially_copy_pass_by_ref)]
545  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
546    o_prot.write_i32(self.0)
547  }
548  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<CompressionCodec> {
549    let enum_value = i_prot.read_i32()?;
550    Ok(CompressionCodec::from(enum_value))
551  }
552}
553
554impl From<i32> for CompressionCodec {
555  fn from(i: i32) -> Self {
556    match i {
557      0 => CompressionCodec::UNCOMPRESSED,
558      1 => CompressionCodec::SNAPPY,
559      2 => CompressionCodec::GZIP,
560      3 => CompressionCodec::LZO,
561      4 => CompressionCodec::BROTLI,
562      5 => CompressionCodec::LZ4,
563      6 => CompressionCodec::ZSTD,
564      7 => CompressionCodec::LZ4_RAW,
565      _ => CompressionCodec(i)
566    }
567  }
568}
569
570impl From<&i32> for CompressionCodec {
571  fn from(i: &i32) -> Self {
572    CompressionCodec::from(*i)
573  }
574}
575
576impl From<CompressionCodec> for i32 {
577  fn from(e: CompressionCodec) -> i32 {
578    e.0
579  }
580}
581
582impl From<&CompressionCodec> for i32 {
583  fn from(e: &CompressionCodec) -> i32 {
584    e.0
585  }
586}
587
588#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
589pub struct PageType(pub i32);
590
591impl PageType {
592  pub const DATA_PAGE: PageType = PageType(0);
593  pub const INDEX_PAGE: PageType = PageType(1);
594  pub const DICTIONARY_PAGE: PageType = PageType(2);
595  pub const DATA_PAGE_V2: PageType = PageType(3);
596  pub const ENUM_VALUES: &'static [Self] = &[
597    Self::DATA_PAGE,
598    Self::INDEX_PAGE,
599    Self::DICTIONARY_PAGE,
600    Self::DATA_PAGE_V2,
601  ];
602}
603
604impl crate::thrift::TSerializable for PageType {
605  #[allow(clippy::trivially_copy_pass_by_ref)]
606  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
607    o_prot.write_i32(self.0)
608  }
609  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<PageType> {
610    let enum_value = i_prot.read_i32()?;
611    Ok(PageType::from(enum_value))
612  }
613}
614
615impl From<i32> for PageType {
616  fn from(i: i32) -> Self {
617    match i {
618      0 => PageType::DATA_PAGE,
619      1 => PageType::INDEX_PAGE,
620      2 => PageType::DICTIONARY_PAGE,
621      3 => PageType::DATA_PAGE_V2,
622      _ => PageType(i)
623    }
624  }
625}
626
627impl From<&i32> for PageType {
628  fn from(i: &i32) -> Self {
629    PageType::from(*i)
630  }
631}
632
633impl From<PageType> for i32 {
634  fn from(e: PageType) -> i32 {
635    e.0
636  }
637}
638
639impl From<&PageType> for i32 {
640  fn from(e: &PageType) -> i32 {
641    e.0
642  }
643}
644
645/// Enum to annotate whether lists of min/max elements inside ColumnIndex
646/// are ordered and if so, in which direction.
647#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
648pub struct BoundaryOrder(pub i32);
649
650impl BoundaryOrder {
651  pub const UNORDERED: BoundaryOrder = BoundaryOrder(0);
652  pub const ASCENDING: BoundaryOrder = BoundaryOrder(1);
653  pub const DESCENDING: BoundaryOrder = BoundaryOrder(2);
654  pub const ENUM_VALUES: &'static [Self] = &[
655    Self::UNORDERED,
656    Self::ASCENDING,
657    Self::DESCENDING,
658  ];
659}
660
661impl crate::thrift::TSerializable for BoundaryOrder {
662  #[allow(clippy::trivially_copy_pass_by_ref)]
663  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
664    o_prot.write_i32(self.0)
665  }
666  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<BoundaryOrder> {
667    let enum_value = i_prot.read_i32()?;
668    Ok(BoundaryOrder::from(enum_value))
669  }
670}
671
672impl From<i32> for BoundaryOrder {
673  fn from(i: i32) -> Self {
674    match i {
675      0 => BoundaryOrder::UNORDERED,
676      1 => BoundaryOrder::ASCENDING,
677      2 => BoundaryOrder::DESCENDING,
678      _ => BoundaryOrder(i)
679    }
680  }
681}
682
683impl From<&i32> for BoundaryOrder {
684  fn from(i: &i32) -> Self {
685    BoundaryOrder::from(*i)
686  }
687}
688
689impl From<BoundaryOrder> for i32 {
690  fn from(e: BoundaryOrder) -> i32 {
691    e.0
692  }
693}
694
695impl From<&BoundaryOrder> for i32 {
696  fn from(e: &BoundaryOrder) -> i32 {
697    e.0
698  }
699}
700
701//
702// SizeStatistics
703//
704
705/// A structure for capturing metadata for estimating the unencoded,
706/// uncompressed size of data written. This is useful for readers to estimate
707/// how much memory is needed to reconstruct data in their memory model and for
708/// fine grained filter pushdown on nested structures (the histograms contained
709/// in this structure can help determine the number of nulls at a particular
710/// nesting level and maximum length of lists).
711#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
712pub struct SizeStatistics {
713  /// The number of physical bytes stored for BYTE_ARRAY data values assuming
714  /// no encoding. This is exclusive of the bytes needed to store the length of
715  /// each byte array. In other words, this field is equivalent to the `(size
716  /// of PLAIN-ENCODING the byte array values) - (4 bytes * number of values
717  /// written)`. To determine unencoded sizes of other types readers can use
718  /// schema information multiplied by the number of non-null and null values.
719  /// The number of null/non-null values can be inferred from the histograms
720  /// below.
721  /// 
722  /// For example, if a column chunk is dictionary-encoded with dictionary
723  /// ["a", "bc", "cde"], and a data page contains the indices [0, 0, 1, 2],
724  /// then this value for that data page should be 7 (1 + 1 + 2 + 3).
725  /// 
726  /// This field should only be set for types that use BYTE_ARRAY as their
727  /// physical type.
728  pub unencoded_byte_array_data_bytes: Option<i64>,
729  /// When present, there is expected to be one element corresponding to each
730  /// repetition (i.e. size=max repetition_level+1) where each element
731  /// represents the number of times the repetition level was observed in the
732  /// data.
733  /// 
734  /// This field may be omitted if max_repetition_level is 0 without loss
735  /// of information.
736  /// 
737  pub repetition_level_histogram: Option<Vec<i64>>,
738  /// Same as repetition_level_histogram except for definition levels.
739  /// 
740  /// This field may be omitted if max_definition_level is 0 or 1 without
741  /// loss of information.
742  /// 
743  pub definition_level_histogram: Option<Vec<i64>>,
744}
745
746impl SizeStatistics {
747  pub fn new<F1, F2, F3>(unencoded_byte_array_data_bytes: F1, repetition_level_histogram: F2, definition_level_histogram: F3) -> SizeStatistics where F1: Into<Option<i64>>, F2: Into<Option<Vec<i64>>>, F3: Into<Option<Vec<i64>>> {
748    SizeStatistics {
749      unencoded_byte_array_data_bytes: unencoded_byte_array_data_bytes.into(),
750      repetition_level_histogram: repetition_level_histogram.into(),
751      definition_level_histogram: definition_level_histogram.into(),
752    }
753  }
754}
755
756impl crate::thrift::TSerializable for SizeStatistics {
757  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<SizeStatistics> {
758    i_prot.read_struct_begin()?;
759    let mut f_1: Option<i64> = None;
760    let mut f_2: Option<Vec<i64>> = None;
761    let mut f_3: Option<Vec<i64>> = None;
762    loop {
763      let field_ident = i_prot.read_field_begin()?;
764      if field_ident.field_type == TType::Stop {
765        break;
766      }
767      let field_id = field_id(&field_ident)?;
768      match field_id {
769        1 => {
770          let val = i_prot.read_i64()?;
771          f_1 = Some(val);
772        },
773        2 => {
774          let list_ident = i_prot.read_list_begin()?;
775          let mut val: Vec<i64> = Vec::with_capacity(list_ident.size as usize);
776          for _ in 0..list_ident.size {
777            let list_elem_0 = i_prot.read_i64()?;
778            val.push(list_elem_0);
779          }
780          i_prot.read_list_end()?;
781          f_2 = Some(val);
782        },
783        3 => {
784          let list_ident = i_prot.read_list_begin()?;
785          let mut val: Vec<i64> = Vec::with_capacity(list_ident.size as usize);
786          for _ in 0..list_ident.size {
787            let list_elem_1 = i_prot.read_i64()?;
788            val.push(list_elem_1);
789          }
790          i_prot.read_list_end()?;
791          f_3 = Some(val);
792        },
793        _ => {
794          i_prot.skip(field_ident.field_type)?;
795        },
796      };
797      i_prot.read_field_end()?;
798    }
799    i_prot.read_struct_end()?;
800    let ret = SizeStatistics {
801      unencoded_byte_array_data_bytes: f_1,
802      repetition_level_histogram: f_2,
803      definition_level_histogram: f_3,
804    };
805    Ok(ret)
806  }
807  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
808    let struct_ident = TStructIdentifier::new("SizeStatistics");
809    o_prot.write_struct_begin(&struct_ident)?;
810    if let Some(fld_var) = self.unencoded_byte_array_data_bytes {
811      o_prot.write_field_begin(&TFieldIdentifier::new("unencoded_byte_array_data_bytes", TType::I64, 1))?;
812      o_prot.write_i64(fld_var)?;
813      o_prot.write_field_end()?
814    }
815    if let Some(ref fld_var) = self.repetition_level_histogram {
816      o_prot.write_field_begin(&TFieldIdentifier::new("repetition_level_histogram", TType::List, 2))?;
817      o_prot.write_list_begin(&TListIdentifier::new(TType::I64, fld_var.len() as i32))?;
818      for e in fld_var {
819        o_prot.write_i64(*e)?;
820      }
821      o_prot.write_list_end()?;
822      o_prot.write_field_end()?
823    }
824    if let Some(ref fld_var) = self.definition_level_histogram {
825      o_prot.write_field_begin(&TFieldIdentifier::new("definition_level_histogram", TType::List, 3))?;
826      o_prot.write_list_begin(&TListIdentifier::new(TType::I64, fld_var.len() as i32))?;
827      for e in fld_var {
828        o_prot.write_i64(*e)?;
829      }
830      o_prot.write_list_end()?;
831      o_prot.write_field_end()?
832    }
833    o_prot.write_field_stop()?;
834    o_prot.write_struct_end()
835  }
836}
837
838//
839// BoundingBox
840//
841
842/// Bounding box for GEOMETRY or GEOGRAPHY type in the representation of min/max
843/// value pair of coordinates from each axis.
844#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
845pub struct BoundingBox {
846  pub xmin: OrderedFloat<f64>,
847  pub xmax: OrderedFloat<f64>,
848  pub ymin: OrderedFloat<f64>,
849  pub ymax: OrderedFloat<f64>,
850  pub zmin: Option<OrderedFloat<f64>>,
851  pub zmax: Option<OrderedFloat<f64>>,
852  pub mmin: Option<OrderedFloat<f64>>,
853  pub mmax: Option<OrderedFloat<f64>>,
854}
855
856impl BoundingBox {
857  pub fn new<F5, F6, F7, F8>(xmin: OrderedFloat<f64>, xmax: OrderedFloat<f64>, ymin: OrderedFloat<f64>, ymax: OrderedFloat<f64>, zmin: F5, zmax: F6, mmin: F7, mmax: F8) -> BoundingBox where F5: Into<Option<OrderedFloat<f64>>>, F6: Into<Option<OrderedFloat<f64>>>, F7: Into<Option<OrderedFloat<f64>>>, F8: Into<Option<OrderedFloat<f64>>> {
858    BoundingBox {
859      xmin,
860      xmax,
861      ymin,
862      ymax,
863      zmin: zmin.into(),
864      zmax: zmax.into(),
865      mmin: mmin.into(),
866      mmax: mmax.into(),
867    }
868  }
869}
870
871impl crate::thrift::TSerializable for BoundingBox {
872  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<BoundingBox> {
873    i_prot.read_struct_begin()?;
874    let mut f_1: Option<OrderedFloat<f64>> = None;
875    let mut f_2: Option<OrderedFloat<f64>> = None;
876    let mut f_3: Option<OrderedFloat<f64>> = None;
877    let mut f_4: Option<OrderedFloat<f64>> = None;
878    let mut f_5: Option<OrderedFloat<f64>> = None;
879    let mut f_6: Option<OrderedFloat<f64>> = None;
880    let mut f_7: Option<OrderedFloat<f64>> = None;
881    let mut f_8: Option<OrderedFloat<f64>> = None;
882    loop {
883      let field_ident = i_prot.read_field_begin()?;
884      if field_ident.field_type == TType::Stop {
885        break;
886      }
887      let field_id = field_id(&field_ident)?;
888      match field_id {
889        1 => {
890          let val = OrderedFloat::from(i_prot.read_double()?);
891          f_1 = Some(val);
892        },
893        2 => {
894          let val = OrderedFloat::from(i_prot.read_double()?);
895          f_2 = Some(val);
896        },
897        3 => {
898          let val = OrderedFloat::from(i_prot.read_double()?);
899          f_3 = Some(val);
900        },
901        4 => {
902          let val = OrderedFloat::from(i_prot.read_double()?);
903          f_4 = Some(val);
904        },
905        5 => {
906          let val = OrderedFloat::from(i_prot.read_double()?);
907          f_5 = Some(val);
908        },
909        6 => {
910          let val = OrderedFloat::from(i_prot.read_double()?);
911          f_6 = Some(val);
912        },
913        7 => {
914          let val = OrderedFloat::from(i_prot.read_double()?);
915          f_7 = Some(val);
916        },
917        8 => {
918          let val = OrderedFloat::from(i_prot.read_double()?);
919          f_8 = Some(val);
920        },
921        _ => {
922          i_prot.skip(field_ident.field_type)?;
923        },
924      };
925      i_prot.read_field_end()?;
926    }
927    i_prot.read_struct_end()?;
928    verify_required_field_exists("BoundingBox.xmin", &f_1)?;
929    verify_required_field_exists("BoundingBox.xmax", &f_2)?;
930    verify_required_field_exists("BoundingBox.ymin", &f_3)?;
931    verify_required_field_exists("BoundingBox.ymax", &f_4)?;
932    let ret = BoundingBox {
933      xmin: f_1.expect("auto-generated code should have checked for presence of required fields"),
934      xmax: f_2.expect("auto-generated code should have checked for presence of required fields"),
935      ymin: f_3.expect("auto-generated code should have checked for presence of required fields"),
936      ymax: f_4.expect("auto-generated code should have checked for presence of required fields"),
937      zmin: f_5,
938      zmax: f_6,
939      mmin: f_7,
940      mmax: f_8,
941    };
942    Ok(ret)
943  }
944  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
945    let struct_ident = TStructIdentifier::new("BoundingBox");
946    o_prot.write_struct_begin(&struct_ident)?;
947    o_prot.write_field_begin(&TFieldIdentifier::new("xmin", TType::Double, 1))?;
948    o_prot.write_double(self.xmin.into())?;
949    o_prot.write_field_end()?;
950    o_prot.write_field_begin(&TFieldIdentifier::new("xmax", TType::Double, 2))?;
951    o_prot.write_double(self.xmax.into())?;
952    o_prot.write_field_end()?;
953    o_prot.write_field_begin(&TFieldIdentifier::new("ymin", TType::Double, 3))?;
954    o_prot.write_double(self.ymin.into())?;
955    o_prot.write_field_end()?;
956    o_prot.write_field_begin(&TFieldIdentifier::new("ymax", TType::Double, 4))?;
957    o_prot.write_double(self.ymax.into())?;
958    o_prot.write_field_end()?;
959    if let Some(fld_var) = self.zmin {
960      o_prot.write_field_begin(&TFieldIdentifier::new("zmin", TType::Double, 5))?;
961      o_prot.write_double(fld_var.into())?;
962      o_prot.write_field_end()?
963    }
964    if let Some(fld_var) = self.zmax {
965      o_prot.write_field_begin(&TFieldIdentifier::new("zmax", TType::Double, 6))?;
966      o_prot.write_double(fld_var.into())?;
967      o_prot.write_field_end()?
968    }
969    if let Some(fld_var) = self.mmin {
970      o_prot.write_field_begin(&TFieldIdentifier::new("mmin", TType::Double, 7))?;
971      o_prot.write_double(fld_var.into())?;
972      o_prot.write_field_end()?
973    }
974    if let Some(fld_var) = self.mmax {
975      o_prot.write_field_begin(&TFieldIdentifier::new("mmax", TType::Double, 8))?;
976      o_prot.write_double(fld_var.into())?;
977      o_prot.write_field_end()?
978    }
979    o_prot.write_field_stop()?;
980    o_prot.write_struct_end()
981  }
982}
983
984//
985// GeospatialStatistics
986//
987
988/// Statistics specific to Geometry and Geography logical types
989#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
990pub struct GeospatialStatistics {
991  /// A bounding box of geospatial instances
992  pub bbox: Option<BoundingBox>,
993  /// Geospatial type codes of all instances, or an empty list if not known
994  pub geospatial_types: Option<Vec<i32>>,
995}
996
997impl GeospatialStatistics {
998  pub fn new<F1, F2>(bbox: F1, geospatial_types: F2) -> GeospatialStatistics where F1: Into<Option<BoundingBox>>, F2: Into<Option<Vec<i32>>> {
999    GeospatialStatistics {
1000      bbox: bbox.into(),
1001      geospatial_types: geospatial_types.into(),
1002    }
1003  }
1004}
1005
1006impl crate::thrift::TSerializable for GeospatialStatistics {
1007  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<GeospatialStatistics> {
1008    i_prot.read_struct_begin()?;
1009    let mut f_1: Option<BoundingBox> = None;
1010    let mut f_2: Option<Vec<i32>> = None;
1011    loop {
1012      let field_ident = i_prot.read_field_begin()?;
1013      if field_ident.field_type == TType::Stop {
1014        break;
1015      }
1016      let field_id = field_id(&field_ident)?;
1017      match field_id {
1018        1 => {
1019          let val = BoundingBox::read_from_in_protocol(i_prot)?;
1020          f_1 = Some(val);
1021        },
1022        2 => {
1023          let list_ident = i_prot.read_list_begin()?;
1024          let mut val: Vec<i32> = Vec::with_capacity(list_ident.size as usize);
1025          for _ in 0..list_ident.size {
1026            let list_elem_2 = i_prot.read_i32()?;
1027            val.push(list_elem_2);
1028          }
1029          i_prot.read_list_end()?;
1030          f_2 = Some(val);
1031        },
1032        _ => {
1033          i_prot.skip(field_ident.field_type)?;
1034        },
1035      };
1036      i_prot.read_field_end()?;
1037    }
1038    i_prot.read_struct_end()?;
1039    let ret = GeospatialStatistics {
1040      bbox: f_1,
1041      geospatial_types: f_2,
1042    };
1043    Ok(ret)
1044  }
1045  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1046    let struct_ident = TStructIdentifier::new("GeospatialStatistics");
1047    o_prot.write_struct_begin(&struct_ident)?;
1048    if let Some(ref fld_var) = self.bbox {
1049      o_prot.write_field_begin(&TFieldIdentifier::new("bbox", TType::Struct, 1))?;
1050      fld_var.write_to_out_protocol(o_prot)?;
1051      o_prot.write_field_end()?
1052    }
1053    if let Some(ref fld_var) = self.geospatial_types {
1054      o_prot.write_field_begin(&TFieldIdentifier::new("geospatial_types", TType::List, 2))?;
1055      o_prot.write_list_begin(&TListIdentifier::new(TType::I32, fld_var.len() as i32))?;
1056      for e in fld_var {
1057        o_prot.write_i32(*e)?;
1058      }
1059      o_prot.write_list_end()?;
1060      o_prot.write_field_end()?
1061    }
1062    o_prot.write_field_stop()?;
1063    o_prot.write_struct_end()
1064  }
1065}
1066
1067//
1068// Statistics
1069//
1070
1071/// Statistics per row group and per page
1072/// All fields are optional.
1073#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
1074pub struct Statistics {
1075  /// DEPRECATED: min and max value of the column. Use min_value and max_value.
1076  /// 
1077  /// Values are encoded using PLAIN encoding, except that variable-length byte
1078  /// arrays do not include a length prefix.
1079  /// 
1080  /// These fields encode min and max values determined by signed comparison
1081  /// only. New files should use the correct order for a column's logical type
1082  /// and store the values in the min_value and max_value fields.
1083  /// 
1084  /// To support older readers, these may be set when the column order is
1085  /// signed.
1086  pub max: Option<Vec<u8>>,
1087  pub min: Option<Vec<u8>>,
1088  /// Count of null values in the column.
1089  /// 
1090  /// Writers SHOULD always write this field even if it is zero (i.e. no null value)
1091  /// or the column is not nullable.
1092  /// Readers MUST distinguish between null_count not being present and null_count == 0.
1093  /// If null_count is not present, readers MUST NOT assume null_count == 0.
1094  pub null_count: Option<i64>,
1095  /// count of distinct values occurring
1096  pub distinct_count: Option<i64>,
1097  /// Lower and upper bound values for the column, determined by its ColumnOrder.
1098  /// 
1099  /// These may be the actual minimum and maximum values found on a page or column
1100  /// chunk, but can also be (more compact) values that do not exist on a page or
1101  /// column chunk. For example, instead of storing "Blart Versenwald III", a writer
1102  /// may set min_value="B", max_value="C". Such more compact values must still be
1103  /// valid values within the column's logical type.
1104  /// 
1105  /// Values are encoded using PLAIN encoding, except that variable-length byte
1106  /// arrays do not include a length prefix.
1107  pub max_value: Option<Vec<u8>>,
1108  pub min_value: Option<Vec<u8>>,
1109  /// If true, max_value is the actual maximum value for a column
1110  pub is_max_value_exact: Option<bool>,
1111  /// If true, min_value is the actual minimum value for a column
1112  pub is_min_value_exact: Option<bool>,
1113}
1114
1115impl Statistics {
1116  pub fn new<F1, F2, F3, F4, F5, F6, F7, F8>(max: F1, min: F2, null_count: F3, distinct_count: F4, max_value: F5, min_value: F6, is_max_value_exact: F7, is_min_value_exact: F8) -> Statistics where F1: Into<Option<Vec<u8>>>, F2: Into<Option<Vec<u8>>>, F3: Into<Option<i64>>, F4: Into<Option<i64>>, F5: Into<Option<Vec<u8>>>, F6: Into<Option<Vec<u8>>>, F7: Into<Option<bool>>, F8: Into<Option<bool>> {
1117    Statistics {
1118      max: max.into(),
1119      min: min.into(),
1120      null_count: null_count.into(),
1121      distinct_count: distinct_count.into(),
1122      max_value: max_value.into(),
1123      min_value: min_value.into(),
1124      is_max_value_exact: is_max_value_exact.into(),
1125      is_min_value_exact: is_min_value_exact.into(),
1126    }
1127  }
1128}
1129
1130impl crate::thrift::TSerializable for Statistics {
1131  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<Statistics> {
1132    i_prot.read_struct_begin()?;
1133    let mut f_1: Option<Vec<u8>> = None;
1134    let mut f_2: Option<Vec<u8>> = None;
1135    let mut f_3: Option<i64> = None;
1136    let mut f_4: Option<i64> = None;
1137    let mut f_5: Option<Vec<u8>> = None;
1138    let mut f_6: Option<Vec<u8>> = None;
1139    let mut f_7: Option<bool> = None;
1140    let mut f_8: Option<bool> = None;
1141    loop {
1142      let field_ident = i_prot.read_field_begin()?;
1143      if field_ident.field_type == TType::Stop {
1144        break;
1145      }
1146      let field_id = field_id(&field_ident)?;
1147      match field_id {
1148        1 => {
1149          let val = i_prot.read_bytes()?;
1150          f_1 = Some(val);
1151        },
1152        2 => {
1153          let val = i_prot.read_bytes()?;
1154          f_2 = Some(val);
1155        },
1156        3 => {
1157          let val = i_prot.read_i64()?;
1158          f_3 = Some(val);
1159        },
1160        4 => {
1161          let val = i_prot.read_i64()?;
1162          f_4 = Some(val);
1163        },
1164        5 => {
1165          let val = i_prot.read_bytes()?;
1166          f_5 = Some(val);
1167        },
1168        6 => {
1169          let val = i_prot.read_bytes()?;
1170          f_6 = Some(val);
1171        },
1172        7 => {
1173          let val = i_prot.read_bool()?;
1174          f_7 = Some(val);
1175        },
1176        8 => {
1177          let val = i_prot.read_bool()?;
1178          f_8 = Some(val);
1179        },
1180        _ => {
1181          i_prot.skip(field_ident.field_type)?;
1182        },
1183      };
1184      i_prot.read_field_end()?;
1185    }
1186    i_prot.read_struct_end()?;
1187    let ret = Statistics {
1188      max: f_1,
1189      min: f_2,
1190      null_count: f_3,
1191      distinct_count: f_4,
1192      max_value: f_5,
1193      min_value: f_6,
1194      is_max_value_exact: f_7,
1195      is_min_value_exact: f_8,
1196    };
1197    Ok(ret)
1198  }
1199  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1200    let struct_ident = TStructIdentifier::new("Statistics");
1201    o_prot.write_struct_begin(&struct_ident)?;
1202    if let Some(ref fld_var) = self.max {
1203      o_prot.write_field_begin(&TFieldIdentifier::new("max", TType::String, 1))?;
1204      o_prot.write_bytes(fld_var)?;
1205      o_prot.write_field_end()?
1206    }
1207    if let Some(ref fld_var) = self.min {
1208      o_prot.write_field_begin(&TFieldIdentifier::new("min", TType::String, 2))?;
1209      o_prot.write_bytes(fld_var)?;
1210      o_prot.write_field_end()?
1211    }
1212    if let Some(fld_var) = self.null_count {
1213      o_prot.write_field_begin(&TFieldIdentifier::new("null_count", TType::I64, 3))?;
1214      o_prot.write_i64(fld_var)?;
1215      o_prot.write_field_end()?
1216    }
1217    if let Some(fld_var) = self.distinct_count {
1218      o_prot.write_field_begin(&TFieldIdentifier::new("distinct_count", TType::I64, 4))?;
1219      o_prot.write_i64(fld_var)?;
1220      o_prot.write_field_end()?
1221    }
1222    if let Some(ref fld_var) = self.max_value {
1223      o_prot.write_field_begin(&TFieldIdentifier::new("max_value", TType::String, 5))?;
1224      o_prot.write_bytes(fld_var)?;
1225      o_prot.write_field_end()?
1226    }
1227    if let Some(ref fld_var) = self.min_value {
1228      o_prot.write_field_begin(&TFieldIdentifier::new("min_value", TType::String, 6))?;
1229      o_prot.write_bytes(fld_var)?;
1230      o_prot.write_field_end()?
1231    }
1232    if let Some(fld_var) = self.is_max_value_exact {
1233      o_prot.write_field_begin(&TFieldIdentifier::new("is_max_value_exact", TType::Bool, 7))?;
1234      o_prot.write_bool(fld_var)?;
1235      o_prot.write_field_end()?
1236    }
1237    if let Some(fld_var) = self.is_min_value_exact {
1238      o_prot.write_field_begin(&TFieldIdentifier::new("is_min_value_exact", TType::Bool, 8))?;
1239      o_prot.write_bool(fld_var)?;
1240      o_prot.write_field_end()?
1241    }
1242    o_prot.write_field_stop()?;
1243    o_prot.write_struct_end()
1244  }
1245}
1246
1247//
1248// StringType
1249//
1250
1251/// Empty structs to use as logical type annotations
1252#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
1253pub struct StringType {
1254}
1255
1256impl StringType {
1257  pub fn new() -> StringType {
1258    StringType {}
1259  }
1260}
1261
1262impl crate::thrift::TSerializable for StringType {
1263  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<StringType> {
1264    i_prot.read_struct_begin()?;
1265    loop {
1266      let field_ident = i_prot.read_field_begin()?;
1267      if field_ident.field_type == TType::Stop {
1268        break;
1269      }
1270      i_prot.skip(field_ident.field_type)?;
1271      i_prot.read_field_end()?;
1272    }
1273    i_prot.read_struct_end()?;
1274    let ret = StringType {};
1275    Ok(ret)
1276  }
1277  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1278    let struct_ident = TStructIdentifier::new("StringType");
1279    o_prot.write_struct_begin(&struct_ident)?;
1280    o_prot.write_field_stop()?;
1281    o_prot.write_struct_end()
1282  }
1283}
1284
1285//
1286// UUIDType
1287//
1288
1289#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
1290pub struct UUIDType {
1291}
1292
1293impl UUIDType {
1294  pub fn new() -> UUIDType {
1295    UUIDType {}
1296  }
1297}
1298
1299impl crate::thrift::TSerializable for UUIDType {
1300  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<UUIDType> {
1301    i_prot.read_struct_begin()?;
1302    loop {
1303      let field_ident = i_prot.read_field_begin()?;
1304      if field_ident.field_type == TType::Stop {
1305        break;
1306      }
1307      i_prot.skip(field_ident.field_type)?;
1308      i_prot.read_field_end()?;
1309    }
1310    i_prot.read_struct_end()?;
1311    let ret = UUIDType {};
1312    Ok(ret)
1313  }
1314  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1315    let struct_ident = TStructIdentifier::new("UUIDType");
1316    o_prot.write_struct_begin(&struct_ident)?;
1317    o_prot.write_field_stop()?;
1318    o_prot.write_struct_end()
1319  }
1320}
1321
1322//
1323// MapType
1324//
1325
1326#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
1327pub struct MapType {
1328}
1329
1330impl MapType {
1331  pub fn new() -> MapType {
1332    MapType {}
1333  }
1334}
1335
1336impl crate::thrift::TSerializable for MapType {
1337  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<MapType> {
1338    i_prot.read_struct_begin()?;
1339    loop {
1340      let field_ident = i_prot.read_field_begin()?;
1341      if field_ident.field_type == TType::Stop {
1342        break;
1343      }
1344      i_prot.skip(field_ident.field_type)?;
1345      i_prot.read_field_end()?;
1346    }
1347    i_prot.read_struct_end()?;
1348    let ret = MapType {};
1349    Ok(ret)
1350  }
1351  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1352    let struct_ident = TStructIdentifier::new("MapType");
1353    o_prot.write_struct_begin(&struct_ident)?;
1354    o_prot.write_field_stop()?;
1355    o_prot.write_struct_end()
1356  }
1357}
1358
1359//
1360// ListType
1361//
1362
1363#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
1364pub struct ListType {
1365}
1366
1367impl ListType {
1368  pub fn new() -> ListType {
1369    ListType {}
1370  }
1371}
1372
1373impl crate::thrift::TSerializable for ListType {
1374  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<ListType> {
1375    i_prot.read_struct_begin()?;
1376    loop {
1377      let field_ident = i_prot.read_field_begin()?;
1378      if field_ident.field_type == TType::Stop {
1379        break;
1380      }
1381      i_prot.skip(field_ident.field_type)?;
1382      i_prot.read_field_end()?;
1383    }
1384    i_prot.read_struct_end()?;
1385    let ret = ListType {};
1386    Ok(ret)
1387  }
1388  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1389    let struct_ident = TStructIdentifier::new("ListType");
1390    o_prot.write_struct_begin(&struct_ident)?;
1391    o_prot.write_field_stop()?;
1392    o_prot.write_struct_end()
1393  }
1394}
1395
1396//
1397// EnumType
1398//
1399
1400#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
1401pub struct EnumType {
1402}
1403
1404impl EnumType {
1405  pub fn new() -> EnumType {
1406    EnumType {}
1407  }
1408}
1409
1410impl crate::thrift::TSerializable for EnumType {
1411  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<EnumType> {
1412    i_prot.read_struct_begin()?;
1413    loop {
1414      let field_ident = i_prot.read_field_begin()?;
1415      if field_ident.field_type == TType::Stop {
1416        break;
1417      }
1418      i_prot.skip(field_ident.field_type)?;
1419      i_prot.read_field_end()?;
1420    }
1421    i_prot.read_struct_end()?;
1422    let ret = EnumType {};
1423    Ok(ret)
1424  }
1425  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1426    let struct_ident = TStructIdentifier::new("EnumType");
1427    o_prot.write_struct_begin(&struct_ident)?;
1428    o_prot.write_field_stop()?;
1429    o_prot.write_struct_end()
1430  }
1431}
1432
1433//
1434// DateType
1435//
1436
1437#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
1438pub struct DateType {
1439}
1440
1441impl DateType {
1442  pub fn new() -> DateType {
1443    DateType {}
1444  }
1445}
1446
1447impl crate::thrift::TSerializable for DateType {
1448  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<DateType> {
1449    i_prot.read_struct_begin()?;
1450    loop {
1451      let field_ident = i_prot.read_field_begin()?;
1452      if field_ident.field_type == TType::Stop {
1453        break;
1454      }
1455      i_prot.skip(field_ident.field_type)?;
1456      i_prot.read_field_end()?;
1457    }
1458    i_prot.read_struct_end()?;
1459    let ret = DateType {};
1460    Ok(ret)
1461  }
1462  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1463    let struct_ident = TStructIdentifier::new("DateType");
1464    o_prot.write_struct_begin(&struct_ident)?;
1465    o_prot.write_field_stop()?;
1466    o_prot.write_struct_end()
1467  }
1468}
1469
1470//
1471// Float16Type
1472//
1473
1474#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
1475pub struct Float16Type {
1476}
1477
1478impl Float16Type {
1479  pub fn new() -> Float16Type {
1480    Float16Type {}
1481  }
1482}
1483
1484impl crate::thrift::TSerializable for Float16Type {
1485  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<Float16Type> {
1486    i_prot.read_struct_begin()?;
1487    loop {
1488      let field_ident = i_prot.read_field_begin()?;
1489      if field_ident.field_type == TType::Stop {
1490        break;
1491      }
1492      i_prot.skip(field_ident.field_type)?;
1493      i_prot.read_field_end()?;
1494    }
1495    i_prot.read_struct_end()?;
1496    let ret = Float16Type {};
1497    Ok(ret)
1498  }
1499  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1500    let struct_ident = TStructIdentifier::new("Float16Type");
1501    o_prot.write_struct_begin(&struct_ident)?;
1502    o_prot.write_field_stop()?;
1503    o_prot.write_struct_end()
1504  }
1505}
1506
1507//
1508// NullType
1509//
1510
1511/// Logical type to annotate a column that is always null.
1512/// 
1513/// Sometimes when discovering the schema of existing data, values are always
1514/// null and the physical type can't be determined. This annotation signals
1515/// the case where the physical type was guessed from all null values.
1516#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
1517pub struct NullType {
1518}
1519
1520impl NullType {
1521  pub fn new() -> NullType {
1522    NullType {}
1523  }
1524}
1525
1526impl crate::thrift::TSerializable for NullType {
1527  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<NullType> {
1528    i_prot.read_struct_begin()?;
1529    loop {
1530      let field_ident = i_prot.read_field_begin()?;
1531      if field_ident.field_type == TType::Stop {
1532        break;
1533      }
1534      i_prot.skip(field_ident.field_type)?;
1535      i_prot.read_field_end()?;
1536    }
1537    i_prot.read_struct_end()?;
1538    let ret = NullType {};
1539    Ok(ret)
1540  }
1541  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1542    let struct_ident = TStructIdentifier::new("NullType");
1543    o_prot.write_struct_begin(&struct_ident)?;
1544    o_prot.write_field_stop()?;
1545    o_prot.write_struct_end()
1546  }
1547}
1548
1549//
1550// DecimalType
1551//
1552
1553/// Decimal logical type annotation
1554/// 
1555/// Scale must be zero or a positive integer less than or equal to the precision.
1556/// Precision must be a non-zero positive integer.
1557/// 
1558/// To maintain forward-compatibility in v1, implementations using this logical
1559/// type must also set scale and precision on the annotated SchemaElement.
1560/// 
1561/// Allowed for physical types: INT32, INT64, FIXED_LEN_BYTE_ARRAY, and BYTE_ARRAY.
1562#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1563pub struct DecimalType {
1564  pub scale: i32,
1565  pub precision: i32,
1566}
1567
1568impl DecimalType {
1569  pub fn new(scale: i32, precision: i32) -> DecimalType {
1570    DecimalType {
1571      scale,
1572      precision,
1573    }
1574  }
1575}
1576
1577impl crate::thrift::TSerializable for DecimalType {
1578  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<DecimalType> {
1579    i_prot.read_struct_begin()?;
1580    let mut f_1: Option<i32> = None;
1581    let mut f_2: Option<i32> = None;
1582    loop {
1583      let field_ident = i_prot.read_field_begin()?;
1584      if field_ident.field_type == TType::Stop {
1585        break;
1586      }
1587      let field_id = field_id(&field_ident)?;
1588      match field_id {
1589        1 => {
1590          let val = i_prot.read_i32()?;
1591          f_1 = Some(val);
1592        },
1593        2 => {
1594          let val = i_prot.read_i32()?;
1595          f_2 = Some(val);
1596        },
1597        _ => {
1598          i_prot.skip(field_ident.field_type)?;
1599        },
1600      };
1601      i_prot.read_field_end()?;
1602    }
1603    i_prot.read_struct_end()?;
1604    verify_required_field_exists("DecimalType.scale", &f_1)?;
1605    verify_required_field_exists("DecimalType.precision", &f_2)?;
1606    let ret = DecimalType {
1607      scale: f_1.expect("auto-generated code should have checked for presence of required fields"),
1608      precision: f_2.expect("auto-generated code should have checked for presence of required fields"),
1609    };
1610    Ok(ret)
1611  }
1612  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1613    let struct_ident = TStructIdentifier::new("DecimalType");
1614    o_prot.write_struct_begin(&struct_ident)?;
1615    o_prot.write_field_begin(&TFieldIdentifier::new("scale", TType::I32, 1))?;
1616    o_prot.write_i32(self.scale)?;
1617    o_prot.write_field_end()?;
1618    o_prot.write_field_begin(&TFieldIdentifier::new("precision", TType::I32, 2))?;
1619    o_prot.write_i32(self.precision)?;
1620    o_prot.write_field_end()?;
1621    o_prot.write_field_stop()?;
1622    o_prot.write_struct_end()
1623  }
1624}
1625
1626//
1627// MilliSeconds
1628//
1629
1630/// Time units for logical types
1631#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
1632pub struct MilliSeconds {
1633}
1634
1635impl MilliSeconds {
1636  pub fn new() -> MilliSeconds {
1637    MilliSeconds {}
1638  }
1639}
1640
1641impl crate::thrift::TSerializable for MilliSeconds {
1642  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<MilliSeconds> {
1643    i_prot.read_struct_begin()?;
1644    loop {
1645      let field_ident = i_prot.read_field_begin()?;
1646      if field_ident.field_type == TType::Stop {
1647        break;
1648      }
1649      i_prot.skip(field_ident.field_type)?;
1650      i_prot.read_field_end()?;
1651    }
1652    i_prot.read_struct_end()?;
1653    let ret = MilliSeconds {};
1654    Ok(ret)
1655  }
1656  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1657    let struct_ident = TStructIdentifier::new("MilliSeconds");
1658    o_prot.write_struct_begin(&struct_ident)?;
1659    o_prot.write_field_stop()?;
1660    o_prot.write_struct_end()
1661  }
1662}
1663
1664//
1665// MicroSeconds
1666//
1667
1668#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
1669pub struct MicroSeconds {
1670}
1671
1672impl MicroSeconds {
1673  pub fn new() -> MicroSeconds {
1674    MicroSeconds {}
1675  }
1676}
1677
1678impl crate::thrift::TSerializable for MicroSeconds {
1679  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<MicroSeconds> {
1680    i_prot.read_struct_begin()?;
1681    loop {
1682      let field_ident = i_prot.read_field_begin()?;
1683      if field_ident.field_type == TType::Stop {
1684        break;
1685      }
1686      i_prot.skip(field_ident.field_type)?;
1687      i_prot.read_field_end()?;
1688    }
1689    i_prot.read_struct_end()?;
1690    let ret = MicroSeconds {};
1691    Ok(ret)
1692  }
1693  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1694    let struct_ident = TStructIdentifier::new("MicroSeconds");
1695    o_prot.write_struct_begin(&struct_ident)?;
1696    o_prot.write_field_stop()?;
1697    o_prot.write_struct_end()
1698  }
1699}
1700
1701//
1702// NanoSeconds
1703//
1704
1705#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
1706pub struct NanoSeconds {
1707}
1708
1709impl NanoSeconds {
1710  pub fn new() -> NanoSeconds {
1711    NanoSeconds {}
1712  }
1713}
1714
1715impl crate::thrift::TSerializable for NanoSeconds {
1716  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<NanoSeconds> {
1717    i_prot.read_struct_begin()?;
1718    loop {
1719      let field_ident = i_prot.read_field_begin()?;
1720      if field_ident.field_type == TType::Stop {
1721        break;
1722      }
1723      i_prot.skip(field_ident.field_type)?;
1724      i_prot.read_field_end()?;
1725    }
1726    i_prot.read_struct_end()?;
1727    let ret = NanoSeconds {};
1728    Ok(ret)
1729  }
1730  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1731    let struct_ident = TStructIdentifier::new("NanoSeconds");
1732    o_prot.write_struct_begin(&struct_ident)?;
1733    o_prot.write_field_stop()?;
1734    o_prot.write_struct_end()
1735  }
1736}
1737
1738//
1739// TimeUnit
1740//
1741
1742#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1743pub enum TimeUnit {
1744  MILLIS(MilliSeconds),
1745  MICROS(MicroSeconds),
1746  NANOS(NanoSeconds),
1747}
1748
1749impl crate::thrift::TSerializable for TimeUnit {
1750  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<TimeUnit> {
1751    let mut ret: Option<TimeUnit> = None;
1752    let mut received_field_count = 0;
1753    i_prot.read_struct_begin()?;
1754    loop {
1755      let field_ident = i_prot.read_field_begin()?;
1756      if field_ident.field_type == TType::Stop {
1757        break;
1758      }
1759      let field_id = field_id(&field_ident)?;
1760      match field_id {
1761        1 => {
1762          let val = MilliSeconds::read_from_in_protocol(i_prot)?;
1763          if ret.is_none() {
1764            ret = Some(TimeUnit::MILLIS(val));
1765          }
1766          received_field_count += 1;
1767        },
1768        2 => {
1769          let val = MicroSeconds::read_from_in_protocol(i_prot)?;
1770          if ret.is_none() {
1771            ret = Some(TimeUnit::MICROS(val));
1772          }
1773          received_field_count += 1;
1774        },
1775        3 => {
1776          let val = NanoSeconds::read_from_in_protocol(i_prot)?;
1777          if ret.is_none() {
1778            ret = Some(TimeUnit::NANOS(val));
1779          }
1780          received_field_count += 1;
1781        },
1782        _ => {
1783          i_prot.skip(field_ident.field_type)?;
1784          received_field_count += 1;
1785        },
1786      };
1787      i_prot.read_field_end()?;
1788    }
1789    i_prot.read_struct_end()?;
1790    if received_field_count == 0 {
1791      Err(
1792        thrift::Error::Protocol(
1793          ProtocolError::new(
1794            ProtocolErrorKind::InvalidData,
1795            "received empty union from remote TimeUnit"
1796          )
1797        )
1798      )
1799    } else if received_field_count > 1 {
1800      Err(
1801        thrift::Error::Protocol(
1802          ProtocolError::new(
1803            ProtocolErrorKind::InvalidData,
1804            "received multiple fields for union from remote TimeUnit"
1805          )
1806        )
1807      )
1808    } else {
1809      ret.ok_or_else(|| thrift::Error::Protocol(ProtocolError::new(ProtocolErrorKind::InvalidData, "return value should have been constructed")))
1810    }
1811  }
1812  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1813    let struct_ident = TStructIdentifier::new("TimeUnit");
1814    o_prot.write_struct_begin(&struct_ident)?;
1815    match *self {
1816      TimeUnit::MILLIS(ref f) => {
1817        o_prot.write_field_begin(&TFieldIdentifier::new("MILLIS", TType::Struct, 1))?;
1818        f.write_to_out_protocol(o_prot)?;
1819        o_prot.write_field_end()?;
1820      },
1821      TimeUnit::MICROS(ref f) => {
1822        o_prot.write_field_begin(&TFieldIdentifier::new("MICROS", TType::Struct, 2))?;
1823        f.write_to_out_protocol(o_prot)?;
1824        o_prot.write_field_end()?;
1825      },
1826      TimeUnit::NANOS(ref f) => {
1827        o_prot.write_field_begin(&TFieldIdentifier::new("NANOS", TType::Struct, 3))?;
1828        f.write_to_out_protocol(o_prot)?;
1829        o_prot.write_field_end()?;
1830      },
1831    }
1832    o_prot.write_field_stop()?;
1833    o_prot.write_struct_end()
1834  }
1835}
1836
1837//
1838// TimestampType
1839//
1840
1841/// Timestamp logical type annotation
1842/// 
1843/// Allowed for physical types: INT64
1844#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1845pub struct TimestampType {
1846  pub is_adjusted_to_u_t_c: bool,
1847  pub unit: TimeUnit,
1848}
1849
1850impl TimestampType {
1851  pub fn new(is_adjusted_to_u_t_c: bool, unit: TimeUnit) -> TimestampType {
1852    TimestampType {
1853      is_adjusted_to_u_t_c,
1854      unit,
1855    }
1856  }
1857}
1858
1859impl crate::thrift::TSerializable for TimestampType {
1860  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<TimestampType> {
1861    i_prot.read_struct_begin()?;
1862    let mut f_1: Option<bool> = None;
1863    let mut f_2: Option<TimeUnit> = None;
1864    loop {
1865      let field_ident = i_prot.read_field_begin()?;
1866      if field_ident.field_type == TType::Stop {
1867        break;
1868      }
1869      let field_id = field_id(&field_ident)?;
1870      match field_id {
1871        1 => {
1872          let val = i_prot.read_bool()?;
1873          f_1 = Some(val);
1874        },
1875        2 => {
1876          let val = TimeUnit::read_from_in_protocol(i_prot)?;
1877          f_2 = Some(val);
1878        },
1879        _ => {
1880          i_prot.skip(field_ident.field_type)?;
1881        },
1882      };
1883      i_prot.read_field_end()?;
1884    }
1885    i_prot.read_struct_end()?;
1886    verify_required_field_exists("TimestampType.is_adjusted_to_u_t_c", &f_1)?;
1887    verify_required_field_exists("TimestampType.unit", &f_2)?;
1888    let ret = TimestampType {
1889      is_adjusted_to_u_t_c: f_1.expect("auto-generated code should have checked for presence of required fields"),
1890      unit: f_2.expect("auto-generated code should have checked for presence of required fields"),
1891    };
1892    Ok(ret)
1893  }
1894  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1895    let struct_ident = TStructIdentifier::new("TimestampType");
1896    o_prot.write_struct_begin(&struct_ident)?;
1897    o_prot.write_field_begin(&TFieldIdentifier::new("isAdjustedToUTC", TType::Bool, 1))?;
1898    o_prot.write_bool(self.is_adjusted_to_u_t_c)?;
1899    o_prot.write_field_end()?;
1900    o_prot.write_field_begin(&TFieldIdentifier::new("unit", TType::Struct, 2))?;
1901    self.unit.write_to_out_protocol(o_prot)?;
1902    o_prot.write_field_end()?;
1903    o_prot.write_field_stop()?;
1904    o_prot.write_struct_end()
1905  }
1906}
1907
1908//
1909// TimeType
1910//
1911
1912/// Time logical type annotation
1913/// 
1914/// Allowed for physical types: INT32 (millis), INT64 (micros, nanos)
1915#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1916pub struct TimeType {
1917  pub is_adjusted_to_u_t_c: bool,
1918  pub unit: TimeUnit,
1919}
1920
1921impl TimeType {
1922  pub fn new(is_adjusted_to_u_t_c: bool, unit: TimeUnit) -> TimeType {
1923    TimeType {
1924      is_adjusted_to_u_t_c,
1925      unit,
1926    }
1927  }
1928}
1929
1930impl crate::thrift::TSerializable for TimeType {
1931  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<TimeType> {
1932    i_prot.read_struct_begin()?;
1933    let mut f_1: Option<bool> = None;
1934    let mut f_2: Option<TimeUnit> = None;
1935    loop {
1936      let field_ident = i_prot.read_field_begin()?;
1937      if field_ident.field_type == TType::Stop {
1938        break;
1939      }
1940      let field_id = field_id(&field_ident)?;
1941      match field_id {
1942        1 => {
1943          let val = i_prot.read_bool()?;
1944          f_1 = Some(val);
1945        },
1946        2 => {
1947          let val = TimeUnit::read_from_in_protocol(i_prot)?;
1948          f_2 = Some(val);
1949        },
1950        _ => {
1951          i_prot.skip(field_ident.field_type)?;
1952        },
1953      };
1954      i_prot.read_field_end()?;
1955    }
1956    i_prot.read_struct_end()?;
1957    verify_required_field_exists("TimeType.is_adjusted_to_u_t_c", &f_1)?;
1958    verify_required_field_exists("TimeType.unit", &f_2)?;
1959    let ret = TimeType {
1960      is_adjusted_to_u_t_c: f_1.expect("auto-generated code should have checked for presence of required fields"),
1961      unit: f_2.expect("auto-generated code should have checked for presence of required fields"),
1962    };
1963    Ok(ret)
1964  }
1965  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
1966    let struct_ident = TStructIdentifier::new("TimeType");
1967    o_prot.write_struct_begin(&struct_ident)?;
1968    o_prot.write_field_begin(&TFieldIdentifier::new("isAdjustedToUTC", TType::Bool, 1))?;
1969    o_prot.write_bool(self.is_adjusted_to_u_t_c)?;
1970    o_prot.write_field_end()?;
1971    o_prot.write_field_begin(&TFieldIdentifier::new("unit", TType::Struct, 2))?;
1972    self.unit.write_to_out_protocol(o_prot)?;
1973    o_prot.write_field_end()?;
1974    o_prot.write_field_stop()?;
1975    o_prot.write_struct_end()
1976  }
1977}
1978
1979//
1980// IntType
1981//
1982
1983/// Integer logical type annotation
1984/// 
1985/// bitWidth must be 8, 16, 32, or 64.
1986/// 
1987/// Allowed for physical types: INT32, INT64
1988#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
1989pub struct IntType {
1990  pub bit_width: i8,
1991  pub is_signed: bool,
1992}
1993
1994impl IntType {
1995  pub fn new(bit_width: i8, is_signed: bool) -> IntType {
1996    IntType {
1997      bit_width,
1998      is_signed,
1999    }
2000  }
2001}
2002
2003impl crate::thrift::TSerializable for IntType {
2004  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<IntType> {
2005    i_prot.read_struct_begin()?;
2006    let mut f_1: Option<i8> = None;
2007    let mut f_2: Option<bool> = None;
2008    loop {
2009      let field_ident = i_prot.read_field_begin()?;
2010      if field_ident.field_type == TType::Stop {
2011        break;
2012      }
2013      let field_id = field_id(&field_ident)?;
2014      match field_id {
2015        1 => {
2016          let val = i_prot.read_i8()?;
2017          f_1 = Some(val);
2018        },
2019        2 => {
2020          let val = i_prot.read_bool()?;
2021          f_2 = Some(val);
2022        },
2023        _ => {
2024          i_prot.skip(field_ident.field_type)?;
2025        },
2026      };
2027      i_prot.read_field_end()?;
2028    }
2029    i_prot.read_struct_end()?;
2030    verify_required_field_exists("IntType.bit_width", &f_1)?;
2031    verify_required_field_exists("IntType.is_signed", &f_2)?;
2032    let ret = IntType {
2033      bit_width: f_1.expect("auto-generated code should have checked for presence of required fields"),
2034      is_signed: f_2.expect("auto-generated code should have checked for presence of required fields"),
2035    };
2036    Ok(ret)
2037  }
2038  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
2039    let struct_ident = TStructIdentifier::new("IntType");
2040    o_prot.write_struct_begin(&struct_ident)?;
2041    o_prot.write_field_begin(&TFieldIdentifier::new("bitWidth", TType::I08, 1))?;
2042    o_prot.write_i8(self.bit_width)?;
2043    o_prot.write_field_end()?;
2044    o_prot.write_field_begin(&TFieldIdentifier::new("isSigned", TType::Bool, 2))?;
2045    o_prot.write_bool(self.is_signed)?;
2046    o_prot.write_field_end()?;
2047    o_prot.write_field_stop()?;
2048    o_prot.write_struct_end()
2049  }
2050}
2051
2052//
2053// JsonType
2054//
2055
2056/// Embedded JSON logical type annotation
2057/// 
2058/// Allowed for physical types: BYTE_ARRAY
2059#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
2060pub struct JsonType {
2061}
2062
2063impl JsonType {
2064  pub fn new() -> JsonType {
2065    JsonType {}
2066  }
2067}
2068
2069impl crate::thrift::TSerializable for JsonType {
2070  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<JsonType> {
2071    i_prot.read_struct_begin()?;
2072    loop {
2073      let field_ident = i_prot.read_field_begin()?;
2074      if field_ident.field_type == TType::Stop {
2075        break;
2076      }
2077      i_prot.skip(field_ident.field_type)?;
2078      i_prot.read_field_end()?;
2079    }
2080    i_prot.read_struct_end()?;
2081    let ret = JsonType {};
2082    Ok(ret)
2083  }
2084  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
2085    let struct_ident = TStructIdentifier::new("JsonType");
2086    o_prot.write_struct_begin(&struct_ident)?;
2087    o_prot.write_field_stop()?;
2088    o_prot.write_struct_end()
2089  }
2090}
2091
2092//
2093// BsonType
2094//
2095
2096/// Embedded BSON logical type annotation
2097/// 
2098/// Allowed for physical types: BYTE_ARRAY
2099#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
2100pub struct BsonType {
2101}
2102
2103impl BsonType {
2104  pub fn new() -> BsonType {
2105    BsonType {}
2106  }
2107}
2108
2109impl crate::thrift::TSerializable for BsonType {
2110  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<BsonType> {
2111    i_prot.read_struct_begin()?;
2112    loop {
2113      let field_ident = i_prot.read_field_begin()?;
2114      if field_ident.field_type == TType::Stop {
2115        break;
2116      }
2117      i_prot.skip(field_ident.field_type)?;
2118      i_prot.read_field_end()?;
2119    }
2120    i_prot.read_struct_end()?;
2121    let ret = BsonType {};
2122    Ok(ret)
2123  }
2124  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
2125    let struct_ident = TStructIdentifier::new("BsonType");
2126    o_prot.write_struct_begin(&struct_ident)?;
2127    o_prot.write_field_stop()?;
2128    o_prot.write_struct_end()
2129  }
2130}
2131
2132//
2133// VariantType
2134//
2135
2136/// Embedded Variant logical type annotation
2137#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
2138pub struct VariantType {
2139  pub specification_version: Option<i8>,
2140}
2141
2142impl VariantType {
2143  pub fn new<F1>(specification_version: F1) -> VariantType where F1: Into<Option<i8>> {
2144    VariantType {
2145      specification_version: specification_version.into(),
2146    }
2147  }
2148}
2149
2150impl crate::thrift::TSerializable for VariantType {
2151  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<VariantType> {
2152    i_prot.read_struct_begin()?;
2153    let mut f_1: Option<i8> = None;
2154    loop {
2155      let field_ident = i_prot.read_field_begin()?;
2156      if field_ident.field_type == TType::Stop {
2157        break;
2158      }
2159      let field_id = field_id(&field_ident)?;
2160      match field_id {
2161        1 => {
2162          let val = i_prot.read_i8()?;
2163          f_1 = Some(val);
2164        },
2165        _ => {
2166          i_prot.skip(field_ident.field_type)?;
2167        },
2168      };
2169      i_prot.read_field_end()?;
2170    }
2171    i_prot.read_struct_end()?;
2172    let ret = VariantType {
2173      specification_version: f_1,
2174    };
2175    Ok(ret)
2176  }
2177  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
2178    let struct_ident = TStructIdentifier::new("VariantType");
2179    o_prot.write_struct_begin(&struct_ident)?;
2180    if let Some(fld_var) = self.specification_version {
2181      o_prot.write_field_begin(&TFieldIdentifier::new("specification_version", TType::I08, 1))?;
2182      o_prot.write_i8(fld_var)?;
2183      o_prot.write_field_end()?
2184    }
2185    o_prot.write_field_stop()?;
2186    o_prot.write_struct_end()
2187  }
2188}
2189
2190//
2191// GeometryType
2192//
2193
2194/// Embedded Geometry logical type annotation
2195/// 
2196/// Geospatial features in the Well-Known Binary (WKB) format and edges interpolation
2197/// is always linear/planar.
2198/// 
2199/// A custom CRS can be set by the crs field. If unset, it defaults to "OGC:CRS84",
2200/// which means that the geometries must be stored in longitude, latitude based on
2201/// the WGS84 datum.
2202/// 
2203/// Allowed for physical type: BYTE_ARRAY.
2204/// 
2205/// See Geospatial.md for details.
2206#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
2207pub struct GeometryType {
2208  pub crs: Option<String>,
2209}
2210
2211impl GeometryType {
2212  pub fn new<F1>(crs: F1) -> GeometryType where F1: Into<Option<String>> {
2213    GeometryType {
2214      crs: crs.into(),
2215    }
2216  }
2217}
2218
2219impl crate::thrift::TSerializable for GeometryType {
2220  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<GeometryType> {
2221    i_prot.read_struct_begin()?;
2222    let mut f_1: Option<String> = None;
2223    loop {
2224      let field_ident = i_prot.read_field_begin()?;
2225      if field_ident.field_type == TType::Stop {
2226        break;
2227      }
2228      let field_id = field_id(&field_ident)?;
2229      match field_id {
2230        1 => {
2231          let val = i_prot.read_string()?;
2232          f_1 = Some(val);
2233        },
2234        _ => {
2235          i_prot.skip(field_ident.field_type)?;
2236        },
2237      };
2238      i_prot.read_field_end()?;
2239    }
2240    i_prot.read_struct_end()?;
2241    let ret = GeometryType {
2242      crs: f_1,
2243    };
2244    Ok(ret)
2245  }
2246  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
2247    let struct_ident = TStructIdentifier::new("GeometryType");
2248    o_prot.write_struct_begin(&struct_ident)?;
2249    if let Some(ref fld_var) = self.crs {
2250      o_prot.write_field_begin(&TFieldIdentifier::new("crs", TType::String, 1))?;
2251      o_prot.write_string(fld_var)?;
2252      o_prot.write_field_end()?
2253    }
2254    o_prot.write_field_stop()?;
2255    o_prot.write_struct_end()
2256  }
2257}
2258
2259//
2260// GeographyType
2261//
2262
2263/// Embedded Geography logical type annotation
2264/// 
2265/// Geospatial features in the WKB format with an explicit (non-linear/non-planar)
2266/// edges interpolation algorithm.
2267/// 
2268/// A custom geographic CRS can be set by the crs field, where longitudes are
2269/// bound by [-180, 180] and latitudes are bound by [-90, 90]. If unset, the CRS
2270/// defaults to "OGC:CRS84".
2271/// 
2272/// An optional algorithm can be set to correctly interpret edges interpolation
2273/// of the geometries. If unset, the algorithm defaults to SPHERICAL.
2274/// 
2275/// Allowed for physical type: BYTE_ARRAY.
2276/// 
2277/// See Geospatial.md for details.
2278#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
2279pub struct GeographyType {
2280  pub crs: Option<String>,
2281  pub algorithm: Option<EdgeInterpolationAlgorithm>,
2282}
2283
2284impl GeographyType {
2285  pub fn new<F1, F2>(crs: F1, algorithm: F2) -> GeographyType where F1: Into<Option<String>>, F2: Into<Option<EdgeInterpolationAlgorithm>> {
2286    GeographyType {
2287      crs: crs.into(),
2288      algorithm: algorithm.into(),
2289    }
2290  }
2291}
2292
2293impl crate::thrift::TSerializable for GeographyType {
2294  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<GeographyType> {
2295    i_prot.read_struct_begin()?;
2296    let mut f_1: Option<String> = None;
2297    let mut f_2: Option<EdgeInterpolationAlgorithm> = None;
2298    loop {
2299      let field_ident = i_prot.read_field_begin()?;
2300      if field_ident.field_type == TType::Stop {
2301        break;
2302      }
2303      let field_id = field_id(&field_ident)?;
2304      match field_id {
2305        1 => {
2306          let val = i_prot.read_string()?;
2307          f_1 = Some(val);
2308        },
2309        2 => {
2310          let val = EdgeInterpolationAlgorithm::read_from_in_protocol(i_prot)?;
2311          f_2 = Some(val);
2312        },
2313        _ => {
2314          i_prot.skip(field_ident.field_type)?;
2315        },
2316      };
2317      i_prot.read_field_end()?;
2318    }
2319    i_prot.read_struct_end()?;
2320    let ret = GeographyType {
2321      crs: f_1,
2322      algorithm: f_2,
2323    };
2324    Ok(ret)
2325  }
2326  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
2327    let struct_ident = TStructIdentifier::new("GeographyType");
2328    o_prot.write_struct_begin(&struct_ident)?;
2329    if let Some(ref fld_var) = self.crs {
2330      o_prot.write_field_begin(&TFieldIdentifier::new("crs", TType::String, 1))?;
2331      o_prot.write_string(fld_var)?;
2332      o_prot.write_field_end()?
2333    }
2334    if let Some(ref fld_var) = self.algorithm {
2335      o_prot.write_field_begin(&TFieldIdentifier::new("algorithm", TType::I32, 2))?;
2336      fld_var.write_to_out_protocol(o_prot)?;
2337      o_prot.write_field_end()?
2338    }
2339    o_prot.write_field_stop()?;
2340    o_prot.write_struct_end()
2341  }
2342}
2343
2344//
2345// LogicalType
2346//
2347
2348#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
2349pub enum LogicalType {
2350  STRING(StringType),
2351  MAP(MapType),
2352  LIST(ListType),
2353  ENUM(EnumType),
2354  DECIMAL(DecimalType),
2355  DATE(DateType),
2356  TIME(TimeType),
2357  TIMESTAMP(TimestampType),
2358  INTEGER(IntType),
2359  UNKNOWN(NullType),
2360  JSON(JsonType),
2361  BSON(BsonType),
2362  UUID(UUIDType),
2363  FLOAT16(Float16Type),
2364  VARIANT(VariantType),
2365  GEOMETRY(GeometryType),
2366  GEOGRAPHY(GeographyType),
2367}
2368
2369impl crate::thrift::TSerializable for LogicalType {
2370  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<LogicalType> {
2371    let mut ret: Option<LogicalType> = None;
2372    let mut received_field_count = 0;
2373    i_prot.read_struct_begin()?;
2374    loop {
2375      let field_ident = i_prot.read_field_begin()?;
2376      if field_ident.field_type == TType::Stop {
2377        break;
2378      }
2379      let field_id = field_id(&field_ident)?;
2380      match field_id {
2381        1 => {
2382          let val = StringType::read_from_in_protocol(i_prot)?;
2383          if ret.is_none() {
2384            ret = Some(LogicalType::STRING(val));
2385          }
2386          received_field_count += 1;
2387        },
2388        2 => {
2389          let val = MapType::read_from_in_protocol(i_prot)?;
2390          if ret.is_none() {
2391            ret = Some(LogicalType::MAP(val));
2392          }
2393          received_field_count += 1;
2394        },
2395        3 => {
2396          let val = ListType::read_from_in_protocol(i_prot)?;
2397          if ret.is_none() {
2398            ret = Some(LogicalType::LIST(val));
2399          }
2400          received_field_count += 1;
2401        },
2402        4 => {
2403          let val = EnumType::read_from_in_protocol(i_prot)?;
2404          if ret.is_none() {
2405            ret = Some(LogicalType::ENUM(val));
2406          }
2407          received_field_count += 1;
2408        },
2409        5 => {
2410          let val = DecimalType::read_from_in_protocol(i_prot)?;
2411          if ret.is_none() {
2412            ret = Some(LogicalType::DECIMAL(val));
2413          }
2414          received_field_count += 1;
2415        },
2416        6 => {
2417          let val = DateType::read_from_in_protocol(i_prot)?;
2418          if ret.is_none() {
2419            ret = Some(LogicalType::DATE(val));
2420          }
2421          received_field_count += 1;
2422        },
2423        7 => {
2424          let val = TimeType::read_from_in_protocol(i_prot)?;
2425          if ret.is_none() {
2426            ret = Some(LogicalType::TIME(val));
2427          }
2428          received_field_count += 1;
2429        },
2430        8 => {
2431          let val = TimestampType::read_from_in_protocol(i_prot)?;
2432          if ret.is_none() {
2433            ret = Some(LogicalType::TIMESTAMP(val));
2434          }
2435          received_field_count += 1;
2436        },
2437        10 => {
2438          let val = IntType::read_from_in_protocol(i_prot)?;
2439          if ret.is_none() {
2440            ret = Some(LogicalType::INTEGER(val));
2441          }
2442          received_field_count += 1;
2443        },
2444        11 => {
2445          let val = NullType::read_from_in_protocol(i_prot)?;
2446          if ret.is_none() {
2447            ret = Some(LogicalType::UNKNOWN(val));
2448          }
2449          received_field_count += 1;
2450        },
2451        12 => {
2452          let val = JsonType::read_from_in_protocol(i_prot)?;
2453          if ret.is_none() {
2454            ret = Some(LogicalType::JSON(val));
2455          }
2456          received_field_count += 1;
2457        },
2458        13 => {
2459          let val = BsonType::read_from_in_protocol(i_prot)?;
2460          if ret.is_none() {
2461            ret = Some(LogicalType::BSON(val));
2462          }
2463          received_field_count += 1;
2464        },
2465        14 => {
2466          let val = UUIDType::read_from_in_protocol(i_prot)?;
2467          if ret.is_none() {
2468            ret = Some(LogicalType::UUID(val));
2469          }
2470          received_field_count += 1;
2471        },
2472        15 => {
2473          let val = Float16Type::read_from_in_protocol(i_prot)?;
2474          if ret.is_none() {
2475            ret = Some(LogicalType::FLOAT16(val));
2476          }
2477          received_field_count += 1;
2478        },
2479        16 => {
2480          let val = VariantType::read_from_in_protocol(i_prot)?;
2481          if ret.is_none() {
2482            ret = Some(LogicalType::VARIANT(val));
2483          }
2484          received_field_count += 1;
2485        },
2486        17 => {
2487          let val = GeometryType::read_from_in_protocol(i_prot)?;
2488          if ret.is_none() {
2489            ret = Some(LogicalType::GEOMETRY(val));
2490          }
2491          received_field_count += 1;
2492        },
2493        18 => {
2494          let val = GeographyType::read_from_in_protocol(i_prot)?;
2495          if ret.is_none() {
2496            ret = Some(LogicalType::GEOGRAPHY(val));
2497          }
2498          received_field_count += 1;
2499        },
2500        _ => {
2501          i_prot.skip(field_ident.field_type)?;
2502          received_field_count += 1;
2503        },
2504      };
2505      i_prot.read_field_end()?;
2506    }
2507    i_prot.read_struct_end()?;
2508    if received_field_count == 0 {
2509      Err(
2510        thrift::Error::Protocol(
2511          ProtocolError::new(
2512            ProtocolErrorKind::InvalidData,
2513            "received empty union from remote LogicalType"
2514          )
2515        )
2516      )
2517    } else if received_field_count > 1 {
2518      Err(
2519        thrift::Error::Protocol(
2520          ProtocolError::new(
2521            ProtocolErrorKind::InvalidData,
2522            "received multiple fields for union from remote LogicalType"
2523          )
2524        )
2525      )
2526    } else {
2527      ret.ok_or_else(|| thrift::Error::Protocol(ProtocolError::new(ProtocolErrorKind::InvalidData, "return value should have been constructed")))
2528    }
2529  }
2530  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
2531    let struct_ident = TStructIdentifier::new("LogicalType");
2532    o_prot.write_struct_begin(&struct_ident)?;
2533    match *self {
2534      LogicalType::STRING(ref f) => {
2535        o_prot.write_field_begin(&TFieldIdentifier::new("STRING", TType::Struct, 1))?;
2536        f.write_to_out_protocol(o_prot)?;
2537        o_prot.write_field_end()?;
2538      },
2539      LogicalType::MAP(ref f) => {
2540        o_prot.write_field_begin(&TFieldIdentifier::new("MAP", TType::Struct, 2))?;
2541        f.write_to_out_protocol(o_prot)?;
2542        o_prot.write_field_end()?;
2543      },
2544      LogicalType::LIST(ref f) => {
2545        o_prot.write_field_begin(&TFieldIdentifier::new("LIST", TType::Struct, 3))?;
2546        f.write_to_out_protocol(o_prot)?;
2547        o_prot.write_field_end()?;
2548      },
2549      LogicalType::ENUM(ref f) => {
2550        o_prot.write_field_begin(&TFieldIdentifier::new("ENUM", TType::Struct, 4))?;
2551        f.write_to_out_protocol(o_prot)?;
2552        o_prot.write_field_end()?;
2553      },
2554      LogicalType::DECIMAL(ref f) => {
2555        o_prot.write_field_begin(&TFieldIdentifier::new("DECIMAL", TType::Struct, 5))?;
2556        f.write_to_out_protocol(o_prot)?;
2557        o_prot.write_field_end()?;
2558      },
2559      LogicalType::DATE(ref f) => {
2560        o_prot.write_field_begin(&TFieldIdentifier::new("DATE", TType::Struct, 6))?;
2561        f.write_to_out_protocol(o_prot)?;
2562        o_prot.write_field_end()?;
2563      },
2564      LogicalType::TIME(ref f) => {
2565        o_prot.write_field_begin(&TFieldIdentifier::new("TIME", TType::Struct, 7))?;
2566        f.write_to_out_protocol(o_prot)?;
2567        o_prot.write_field_end()?;
2568      },
2569      LogicalType::TIMESTAMP(ref f) => {
2570        o_prot.write_field_begin(&TFieldIdentifier::new("TIMESTAMP", TType::Struct, 8))?;
2571        f.write_to_out_protocol(o_prot)?;
2572        o_prot.write_field_end()?;
2573      },
2574      LogicalType::INTEGER(ref f) => {
2575        o_prot.write_field_begin(&TFieldIdentifier::new("INTEGER", TType::Struct, 10))?;
2576        f.write_to_out_protocol(o_prot)?;
2577        o_prot.write_field_end()?;
2578      },
2579      LogicalType::UNKNOWN(ref f) => {
2580        o_prot.write_field_begin(&TFieldIdentifier::new("UNKNOWN", TType::Struct, 11))?;
2581        f.write_to_out_protocol(o_prot)?;
2582        o_prot.write_field_end()?;
2583      },
2584      LogicalType::JSON(ref f) => {
2585        o_prot.write_field_begin(&TFieldIdentifier::new("JSON", TType::Struct, 12))?;
2586        f.write_to_out_protocol(o_prot)?;
2587        o_prot.write_field_end()?;
2588      },
2589      LogicalType::BSON(ref f) => {
2590        o_prot.write_field_begin(&TFieldIdentifier::new("BSON", TType::Struct, 13))?;
2591        f.write_to_out_protocol(o_prot)?;
2592        o_prot.write_field_end()?;
2593      },
2594      LogicalType::UUID(ref f) => {
2595        o_prot.write_field_begin(&TFieldIdentifier::new("UUID", TType::Struct, 14))?;
2596        f.write_to_out_protocol(o_prot)?;
2597        o_prot.write_field_end()?;
2598      },
2599      LogicalType::FLOAT16(ref f) => {
2600        o_prot.write_field_begin(&TFieldIdentifier::new("FLOAT16", TType::Struct, 15))?;
2601        f.write_to_out_protocol(o_prot)?;
2602        o_prot.write_field_end()?;
2603      },
2604      LogicalType::VARIANT(ref f) => {
2605        o_prot.write_field_begin(&TFieldIdentifier::new("VARIANT", TType::Struct, 16))?;
2606        f.write_to_out_protocol(o_prot)?;
2607        o_prot.write_field_end()?;
2608      },
2609      LogicalType::GEOMETRY(ref f) => {
2610        o_prot.write_field_begin(&TFieldIdentifier::new("GEOMETRY", TType::Struct, 17))?;
2611        f.write_to_out_protocol(o_prot)?;
2612        o_prot.write_field_end()?;
2613      },
2614      LogicalType::GEOGRAPHY(ref f) => {
2615        o_prot.write_field_begin(&TFieldIdentifier::new("GEOGRAPHY", TType::Struct, 18))?;
2616        f.write_to_out_protocol(o_prot)?;
2617        o_prot.write_field_end()?;
2618      },
2619    }
2620    o_prot.write_field_stop()?;
2621    o_prot.write_struct_end()
2622  }
2623}
2624
2625//
2626// SchemaElement
2627//
2628
2629/// Represents a element inside a schema definition.
2630///  - if it is a group (inner node) then type is undefined and num_children is defined
2631///  - if it is a primitive type (leaf) then type is defined and num_children is undefined
2632/// the nodes are listed in depth first traversal order.
2633#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
2634pub struct SchemaElement {
2635  /// Data type for this field. Not set if the current element is a non-leaf node
2636  pub type_: Option<Type>,
2637  /// If type is FIXED_LEN_BYTE_ARRAY, this is the byte length of the values.
2638  /// Otherwise, if specified, this is the maximum bit length to store any of the values.
2639  /// (e.g. a low cardinality INT col could have this set to 3).  Note that this is
2640  /// in the schema, and therefore fixed for the entire file.
2641  pub type_length: Option<i32>,
2642  /// repetition of the field. The root of the schema does not have a repetition_type.
2643  /// All other nodes must have one
2644  pub repetition_type: Option<FieldRepetitionType>,
2645  /// Name of the field in the schema
2646  pub name: String,
2647  /// Nested fields.  Since thrift does not support nested fields,
2648  /// the nesting is flattened to a single list by a depth-first traversal.
2649  /// The children count is used to construct the nested relationship.
2650  /// This field is not set when the element is a primitive type
2651  pub num_children: Option<i32>,
2652  /// DEPRECATED: When the schema is the result of a conversion from another model.
2653  /// Used to record the original type to help with cross conversion.
2654  /// 
2655  /// This is superseded by logicalType.
2656  pub converted_type: Option<ConvertedType>,
2657  /// DEPRECATED: Used when this column contains decimal data.
2658  /// See the DECIMAL converted type for more details.
2659  /// 
2660  /// This is superseded by using the DecimalType annotation in logicalType.
2661  pub scale: Option<i32>,
2662  pub precision: Option<i32>,
2663  /// When the original schema supports field ids, this will save the
2664  /// original field id in the parquet schema
2665  pub field_id: Option<i32>,
2666  /// The logical type of this SchemaElement
2667  /// 
2668  /// LogicalType replaces ConvertedType, but ConvertedType is still required
2669  /// for some logical types to ensure forward-compatibility in format v1.
2670  pub logical_type: Option<LogicalType>,
2671}
2672
2673impl SchemaElement {
2674  pub fn new<F1, F2, F3, F5, F6, F7, F8, F9, F10>(type_: F1, type_length: F2, repetition_type: F3, name: String, num_children: F5, converted_type: F6, scale: F7, precision: F8, field_id: F9, logical_type: F10) -> SchemaElement where F1: Into<Option<Type>>, F2: Into<Option<i32>>, F3: Into<Option<FieldRepetitionType>>, F5: Into<Option<i32>>, F6: Into<Option<ConvertedType>>, F7: Into<Option<i32>>, F8: Into<Option<i32>>, F9: Into<Option<i32>>, F10: Into<Option<LogicalType>> {
2675    SchemaElement {
2676      type_: type_.into(),
2677      type_length: type_length.into(),
2678      repetition_type: repetition_type.into(),
2679      name,
2680      num_children: num_children.into(),
2681      converted_type: converted_type.into(),
2682      scale: scale.into(),
2683      precision: precision.into(),
2684      field_id: field_id.into(),
2685      logical_type: logical_type.into(),
2686    }
2687  }
2688}
2689
2690impl crate::thrift::TSerializable for SchemaElement {
2691  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<SchemaElement> {
2692    i_prot.read_struct_begin()?;
2693    let mut f_1: Option<Type> = None;
2694    let mut f_2: Option<i32> = None;
2695    let mut f_3: Option<FieldRepetitionType> = None;
2696    let mut f_4: Option<String> = None;
2697    let mut f_5: Option<i32> = None;
2698    let mut f_6: Option<ConvertedType> = None;
2699    let mut f_7: Option<i32> = None;
2700    let mut f_8: Option<i32> = None;
2701    let mut f_9: Option<i32> = None;
2702    let mut f_10: Option<LogicalType> = None;
2703    loop {
2704      let field_ident = i_prot.read_field_begin()?;
2705      if field_ident.field_type == TType::Stop {
2706        break;
2707      }
2708      let field_id = field_id(&field_ident)?;
2709      match field_id {
2710        1 => {
2711          let val = Type::read_from_in_protocol(i_prot)?;
2712          f_1 = Some(val);
2713        },
2714        2 => {
2715          let val = i_prot.read_i32()?;
2716          f_2 = Some(val);
2717        },
2718        3 => {
2719          let val = FieldRepetitionType::read_from_in_protocol(i_prot)?;
2720          f_3 = Some(val);
2721        },
2722        4 => {
2723          let val = i_prot.read_string()?;
2724          f_4 = Some(val);
2725        },
2726        5 => {
2727          let val = i_prot.read_i32()?;
2728          f_5 = Some(val);
2729        },
2730        6 => {
2731          let val = ConvertedType::read_from_in_protocol(i_prot)?;
2732          f_6 = Some(val);
2733        },
2734        7 => {
2735          let val = i_prot.read_i32()?;
2736          f_7 = Some(val);
2737        },
2738        8 => {
2739          let val = i_prot.read_i32()?;
2740          f_8 = Some(val);
2741        },
2742        9 => {
2743          let val = i_prot.read_i32()?;
2744          f_9 = Some(val);
2745        },
2746        10 => {
2747          let val = LogicalType::read_from_in_protocol(i_prot)?;
2748          f_10 = Some(val);
2749        },
2750        _ => {
2751          i_prot.skip(field_ident.field_type)?;
2752        },
2753      };
2754      i_prot.read_field_end()?;
2755    }
2756    i_prot.read_struct_end()?;
2757    verify_required_field_exists("SchemaElement.name", &f_4)?;
2758    let ret = SchemaElement {
2759      type_: f_1,
2760      type_length: f_2,
2761      repetition_type: f_3,
2762      name: f_4.expect("auto-generated code should have checked for presence of required fields"),
2763      num_children: f_5,
2764      converted_type: f_6,
2765      scale: f_7,
2766      precision: f_8,
2767      field_id: f_9,
2768      logical_type: f_10,
2769    };
2770    Ok(ret)
2771  }
2772  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
2773    let struct_ident = TStructIdentifier::new("SchemaElement");
2774    o_prot.write_struct_begin(&struct_ident)?;
2775    if let Some(ref fld_var) = self.type_ {
2776      o_prot.write_field_begin(&TFieldIdentifier::new("type", TType::I32, 1))?;
2777      fld_var.write_to_out_protocol(o_prot)?;
2778      o_prot.write_field_end()?
2779    }
2780    if let Some(fld_var) = self.type_length {
2781      o_prot.write_field_begin(&TFieldIdentifier::new("type_length", TType::I32, 2))?;
2782      o_prot.write_i32(fld_var)?;
2783      o_prot.write_field_end()?
2784    }
2785    if let Some(ref fld_var) = self.repetition_type {
2786      o_prot.write_field_begin(&TFieldIdentifier::new("repetition_type", TType::I32, 3))?;
2787      fld_var.write_to_out_protocol(o_prot)?;
2788      o_prot.write_field_end()?
2789    }
2790    o_prot.write_field_begin(&TFieldIdentifier::new("name", TType::String, 4))?;
2791    o_prot.write_string(&self.name)?;
2792    o_prot.write_field_end()?;
2793    if let Some(fld_var) = self.num_children {
2794      o_prot.write_field_begin(&TFieldIdentifier::new("num_children", TType::I32, 5))?;
2795      o_prot.write_i32(fld_var)?;
2796      o_prot.write_field_end()?
2797    }
2798    if let Some(ref fld_var) = self.converted_type {
2799      o_prot.write_field_begin(&TFieldIdentifier::new("converted_type", TType::I32, 6))?;
2800      fld_var.write_to_out_protocol(o_prot)?;
2801      o_prot.write_field_end()?
2802    }
2803    if let Some(fld_var) = self.scale {
2804      o_prot.write_field_begin(&TFieldIdentifier::new("scale", TType::I32, 7))?;
2805      o_prot.write_i32(fld_var)?;
2806      o_prot.write_field_end()?
2807    }
2808    if let Some(fld_var) = self.precision {
2809      o_prot.write_field_begin(&TFieldIdentifier::new("precision", TType::I32, 8))?;
2810      o_prot.write_i32(fld_var)?;
2811      o_prot.write_field_end()?
2812    }
2813    if let Some(fld_var) = self.field_id {
2814      o_prot.write_field_begin(&TFieldIdentifier::new("field_id", TType::I32, 9))?;
2815      o_prot.write_i32(fld_var)?;
2816      o_prot.write_field_end()?
2817    }
2818    if let Some(ref fld_var) = self.logical_type {
2819      o_prot.write_field_begin(&TFieldIdentifier::new("logicalType", TType::Struct, 10))?;
2820      fld_var.write_to_out_protocol(o_prot)?;
2821      o_prot.write_field_end()?
2822    }
2823    o_prot.write_field_stop()?;
2824    o_prot.write_struct_end()
2825  }
2826}
2827
2828//
2829// DataPageHeader
2830//
2831
2832/// Data page header
2833#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
2834pub struct DataPageHeader {
2835  /// Number of values, including NULLs, in this data page.
2836  /// 
2837  /// If a OffsetIndex is present, a page must begin at a row
2838  /// boundary (repetition_level = 0). Otherwise, pages may begin
2839  /// within a row (repetition_level > 0).
2840  /// 
2841  pub num_values: i32,
2842  /// Encoding used for this data page *
2843  pub encoding: Encoding,
2844  /// Encoding used for definition levels *
2845  pub definition_level_encoding: Encoding,
2846  /// Encoding used for repetition levels *
2847  pub repetition_level_encoding: Encoding,
2848  /// Optional statistics for the data in this page *
2849  pub statistics: Option<Statistics>,
2850}
2851
2852impl DataPageHeader {
2853  pub fn new<F5>(num_values: i32, encoding: Encoding, definition_level_encoding: Encoding, repetition_level_encoding: Encoding, statistics: F5) -> DataPageHeader where F5: Into<Option<Statistics>> {
2854    DataPageHeader {
2855      num_values,
2856      encoding,
2857      definition_level_encoding,
2858      repetition_level_encoding,
2859      statistics: statistics.into(),
2860    }
2861  }
2862}
2863
2864impl crate::thrift::TSerializable for DataPageHeader {
2865  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<DataPageHeader> {
2866    i_prot.read_struct_begin()?;
2867    let mut f_1: Option<i32> = None;
2868    let mut f_2: Option<Encoding> = None;
2869    let mut f_3: Option<Encoding> = None;
2870    let mut f_4: Option<Encoding> = None;
2871    let mut f_5: Option<Statistics> = None;
2872    loop {
2873      let field_ident = i_prot.read_field_begin()?;
2874      if field_ident.field_type == TType::Stop {
2875        break;
2876      }
2877      let field_id = field_id(&field_ident)?;
2878      match field_id {
2879        1 => {
2880          let val = i_prot.read_i32()?;
2881          f_1 = Some(val);
2882        },
2883        2 => {
2884          let val = Encoding::read_from_in_protocol(i_prot)?;
2885          f_2 = Some(val);
2886        },
2887        3 => {
2888          let val = Encoding::read_from_in_protocol(i_prot)?;
2889          f_3 = Some(val);
2890        },
2891        4 => {
2892          let val = Encoding::read_from_in_protocol(i_prot)?;
2893          f_4 = Some(val);
2894        },
2895        5 => {
2896          let val = Statistics::read_from_in_protocol(i_prot)?;
2897          f_5 = Some(val);
2898        },
2899        _ => {
2900          i_prot.skip(field_ident.field_type)?;
2901        },
2902      };
2903      i_prot.read_field_end()?;
2904    }
2905    i_prot.read_struct_end()?;
2906    verify_required_field_exists("DataPageHeader.num_values", &f_1)?;
2907    verify_required_field_exists("DataPageHeader.encoding", &f_2)?;
2908    verify_required_field_exists("DataPageHeader.definition_level_encoding", &f_3)?;
2909    verify_required_field_exists("DataPageHeader.repetition_level_encoding", &f_4)?;
2910    let ret = DataPageHeader {
2911      num_values: f_1.expect("auto-generated code should have checked for presence of required fields"),
2912      encoding: f_2.expect("auto-generated code should have checked for presence of required fields"),
2913      definition_level_encoding: f_3.expect("auto-generated code should have checked for presence of required fields"),
2914      repetition_level_encoding: f_4.expect("auto-generated code should have checked for presence of required fields"),
2915      statistics: f_5,
2916    };
2917    Ok(ret)
2918  }
2919  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
2920    let struct_ident = TStructIdentifier::new("DataPageHeader");
2921    o_prot.write_struct_begin(&struct_ident)?;
2922    o_prot.write_field_begin(&TFieldIdentifier::new("num_values", TType::I32, 1))?;
2923    o_prot.write_i32(self.num_values)?;
2924    o_prot.write_field_end()?;
2925    o_prot.write_field_begin(&TFieldIdentifier::new("encoding", TType::I32, 2))?;
2926    self.encoding.write_to_out_protocol(o_prot)?;
2927    o_prot.write_field_end()?;
2928    o_prot.write_field_begin(&TFieldIdentifier::new("definition_level_encoding", TType::I32, 3))?;
2929    self.definition_level_encoding.write_to_out_protocol(o_prot)?;
2930    o_prot.write_field_end()?;
2931    o_prot.write_field_begin(&TFieldIdentifier::new("repetition_level_encoding", TType::I32, 4))?;
2932    self.repetition_level_encoding.write_to_out_protocol(o_prot)?;
2933    o_prot.write_field_end()?;
2934    if let Some(ref fld_var) = self.statistics {
2935      o_prot.write_field_begin(&TFieldIdentifier::new("statistics", TType::Struct, 5))?;
2936      fld_var.write_to_out_protocol(o_prot)?;
2937      o_prot.write_field_end()?
2938    }
2939    o_prot.write_field_stop()?;
2940    o_prot.write_struct_end()
2941  }
2942}
2943
2944//
2945// IndexPageHeader
2946//
2947
2948#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
2949pub struct IndexPageHeader {
2950}
2951
2952impl IndexPageHeader {
2953  pub fn new() -> IndexPageHeader {
2954    IndexPageHeader {}
2955  }
2956}
2957
2958impl crate::thrift::TSerializable for IndexPageHeader {
2959  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<IndexPageHeader> {
2960    i_prot.read_struct_begin()?;
2961    loop {
2962      let field_ident = i_prot.read_field_begin()?;
2963      if field_ident.field_type == TType::Stop {
2964        break;
2965      }
2966      i_prot.skip(field_ident.field_type)?;
2967      i_prot.read_field_end()?;
2968    }
2969    i_prot.read_struct_end()?;
2970    let ret = IndexPageHeader {};
2971    Ok(ret)
2972  }
2973  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
2974    let struct_ident = TStructIdentifier::new("IndexPageHeader");
2975    o_prot.write_struct_begin(&struct_ident)?;
2976    o_prot.write_field_stop()?;
2977    o_prot.write_struct_end()
2978  }
2979}
2980
2981//
2982// DictionaryPageHeader
2983//
2984
2985/// The dictionary page must be placed at the first position of the column chunk
2986/// if it is partly or completely dictionary encoded. At most one dictionary page
2987/// can be placed in a column chunk.
2988/// 
2989#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
2990pub struct DictionaryPageHeader {
2991  /// Number of values in the dictionary *
2992  pub num_values: i32,
2993  /// Encoding using this dictionary page *
2994  pub encoding: Encoding,
2995  /// If true, the entries in the dictionary are sorted in ascending order *
2996  pub is_sorted: Option<bool>,
2997}
2998
2999impl DictionaryPageHeader {
3000  pub fn new<F3>(num_values: i32, encoding: Encoding, is_sorted: F3) -> DictionaryPageHeader where F3: Into<Option<bool>> {
3001    DictionaryPageHeader {
3002      num_values,
3003      encoding,
3004      is_sorted: is_sorted.into(),
3005    }
3006  }
3007}
3008
3009impl crate::thrift::TSerializable for DictionaryPageHeader {
3010  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<DictionaryPageHeader> {
3011    i_prot.read_struct_begin()?;
3012    let mut f_1: Option<i32> = None;
3013    let mut f_2: Option<Encoding> = None;
3014    let mut f_3: Option<bool> = None;
3015    loop {
3016      let field_ident = i_prot.read_field_begin()?;
3017      if field_ident.field_type == TType::Stop {
3018        break;
3019      }
3020      let field_id = field_id(&field_ident)?;
3021      match field_id {
3022        1 => {
3023          let val = i_prot.read_i32()?;
3024          f_1 = Some(val);
3025        },
3026        2 => {
3027          let val = Encoding::read_from_in_protocol(i_prot)?;
3028          f_2 = Some(val);
3029        },
3030        3 => {
3031          let val = i_prot.read_bool()?;
3032          f_3 = Some(val);
3033        },
3034        _ => {
3035          i_prot.skip(field_ident.field_type)?;
3036        },
3037      };
3038      i_prot.read_field_end()?;
3039    }
3040    i_prot.read_struct_end()?;
3041    verify_required_field_exists("DictionaryPageHeader.num_values", &f_1)?;
3042    verify_required_field_exists("DictionaryPageHeader.encoding", &f_2)?;
3043    let ret = DictionaryPageHeader {
3044      num_values: f_1.expect("auto-generated code should have checked for presence of required fields"),
3045      encoding: f_2.expect("auto-generated code should have checked for presence of required fields"),
3046      is_sorted: f_3,
3047    };
3048    Ok(ret)
3049  }
3050  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
3051    let struct_ident = TStructIdentifier::new("DictionaryPageHeader");
3052    o_prot.write_struct_begin(&struct_ident)?;
3053    o_prot.write_field_begin(&TFieldIdentifier::new("num_values", TType::I32, 1))?;
3054    o_prot.write_i32(self.num_values)?;
3055    o_prot.write_field_end()?;
3056    o_prot.write_field_begin(&TFieldIdentifier::new("encoding", TType::I32, 2))?;
3057    self.encoding.write_to_out_protocol(o_prot)?;
3058    o_prot.write_field_end()?;
3059    if let Some(fld_var) = self.is_sorted {
3060      o_prot.write_field_begin(&TFieldIdentifier::new("is_sorted", TType::Bool, 3))?;
3061      o_prot.write_bool(fld_var)?;
3062      o_prot.write_field_end()?
3063    }
3064    o_prot.write_field_stop()?;
3065    o_prot.write_struct_end()
3066  }
3067}
3068
3069//
3070// DataPageHeaderV2
3071//
3072
3073/// New page format allowing reading levels without decompressing the data
3074/// Repetition and definition levels are uncompressed
3075/// The remaining section containing the data is compressed if is_compressed is true
3076/// 
3077#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3078pub struct DataPageHeaderV2 {
3079  /// Number of values, including NULLs, in this data page. *
3080  pub num_values: i32,
3081  /// Number of NULL values, in this data page.
3082  /// Number of non-null = num_values - num_nulls which is also the number of values in the data section *
3083  pub num_nulls: i32,
3084  /// Number of rows in this data page. Every page must begin at a
3085  /// row boundary (repetition_level = 0): rows must **not** be
3086  /// split across page boundaries when using V2 data pages.
3087  /// 
3088  pub num_rows: i32,
3089  /// Encoding used for data in this page *
3090  pub encoding: Encoding,
3091  /// Length of the definition levels
3092  pub definition_levels_byte_length: i32,
3093  /// Length of the repetition levels
3094  pub repetition_levels_byte_length: i32,
3095  /// Whether the values are compressed.
3096  /// Which means the section of the page between
3097  /// definition_levels_byte_length + repetition_levels_byte_length + 1 and compressed_page_size (included)
3098  /// is compressed with the compression_codec.
3099  /// If missing it is considered compressed
3100  pub is_compressed: Option<bool>,
3101  /// Optional statistics for the data in this page *
3102  pub statistics: Option<Statistics>,
3103}
3104
3105impl DataPageHeaderV2 {
3106  pub fn new<F7, F8>(num_values: i32, num_nulls: i32, num_rows: i32, encoding: Encoding, definition_levels_byte_length: i32, repetition_levels_byte_length: i32, is_compressed: F7, statistics: F8) -> DataPageHeaderV2 where F7: Into<Option<bool>>, F8: Into<Option<Statistics>> {
3107    DataPageHeaderV2 {
3108      num_values,
3109      num_nulls,
3110      num_rows,
3111      encoding,
3112      definition_levels_byte_length,
3113      repetition_levels_byte_length,
3114      is_compressed: is_compressed.into(),
3115      statistics: statistics.into(),
3116    }
3117  }
3118}
3119
3120impl crate::thrift::TSerializable for DataPageHeaderV2 {
3121  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<DataPageHeaderV2> {
3122    i_prot.read_struct_begin()?;
3123    let mut f_1: Option<i32> = None;
3124    let mut f_2: Option<i32> = None;
3125    let mut f_3: Option<i32> = None;
3126    let mut f_4: Option<Encoding> = None;
3127    let mut f_5: Option<i32> = None;
3128    let mut f_6: Option<i32> = None;
3129    let mut f_7: Option<bool> = None;
3130    let mut f_8: Option<Statistics> = None;
3131    loop {
3132      let field_ident = i_prot.read_field_begin()?;
3133      if field_ident.field_type == TType::Stop {
3134        break;
3135      }
3136      let field_id = field_id(&field_ident)?;
3137      match field_id {
3138        1 => {
3139          let val = i_prot.read_i32()?;
3140          f_1 = Some(val);
3141        },
3142        2 => {
3143          let val = i_prot.read_i32()?;
3144          f_2 = Some(val);
3145        },
3146        3 => {
3147          let val = i_prot.read_i32()?;
3148          f_3 = Some(val);
3149        },
3150        4 => {
3151          let val = Encoding::read_from_in_protocol(i_prot)?;
3152          f_4 = Some(val);
3153        },
3154        5 => {
3155          let val = i_prot.read_i32()?;
3156          f_5 = Some(val);
3157        },
3158        6 => {
3159          let val = i_prot.read_i32()?;
3160          f_6 = Some(val);
3161        },
3162        7 => {
3163          let val = i_prot.read_bool()?;
3164          f_7 = Some(val);
3165        },
3166        8 => {
3167          let val = Statistics::read_from_in_protocol(i_prot)?;
3168          f_8 = Some(val);
3169        },
3170        _ => {
3171          i_prot.skip(field_ident.field_type)?;
3172        },
3173      };
3174      i_prot.read_field_end()?;
3175    }
3176    i_prot.read_struct_end()?;
3177    verify_required_field_exists("DataPageHeaderV2.num_values", &f_1)?;
3178    verify_required_field_exists("DataPageHeaderV2.num_nulls", &f_2)?;
3179    verify_required_field_exists("DataPageHeaderV2.num_rows", &f_3)?;
3180    verify_required_field_exists("DataPageHeaderV2.encoding", &f_4)?;
3181    verify_required_field_exists("DataPageHeaderV2.definition_levels_byte_length", &f_5)?;
3182    verify_required_field_exists("DataPageHeaderV2.repetition_levels_byte_length", &f_6)?;
3183    let ret = DataPageHeaderV2 {
3184      num_values: f_1.expect("auto-generated code should have checked for presence of required fields"),
3185      num_nulls: f_2.expect("auto-generated code should have checked for presence of required fields"),
3186      num_rows: f_3.expect("auto-generated code should have checked for presence of required fields"),
3187      encoding: f_4.expect("auto-generated code should have checked for presence of required fields"),
3188      definition_levels_byte_length: f_5.expect("auto-generated code should have checked for presence of required fields"),
3189      repetition_levels_byte_length: f_6.expect("auto-generated code should have checked for presence of required fields"),
3190      is_compressed: f_7,
3191      statistics: f_8,
3192    };
3193    Ok(ret)
3194  }
3195  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
3196    let struct_ident = TStructIdentifier::new("DataPageHeaderV2");
3197    o_prot.write_struct_begin(&struct_ident)?;
3198    o_prot.write_field_begin(&TFieldIdentifier::new("num_values", TType::I32, 1))?;
3199    o_prot.write_i32(self.num_values)?;
3200    o_prot.write_field_end()?;
3201    o_prot.write_field_begin(&TFieldIdentifier::new("num_nulls", TType::I32, 2))?;
3202    o_prot.write_i32(self.num_nulls)?;
3203    o_prot.write_field_end()?;
3204    o_prot.write_field_begin(&TFieldIdentifier::new("num_rows", TType::I32, 3))?;
3205    o_prot.write_i32(self.num_rows)?;
3206    o_prot.write_field_end()?;
3207    o_prot.write_field_begin(&TFieldIdentifier::new("encoding", TType::I32, 4))?;
3208    self.encoding.write_to_out_protocol(o_prot)?;
3209    o_prot.write_field_end()?;
3210    o_prot.write_field_begin(&TFieldIdentifier::new("definition_levels_byte_length", TType::I32, 5))?;
3211    o_prot.write_i32(self.definition_levels_byte_length)?;
3212    o_prot.write_field_end()?;
3213    o_prot.write_field_begin(&TFieldIdentifier::new("repetition_levels_byte_length", TType::I32, 6))?;
3214    o_prot.write_i32(self.repetition_levels_byte_length)?;
3215    o_prot.write_field_end()?;
3216    if let Some(fld_var) = self.is_compressed {
3217      o_prot.write_field_begin(&TFieldIdentifier::new("is_compressed", TType::Bool, 7))?;
3218      o_prot.write_bool(fld_var)?;
3219      o_prot.write_field_end()?
3220    }
3221    if let Some(ref fld_var) = self.statistics {
3222      o_prot.write_field_begin(&TFieldIdentifier::new("statistics", TType::Struct, 8))?;
3223      fld_var.write_to_out_protocol(o_prot)?;
3224      o_prot.write_field_end()?
3225    }
3226    o_prot.write_field_stop()?;
3227    o_prot.write_struct_end()
3228  }
3229}
3230
3231//
3232// SplitBlockAlgorithm
3233//
3234
3235/// Block-based algorithm type annotation. *
3236#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
3237pub struct SplitBlockAlgorithm {
3238}
3239
3240impl SplitBlockAlgorithm {
3241  pub fn new() -> SplitBlockAlgorithm {
3242    SplitBlockAlgorithm {}
3243  }
3244}
3245
3246impl crate::thrift::TSerializable for SplitBlockAlgorithm {
3247  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<SplitBlockAlgorithm> {
3248    i_prot.read_struct_begin()?;
3249    loop {
3250      let field_ident = i_prot.read_field_begin()?;
3251      if field_ident.field_type == TType::Stop {
3252        break;
3253      }
3254      i_prot.skip(field_ident.field_type)?;
3255      i_prot.read_field_end()?;
3256    }
3257    i_prot.read_struct_end()?;
3258    let ret = SplitBlockAlgorithm {};
3259    Ok(ret)
3260  }
3261  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
3262    let struct_ident = TStructIdentifier::new("SplitBlockAlgorithm");
3263    o_prot.write_struct_begin(&struct_ident)?;
3264    o_prot.write_field_stop()?;
3265    o_prot.write_struct_end()
3266  }
3267}
3268
3269//
3270// BloomFilterAlgorithm
3271//
3272
3273#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3274pub enum BloomFilterAlgorithm {
3275  BLOCK(SplitBlockAlgorithm),
3276}
3277
3278impl crate::thrift::TSerializable for BloomFilterAlgorithm {
3279  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<BloomFilterAlgorithm> {
3280    let mut ret: Option<BloomFilterAlgorithm> = None;
3281    let mut received_field_count = 0;
3282    i_prot.read_struct_begin()?;
3283    loop {
3284      let field_ident = i_prot.read_field_begin()?;
3285      if field_ident.field_type == TType::Stop {
3286        break;
3287      }
3288      let field_id = field_id(&field_ident)?;
3289      match field_id {
3290        1 => {
3291          let val = SplitBlockAlgorithm::read_from_in_protocol(i_prot)?;
3292          if ret.is_none() {
3293            ret = Some(BloomFilterAlgorithm::BLOCK(val));
3294          }
3295          received_field_count += 1;
3296        },
3297        _ => {
3298          i_prot.skip(field_ident.field_type)?;
3299          received_field_count += 1;
3300        },
3301      };
3302      i_prot.read_field_end()?;
3303    }
3304    i_prot.read_struct_end()?;
3305    if received_field_count == 0 {
3306      Err(
3307        thrift::Error::Protocol(
3308          ProtocolError::new(
3309            ProtocolErrorKind::InvalidData,
3310            "received empty union from remote BloomFilterAlgorithm"
3311          )
3312        )
3313      )
3314    } else if received_field_count > 1 {
3315      Err(
3316        thrift::Error::Protocol(
3317          ProtocolError::new(
3318            ProtocolErrorKind::InvalidData,
3319            "received multiple fields for union from remote BloomFilterAlgorithm"
3320          )
3321        )
3322      )
3323    } else {
3324      ret.ok_or_else(|| thrift::Error::Protocol(ProtocolError::new(ProtocolErrorKind::InvalidData, "return value should have been constructed")))
3325    }
3326  }
3327  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
3328    let struct_ident = TStructIdentifier::new("BloomFilterAlgorithm");
3329    o_prot.write_struct_begin(&struct_ident)?;
3330    match *self {
3331      BloomFilterAlgorithm::BLOCK(ref f) => {
3332        o_prot.write_field_begin(&TFieldIdentifier::new("BLOCK", TType::Struct, 1))?;
3333        f.write_to_out_protocol(o_prot)?;
3334        o_prot.write_field_end()?;
3335      },
3336    }
3337    o_prot.write_field_stop()?;
3338    o_prot.write_struct_end()
3339  }
3340}
3341
3342//
3343// XxHash
3344//
3345
3346/// Hash strategy type annotation. xxHash is an extremely fast non-cryptographic hash
3347/// algorithm. It uses 64 bits version of xxHash.
3348/// 
3349#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
3350pub struct XxHash {
3351}
3352
3353impl XxHash {
3354  pub fn new() -> XxHash {
3355    XxHash {}
3356  }
3357}
3358
3359impl crate::thrift::TSerializable for XxHash {
3360  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<XxHash> {
3361    i_prot.read_struct_begin()?;
3362    loop {
3363      let field_ident = i_prot.read_field_begin()?;
3364      if field_ident.field_type == TType::Stop {
3365        break;
3366      }
3367      i_prot.skip(field_ident.field_type)?;
3368      i_prot.read_field_end()?;
3369    }
3370    i_prot.read_struct_end()?;
3371    let ret = XxHash {};
3372    Ok(ret)
3373  }
3374  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
3375    let struct_ident = TStructIdentifier::new("XxHash");
3376    o_prot.write_struct_begin(&struct_ident)?;
3377    o_prot.write_field_stop()?;
3378    o_prot.write_struct_end()
3379  }
3380}
3381
3382//
3383// BloomFilterHash
3384//
3385
3386#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3387pub enum BloomFilterHash {
3388  XXHASH(XxHash),
3389}
3390
3391impl crate::thrift::TSerializable for BloomFilterHash {
3392  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<BloomFilterHash> {
3393    let mut ret: Option<BloomFilterHash> = None;
3394    let mut received_field_count = 0;
3395    i_prot.read_struct_begin()?;
3396    loop {
3397      let field_ident = i_prot.read_field_begin()?;
3398      if field_ident.field_type == TType::Stop {
3399        break;
3400      }
3401      let field_id = field_id(&field_ident)?;
3402      match field_id {
3403        1 => {
3404          let val = XxHash::read_from_in_protocol(i_prot)?;
3405          if ret.is_none() {
3406            ret = Some(BloomFilterHash::XXHASH(val));
3407          }
3408          received_field_count += 1;
3409        },
3410        _ => {
3411          i_prot.skip(field_ident.field_type)?;
3412          received_field_count += 1;
3413        },
3414      };
3415      i_prot.read_field_end()?;
3416    }
3417    i_prot.read_struct_end()?;
3418    if received_field_count == 0 {
3419      Err(
3420        thrift::Error::Protocol(
3421          ProtocolError::new(
3422            ProtocolErrorKind::InvalidData,
3423            "received empty union from remote BloomFilterHash"
3424          )
3425        )
3426      )
3427    } else if received_field_count > 1 {
3428      Err(
3429        thrift::Error::Protocol(
3430          ProtocolError::new(
3431            ProtocolErrorKind::InvalidData,
3432            "received multiple fields for union from remote BloomFilterHash"
3433          )
3434        )
3435      )
3436    } else {
3437      ret.ok_or_else(|| thrift::Error::Protocol(ProtocolError::new(ProtocolErrorKind::InvalidData, "return value should have been constructed")))
3438    }
3439  }
3440  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
3441    let struct_ident = TStructIdentifier::new("BloomFilterHash");
3442    o_prot.write_struct_begin(&struct_ident)?;
3443    match *self {
3444      BloomFilterHash::XXHASH(ref f) => {
3445        o_prot.write_field_begin(&TFieldIdentifier::new("XXHASH", TType::Struct, 1))?;
3446        f.write_to_out_protocol(o_prot)?;
3447        o_prot.write_field_end()?;
3448      },
3449    }
3450    o_prot.write_field_stop()?;
3451    o_prot.write_struct_end()
3452  }
3453}
3454
3455//
3456// Uncompressed
3457//
3458
3459/// The compression used in the Bloom filter.
3460/// 
3461#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
3462pub struct Uncompressed {
3463}
3464
3465impl Uncompressed {
3466  pub fn new() -> Uncompressed {
3467    Uncompressed {}
3468  }
3469}
3470
3471impl crate::thrift::TSerializable for Uncompressed {
3472  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<Uncompressed> {
3473    i_prot.read_struct_begin()?;
3474    loop {
3475      let field_ident = i_prot.read_field_begin()?;
3476      if field_ident.field_type == TType::Stop {
3477        break;
3478      }
3479      i_prot.skip(field_ident.field_type)?;
3480      i_prot.read_field_end()?;
3481    }
3482    i_prot.read_struct_end()?;
3483    let ret = Uncompressed {};
3484    Ok(ret)
3485  }
3486  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
3487    let struct_ident = TStructIdentifier::new("Uncompressed");
3488    o_prot.write_struct_begin(&struct_ident)?;
3489    o_prot.write_field_stop()?;
3490    o_prot.write_struct_end()
3491  }
3492}
3493
3494//
3495// BloomFilterCompression
3496//
3497
3498#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3499pub enum BloomFilterCompression {
3500  UNCOMPRESSED(Uncompressed),
3501}
3502
3503impl crate::thrift::TSerializable for BloomFilterCompression {
3504  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<BloomFilterCompression> {
3505    let mut ret: Option<BloomFilterCompression> = None;
3506    let mut received_field_count = 0;
3507    i_prot.read_struct_begin()?;
3508    loop {
3509      let field_ident = i_prot.read_field_begin()?;
3510      if field_ident.field_type == TType::Stop {
3511        break;
3512      }
3513      let field_id = field_id(&field_ident)?;
3514      match field_id {
3515        1 => {
3516          let val = Uncompressed::read_from_in_protocol(i_prot)?;
3517          if ret.is_none() {
3518            ret = Some(BloomFilterCompression::UNCOMPRESSED(val));
3519          }
3520          received_field_count += 1;
3521        },
3522        _ => {
3523          i_prot.skip(field_ident.field_type)?;
3524          received_field_count += 1;
3525        },
3526      };
3527      i_prot.read_field_end()?;
3528    }
3529    i_prot.read_struct_end()?;
3530    if received_field_count == 0 {
3531      Err(
3532        thrift::Error::Protocol(
3533          ProtocolError::new(
3534            ProtocolErrorKind::InvalidData,
3535            "received empty union from remote BloomFilterCompression"
3536          )
3537        )
3538      )
3539    } else if received_field_count > 1 {
3540      Err(
3541        thrift::Error::Protocol(
3542          ProtocolError::new(
3543            ProtocolErrorKind::InvalidData,
3544            "received multiple fields for union from remote BloomFilterCompression"
3545          )
3546        )
3547      )
3548    } else {
3549      ret.ok_or_else(|| thrift::Error::Protocol(ProtocolError::new(ProtocolErrorKind::InvalidData, "return value should have been constructed")))
3550    }
3551  }
3552  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
3553    let struct_ident = TStructIdentifier::new("BloomFilterCompression");
3554    o_prot.write_struct_begin(&struct_ident)?;
3555    match *self {
3556      BloomFilterCompression::UNCOMPRESSED(ref f) => {
3557        o_prot.write_field_begin(&TFieldIdentifier::new("UNCOMPRESSED", TType::Struct, 1))?;
3558        f.write_to_out_protocol(o_prot)?;
3559        o_prot.write_field_end()?;
3560      },
3561    }
3562    o_prot.write_field_stop()?;
3563    o_prot.write_struct_end()
3564  }
3565}
3566
3567//
3568// BloomFilterHeader
3569//
3570
3571/// Bloom filter header is stored at beginning of Bloom filter data of each column
3572/// and followed by its bitset.
3573/// 
3574#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3575pub struct BloomFilterHeader {
3576  /// The size of bitset in bytes *
3577  pub num_bytes: i32,
3578  /// The algorithm for setting bits. *
3579  pub algorithm: BloomFilterAlgorithm,
3580  /// The hash function used for Bloom filter. *
3581  pub hash: BloomFilterHash,
3582  /// The compression used in the Bloom filter *
3583  pub compression: BloomFilterCompression,
3584}
3585
3586impl BloomFilterHeader {
3587  pub fn new(num_bytes: i32, algorithm: BloomFilterAlgorithm, hash: BloomFilterHash, compression: BloomFilterCompression) -> BloomFilterHeader {
3588    BloomFilterHeader {
3589      num_bytes,
3590      algorithm,
3591      hash,
3592      compression,
3593    }
3594  }
3595}
3596
3597impl crate::thrift::TSerializable for BloomFilterHeader {
3598  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<BloomFilterHeader> {
3599    i_prot.read_struct_begin()?;
3600    let mut f_1: Option<i32> = None;
3601    let mut f_2: Option<BloomFilterAlgorithm> = None;
3602    let mut f_3: Option<BloomFilterHash> = None;
3603    let mut f_4: Option<BloomFilterCompression> = None;
3604    loop {
3605      let field_ident = i_prot.read_field_begin()?;
3606      if field_ident.field_type == TType::Stop {
3607        break;
3608      }
3609      let field_id = field_id(&field_ident)?;
3610      match field_id {
3611        1 => {
3612          let val = i_prot.read_i32()?;
3613          f_1 = Some(val);
3614        },
3615        2 => {
3616          let val = BloomFilterAlgorithm::read_from_in_protocol(i_prot)?;
3617          f_2 = Some(val);
3618        },
3619        3 => {
3620          let val = BloomFilterHash::read_from_in_protocol(i_prot)?;
3621          f_3 = Some(val);
3622        },
3623        4 => {
3624          let val = BloomFilterCompression::read_from_in_protocol(i_prot)?;
3625          f_4 = Some(val);
3626        },
3627        _ => {
3628          i_prot.skip(field_ident.field_type)?;
3629        },
3630      };
3631      i_prot.read_field_end()?;
3632    }
3633    i_prot.read_struct_end()?;
3634    verify_required_field_exists("BloomFilterHeader.num_bytes", &f_1)?;
3635    verify_required_field_exists("BloomFilterHeader.algorithm", &f_2)?;
3636    verify_required_field_exists("BloomFilterHeader.hash", &f_3)?;
3637    verify_required_field_exists("BloomFilterHeader.compression", &f_4)?;
3638    let ret = BloomFilterHeader {
3639      num_bytes: f_1.expect("auto-generated code should have checked for presence of required fields"),
3640      algorithm: f_2.expect("auto-generated code should have checked for presence of required fields"),
3641      hash: f_3.expect("auto-generated code should have checked for presence of required fields"),
3642      compression: f_4.expect("auto-generated code should have checked for presence of required fields"),
3643    };
3644    Ok(ret)
3645  }
3646  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
3647    let struct_ident = TStructIdentifier::new("BloomFilterHeader");
3648    o_prot.write_struct_begin(&struct_ident)?;
3649    o_prot.write_field_begin(&TFieldIdentifier::new("numBytes", TType::I32, 1))?;
3650    o_prot.write_i32(self.num_bytes)?;
3651    o_prot.write_field_end()?;
3652    o_prot.write_field_begin(&TFieldIdentifier::new("algorithm", TType::Struct, 2))?;
3653    self.algorithm.write_to_out_protocol(o_prot)?;
3654    o_prot.write_field_end()?;
3655    o_prot.write_field_begin(&TFieldIdentifier::new("hash", TType::Struct, 3))?;
3656    self.hash.write_to_out_protocol(o_prot)?;
3657    o_prot.write_field_end()?;
3658    o_prot.write_field_begin(&TFieldIdentifier::new("compression", TType::Struct, 4))?;
3659    self.compression.write_to_out_protocol(o_prot)?;
3660    o_prot.write_field_end()?;
3661    o_prot.write_field_stop()?;
3662    o_prot.write_struct_end()
3663  }
3664}
3665
3666//
3667// PageHeader
3668//
3669
3670#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3671pub struct PageHeader {
3672  /// the type of the page: indicates which of the *_header fields is set *
3673  pub type_: PageType,
3674  /// Uncompressed page size in bytes (not including this header) *
3675  pub uncompressed_page_size: i32,
3676  /// Compressed (and potentially encrypted) page size in bytes, not including this header *
3677  pub compressed_page_size: i32,
3678  /// The 32-bit CRC checksum for the page, to be be calculated as follows:
3679  /// 
3680  /// - The standard CRC32 algorithm is used (with polynomial 0x04C11DB7,
3681  ///   the same as in e.g. GZip).
3682  /// - All page types can have a CRC (v1 and v2 data pages, dictionary pages,
3683  ///   etc.).
3684  /// - The CRC is computed on the serialization binary representation of the page
3685  ///   (as written to disk), excluding the page header. For example, for v1
3686  ///   data pages, the CRC is computed on the concatenation of repetition levels,
3687  ///   definition levels and column values (optionally compressed, optionally
3688  ///   encrypted).
3689  /// - The CRC computation therefore takes place after any compression
3690  ///   and encryption steps, if any.
3691  /// 
3692  /// If enabled, this allows for disabling checksumming in HDFS if only a few
3693  /// pages need to be read.
3694  pub crc: Option<i32>,
3695  pub data_page_header: Option<DataPageHeader>,
3696  pub index_page_header: Option<IndexPageHeader>,
3697  pub dictionary_page_header: Option<DictionaryPageHeader>,
3698  pub data_page_header_v2: Option<DataPageHeaderV2>,
3699}
3700
3701impl PageHeader {
3702  pub fn new<F4, F5, F6, F7, F8>(type_: PageType, uncompressed_page_size: i32, compressed_page_size: i32, crc: F4, data_page_header: F5, index_page_header: F6, dictionary_page_header: F7, data_page_header_v2: F8) -> PageHeader where F4: Into<Option<i32>>, F5: Into<Option<DataPageHeader>>, F6: Into<Option<IndexPageHeader>>, F7: Into<Option<DictionaryPageHeader>>, F8: Into<Option<DataPageHeaderV2>> {
3703    PageHeader {
3704      type_,
3705      uncompressed_page_size,
3706      compressed_page_size,
3707      crc: crc.into(),
3708      data_page_header: data_page_header.into(),
3709      index_page_header: index_page_header.into(),
3710      dictionary_page_header: dictionary_page_header.into(),
3711      data_page_header_v2: data_page_header_v2.into(),
3712    }
3713  }
3714}
3715
3716impl crate::thrift::TSerializable for PageHeader {
3717  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<PageHeader> {
3718    i_prot.read_struct_begin()?;
3719    let mut f_1: Option<PageType> = None;
3720    let mut f_2: Option<i32> = None;
3721    let mut f_3: Option<i32> = None;
3722    let mut f_4: Option<i32> = None;
3723    let mut f_5: Option<DataPageHeader> = None;
3724    let mut f_6: Option<IndexPageHeader> = None;
3725    let mut f_7: Option<DictionaryPageHeader> = None;
3726    let mut f_8: Option<DataPageHeaderV2> = None;
3727    loop {
3728      let field_ident = i_prot.read_field_begin()?;
3729      if field_ident.field_type == TType::Stop {
3730        break;
3731      }
3732      let field_id = field_id(&field_ident)?;
3733      match field_id {
3734        1 => {
3735          let val = PageType::read_from_in_protocol(i_prot)?;
3736          f_1 = Some(val);
3737        },
3738        2 => {
3739          let val = i_prot.read_i32()?;
3740          f_2 = Some(val);
3741        },
3742        3 => {
3743          let val = i_prot.read_i32()?;
3744          f_3 = Some(val);
3745        },
3746        4 => {
3747          let val = i_prot.read_i32()?;
3748          f_4 = Some(val);
3749        },
3750        5 => {
3751          let val = DataPageHeader::read_from_in_protocol(i_prot)?;
3752          f_5 = Some(val);
3753        },
3754        6 => {
3755          let val = IndexPageHeader::read_from_in_protocol(i_prot)?;
3756          f_6 = Some(val);
3757        },
3758        7 => {
3759          let val = DictionaryPageHeader::read_from_in_protocol(i_prot)?;
3760          f_7 = Some(val);
3761        },
3762        8 => {
3763          let val = DataPageHeaderV2::read_from_in_protocol(i_prot)?;
3764          f_8 = Some(val);
3765        },
3766        _ => {
3767          i_prot.skip(field_ident.field_type)?;
3768        },
3769      };
3770      i_prot.read_field_end()?;
3771    }
3772    i_prot.read_struct_end()?;
3773    verify_required_field_exists("PageHeader.type_", &f_1)?;
3774    verify_required_field_exists("PageHeader.uncompressed_page_size", &f_2)?;
3775    verify_required_field_exists("PageHeader.compressed_page_size", &f_3)?;
3776    let ret = PageHeader {
3777      type_: f_1.expect("auto-generated code should have checked for presence of required fields"),
3778      uncompressed_page_size: f_2.expect("auto-generated code should have checked for presence of required fields"),
3779      compressed_page_size: f_3.expect("auto-generated code should have checked for presence of required fields"),
3780      crc: f_4,
3781      data_page_header: f_5,
3782      index_page_header: f_6,
3783      dictionary_page_header: f_7,
3784      data_page_header_v2: f_8,
3785    };
3786    Ok(ret)
3787  }
3788  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
3789    let struct_ident = TStructIdentifier::new("PageHeader");
3790    o_prot.write_struct_begin(&struct_ident)?;
3791    o_prot.write_field_begin(&TFieldIdentifier::new("type", TType::I32, 1))?;
3792    self.type_.write_to_out_protocol(o_prot)?;
3793    o_prot.write_field_end()?;
3794    o_prot.write_field_begin(&TFieldIdentifier::new("uncompressed_page_size", TType::I32, 2))?;
3795    o_prot.write_i32(self.uncompressed_page_size)?;
3796    o_prot.write_field_end()?;
3797    o_prot.write_field_begin(&TFieldIdentifier::new("compressed_page_size", TType::I32, 3))?;
3798    o_prot.write_i32(self.compressed_page_size)?;
3799    o_prot.write_field_end()?;
3800    if let Some(fld_var) = self.crc {
3801      o_prot.write_field_begin(&TFieldIdentifier::new("crc", TType::I32, 4))?;
3802      o_prot.write_i32(fld_var)?;
3803      o_prot.write_field_end()?
3804    }
3805    if let Some(ref fld_var) = self.data_page_header {
3806      o_prot.write_field_begin(&TFieldIdentifier::new("data_page_header", TType::Struct, 5))?;
3807      fld_var.write_to_out_protocol(o_prot)?;
3808      o_prot.write_field_end()?
3809    }
3810    if let Some(ref fld_var) = self.index_page_header {
3811      o_prot.write_field_begin(&TFieldIdentifier::new("index_page_header", TType::Struct, 6))?;
3812      fld_var.write_to_out_protocol(o_prot)?;
3813      o_prot.write_field_end()?
3814    }
3815    if let Some(ref fld_var) = self.dictionary_page_header {
3816      o_prot.write_field_begin(&TFieldIdentifier::new("dictionary_page_header", TType::Struct, 7))?;
3817      fld_var.write_to_out_protocol(o_prot)?;
3818      o_prot.write_field_end()?
3819    }
3820    if let Some(ref fld_var) = self.data_page_header_v2 {
3821      o_prot.write_field_begin(&TFieldIdentifier::new("data_page_header_v2", TType::Struct, 8))?;
3822      fld_var.write_to_out_protocol(o_prot)?;
3823      o_prot.write_field_end()?
3824    }
3825    o_prot.write_field_stop()?;
3826    o_prot.write_struct_end()
3827  }
3828}
3829
3830//
3831// KeyValue
3832//
3833
3834/// Wrapper struct to store key values
3835#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3836pub struct KeyValue {
3837  pub key: String,
3838  pub value: Option<String>,
3839}
3840
3841impl KeyValue {
3842  pub fn new<F2>(key: String, value: F2) -> KeyValue where F2: Into<Option<String>> {
3843    KeyValue {
3844      key,
3845      value: value.into(),
3846    }
3847  }
3848}
3849
3850impl crate::thrift::TSerializable for KeyValue {
3851  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<KeyValue> {
3852    i_prot.read_struct_begin()?;
3853    let mut f_1: Option<String> = None;
3854    let mut f_2: Option<String> = None;
3855    loop {
3856      let field_ident = i_prot.read_field_begin()?;
3857      if field_ident.field_type == TType::Stop {
3858        break;
3859      }
3860      let field_id = field_id(&field_ident)?;
3861      match field_id {
3862        1 => {
3863          let val = i_prot.read_string()?;
3864          f_1 = Some(val);
3865        },
3866        2 => {
3867          let val = i_prot.read_string()?;
3868          f_2 = Some(val);
3869        },
3870        _ => {
3871          i_prot.skip(field_ident.field_type)?;
3872        },
3873      };
3874      i_prot.read_field_end()?;
3875    }
3876    i_prot.read_struct_end()?;
3877    verify_required_field_exists("KeyValue.key", &f_1)?;
3878    let ret = KeyValue {
3879      key: f_1.expect("auto-generated code should have checked for presence of required fields"),
3880      value: f_2,
3881    };
3882    Ok(ret)
3883  }
3884  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
3885    let struct_ident = TStructIdentifier::new("KeyValue");
3886    o_prot.write_struct_begin(&struct_ident)?;
3887    o_prot.write_field_begin(&TFieldIdentifier::new("key", TType::String, 1))?;
3888    o_prot.write_string(&self.key)?;
3889    o_prot.write_field_end()?;
3890    if let Some(ref fld_var) = self.value {
3891      o_prot.write_field_begin(&TFieldIdentifier::new("value", TType::String, 2))?;
3892      o_prot.write_string(fld_var)?;
3893      o_prot.write_field_end()?
3894    }
3895    o_prot.write_field_stop()?;
3896    o_prot.write_struct_end()
3897  }
3898}
3899
3900//
3901// SortingColumn
3902//
3903
3904/// Sort order within a RowGroup of a leaf column
3905#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3906pub struct SortingColumn {
3907  /// The ordinal position of the column (in this row group) *
3908  pub column_idx: i32,
3909  /// If true, indicates this column is sorted in descending order. *
3910  pub descending: bool,
3911  /// If true, nulls will come before non-null values, otherwise,
3912  /// nulls go at the end.
3913  pub nulls_first: bool,
3914}
3915
3916impl SortingColumn {
3917  pub fn new(column_idx: i32, descending: bool, nulls_first: bool) -> SortingColumn {
3918    SortingColumn {
3919      column_idx,
3920      descending,
3921      nulls_first,
3922    }
3923  }
3924}
3925
3926impl crate::thrift::TSerializable for SortingColumn {
3927  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<SortingColumn> {
3928    i_prot.read_struct_begin()?;
3929    let mut f_1: Option<i32> = None;
3930    let mut f_2: Option<bool> = None;
3931    let mut f_3: Option<bool> = None;
3932    loop {
3933      let field_ident = i_prot.read_field_begin()?;
3934      if field_ident.field_type == TType::Stop {
3935        break;
3936      }
3937      let field_id = field_id(&field_ident)?;
3938      match field_id {
3939        1 => {
3940          let val = i_prot.read_i32()?;
3941          f_1 = Some(val);
3942        },
3943        2 => {
3944          let val = i_prot.read_bool()?;
3945          f_2 = Some(val);
3946        },
3947        3 => {
3948          let val = i_prot.read_bool()?;
3949          f_3 = Some(val);
3950        },
3951        _ => {
3952          i_prot.skip(field_ident.field_type)?;
3953        },
3954      };
3955      i_prot.read_field_end()?;
3956    }
3957    i_prot.read_struct_end()?;
3958    verify_required_field_exists("SortingColumn.column_idx", &f_1)?;
3959    verify_required_field_exists("SortingColumn.descending", &f_2)?;
3960    verify_required_field_exists("SortingColumn.nulls_first", &f_3)?;
3961    let ret = SortingColumn {
3962      column_idx: f_1.expect("auto-generated code should have checked for presence of required fields"),
3963      descending: f_2.expect("auto-generated code should have checked for presence of required fields"),
3964      nulls_first: f_3.expect("auto-generated code should have checked for presence of required fields"),
3965    };
3966    Ok(ret)
3967  }
3968  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
3969    let struct_ident = TStructIdentifier::new("SortingColumn");
3970    o_prot.write_struct_begin(&struct_ident)?;
3971    o_prot.write_field_begin(&TFieldIdentifier::new("column_idx", TType::I32, 1))?;
3972    o_prot.write_i32(self.column_idx)?;
3973    o_prot.write_field_end()?;
3974    o_prot.write_field_begin(&TFieldIdentifier::new("descending", TType::Bool, 2))?;
3975    o_prot.write_bool(self.descending)?;
3976    o_prot.write_field_end()?;
3977    o_prot.write_field_begin(&TFieldIdentifier::new("nulls_first", TType::Bool, 3))?;
3978    o_prot.write_bool(self.nulls_first)?;
3979    o_prot.write_field_end()?;
3980    o_prot.write_field_stop()?;
3981    o_prot.write_struct_end()
3982  }
3983}
3984
3985//
3986// PageEncodingStats
3987//
3988
3989/// statistics of a given page type and encoding
3990#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3991pub struct PageEncodingStats {
3992  /// the page type (data/dic/...) *
3993  pub page_type: PageType,
3994  /// encoding of the page *
3995  pub encoding: Encoding,
3996  /// number of pages of this type with this encoding *
3997  pub count: i32,
3998}
3999
4000impl PageEncodingStats {
4001  pub fn new(page_type: PageType, encoding: Encoding, count: i32) -> PageEncodingStats {
4002    PageEncodingStats {
4003      page_type,
4004      encoding,
4005      count,
4006    }
4007  }
4008}
4009
4010impl crate::thrift::TSerializable for PageEncodingStats {
4011  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<PageEncodingStats> {
4012    i_prot.read_struct_begin()?;
4013    let mut f_1: Option<PageType> = None;
4014    let mut f_2: Option<Encoding> = None;
4015    let mut f_3: Option<i32> = None;
4016    loop {
4017      let field_ident = i_prot.read_field_begin()?;
4018      if field_ident.field_type == TType::Stop {
4019        break;
4020      }
4021      let field_id = field_id(&field_ident)?;
4022      match field_id {
4023        1 => {
4024          let val = PageType::read_from_in_protocol(i_prot)?;
4025          f_1 = Some(val);
4026        },
4027        2 => {
4028          let val = Encoding::read_from_in_protocol(i_prot)?;
4029          f_2 = Some(val);
4030        },
4031        3 => {
4032          let val = i_prot.read_i32()?;
4033          f_3 = Some(val);
4034        },
4035        _ => {
4036          i_prot.skip(field_ident.field_type)?;
4037        },
4038      };
4039      i_prot.read_field_end()?;
4040    }
4041    i_prot.read_struct_end()?;
4042    verify_required_field_exists("PageEncodingStats.page_type", &f_1)?;
4043    verify_required_field_exists("PageEncodingStats.encoding", &f_2)?;
4044    verify_required_field_exists("PageEncodingStats.count", &f_3)?;
4045    let ret = PageEncodingStats {
4046      page_type: f_1.expect("auto-generated code should have checked for presence of required fields"),
4047      encoding: f_2.expect("auto-generated code should have checked for presence of required fields"),
4048      count: f_3.expect("auto-generated code should have checked for presence of required fields"),
4049    };
4050    Ok(ret)
4051  }
4052  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
4053    let struct_ident = TStructIdentifier::new("PageEncodingStats");
4054    o_prot.write_struct_begin(&struct_ident)?;
4055    o_prot.write_field_begin(&TFieldIdentifier::new("page_type", TType::I32, 1))?;
4056    self.page_type.write_to_out_protocol(o_prot)?;
4057    o_prot.write_field_end()?;
4058    o_prot.write_field_begin(&TFieldIdentifier::new("encoding", TType::I32, 2))?;
4059    self.encoding.write_to_out_protocol(o_prot)?;
4060    o_prot.write_field_end()?;
4061    o_prot.write_field_begin(&TFieldIdentifier::new("count", TType::I32, 3))?;
4062    o_prot.write_i32(self.count)?;
4063    o_prot.write_field_end()?;
4064    o_prot.write_field_stop()?;
4065    o_prot.write_struct_end()
4066  }
4067}
4068
4069//
4070// ColumnMetaData
4071//
4072
4073/// Description for column metadata
4074#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
4075pub struct ColumnMetaData {
4076  /// Type of this column *
4077  pub type_: Type,
4078  /// Set of all encodings used for this column. The purpose is to validate
4079  /// whether we can decode those pages. *
4080  pub encodings: Vec<Encoding>,
4081  /// Path in schema *
4082  pub path_in_schema: Vec<String>,
4083  /// Compression codec *
4084  pub codec: CompressionCodec,
4085  /// Number of values in this column *
4086  pub num_values: i64,
4087  /// total byte size of all uncompressed pages in this column chunk (including the headers) *
4088  pub total_uncompressed_size: i64,
4089  /// total byte size of all compressed, and potentially encrypted, pages
4090  /// in this column chunk (including the headers) *
4091  pub total_compressed_size: i64,
4092  /// Optional key/value metadata *
4093  pub key_value_metadata: Option<Vec<KeyValue>>,
4094  /// Byte offset from beginning of file to first data page *
4095  pub data_page_offset: i64,
4096  /// Byte offset from beginning of file to root index page *
4097  pub index_page_offset: Option<i64>,
4098  /// Byte offset from the beginning of file to first (only) dictionary page *
4099  pub dictionary_page_offset: Option<i64>,
4100  /// optional statistics for this column chunk
4101  pub statistics: Option<Statistics>,
4102  /// Set of all encodings used for pages in this column chunk.
4103  /// This information can be used to determine if all data pages are
4104  /// dictionary encoded for example *
4105  pub encoding_stats: Option<Vec<PageEncodingStats>>,
4106  /// Byte offset from beginning of file to Bloom filter data. *
4107  pub bloom_filter_offset: Option<i64>,
4108  /// Size of Bloom filter data including the serialized header, in bytes.
4109  /// Added in 2.10 so readers may not read this field from old files and
4110  /// it can be obtained after the BloomFilterHeader has been deserialized.
4111  /// Writers should write this field so readers can read the bloom filter
4112  /// in a single I/O.
4113  pub bloom_filter_length: Option<i32>,
4114  /// Optional statistics to help estimate total memory when converted to in-memory
4115  /// representations. The histograms contained in these statistics can
4116  /// also be useful in some cases for more fine-grained nullability/list length
4117  /// filter pushdown.
4118  pub size_statistics: Option<SizeStatistics>,
4119  /// Optional statistics specific for Geometry and Geography logical types
4120  pub geospatial_statistics: Option<GeospatialStatistics>,
4121}
4122
4123impl ColumnMetaData {
4124  pub fn new<F8, F10, F11, F12, F13, F14, F15, F16, F17>(type_: Type, encodings: Vec<Encoding>, path_in_schema: Vec<String>, codec: CompressionCodec, num_values: i64, total_uncompressed_size: i64, total_compressed_size: i64, key_value_metadata: F8, data_page_offset: i64, index_page_offset: F10, dictionary_page_offset: F11, statistics: F12, encoding_stats: F13, bloom_filter_offset: F14, bloom_filter_length: F15, size_statistics: F16, geospatial_statistics: F17) -> ColumnMetaData where F8: Into<Option<Vec<KeyValue>>>, F10: Into<Option<i64>>, F11: Into<Option<i64>>, F12: Into<Option<Statistics>>, F13: Into<Option<Vec<PageEncodingStats>>>, F14: Into<Option<i64>>, F15: Into<Option<i32>>, F16: Into<Option<SizeStatistics>>, F17: Into<Option<GeospatialStatistics>> {
4125    ColumnMetaData {
4126      type_,
4127      encodings,
4128      path_in_schema,
4129      codec,
4130      num_values,
4131      total_uncompressed_size,
4132      total_compressed_size,
4133      key_value_metadata: key_value_metadata.into(),
4134      data_page_offset,
4135      index_page_offset: index_page_offset.into(),
4136      dictionary_page_offset: dictionary_page_offset.into(),
4137      statistics: statistics.into(),
4138      encoding_stats: encoding_stats.into(),
4139      bloom_filter_offset: bloom_filter_offset.into(),
4140      bloom_filter_length: bloom_filter_length.into(),
4141      size_statistics: size_statistics.into(),
4142      geospatial_statistics: geospatial_statistics.into(),
4143    }
4144  }
4145}
4146
4147impl crate::thrift::TSerializable for ColumnMetaData {
4148  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<ColumnMetaData> {
4149    i_prot.read_struct_begin()?;
4150    let mut f_1: Option<Type> = None;
4151    let mut f_2: Option<Vec<Encoding>> = None;
4152    let mut f_3: Option<Vec<String>> = None;
4153    let mut f_4: Option<CompressionCodec> = None;
4154    let mut f_5: Option<i64> = None;
4155    let mut f_6: Option<i64> = None;
4156    let mut f_7: Option<i64> = None;
4157    let mut f_8: Option<Vec<KeyValue>> = None;
4158    let mut f_9: Option<i64> = None;
4159    let mut f_10: Option<i64> = None;
4160    let mut f_11: Option<i64> = None;
4161    let mut f_12: Option<Statistics> = None;
4162    let mut f_13: Option<Vec<PageEncodingStats>> = None;
4163    let mut f_14: Option<i64> = None;
4164    let mut f_15: Option<i32> = None;
4165    let mut f_16: Option<SizeStatistics> = None;
4166    let mut f_17: Option<GeospatialStatistics> = None;
4167    loop {
4168      let field_ident = i_prot.read_field_begin()?;
4169      if field_ident.field_type == TType::Stop {
4170        break;
4171      }
4172      let field_id = field_id(&field_ident)?;
4173      match field_id {
4174        1 => {
4175          let val = Type::read_from_in_protocol(i_prot)?;
4176          f_1 = Some(val);
4177        },
4178        2 => {
4179          let list_ident = i_prot.read_list_begin()?;
4180          let mut val: Vec<Encoding> = Vec::with_capacity(list_ident.size as usize);
4181          for _ in 0..list_ident.size {
4182            let list_elem_3 = Encoding::read_from_in_protocol(i_prot)?;
4183            val.push(list_elem_3);
4184          }
4185          i_prot.read_list_end()?;
4186          f_2 = Some(val);
4187        },
4188        3 => {
4189          let list_ident = i_prot.read_list_begin()?;
4190          let mut val: Vec<String> = Vec::with_capacity(list_ident.size as usize);
4191          for _ in 0..list_ident.size {
4192            let list_elem_4 = i_prot.read_string()?;
4193            val.push(list_elem_4);
4194          }
4195          i_prot.read_list_end()?;
4196          f_3 = Some(val);
4197        },
4198        4 => {
4199          let val = CompressionCodec::read_from_in_protocol(i_prot)?;
4200          f_4 = Some(val);
4201        },
4202        5 => {
4203          let val = i_prot.read_i64()?;
4204          f_5 = Some(val);
4205        },
4206        6 => {
4207          let val = i_prot.read_i64()?;
4208          f_6 = Some(val);
4209        },
4210        7 => {
4211          let val = i_prot.read_i64()?;
4212          f_7 = Some(val);
4213        },
4214        8 => {
4215          let list_ident = i_prot.read_list_begin()?;
4216          let mut val: Vec<KeyValue> = Vec::with_capacity(list_ident.size as usize);
4217          for _ in 0..list_ident.size {
4218            let list_elem_5 = KeyValue::read_from_in_protocol(i_prot)?;
4219            val.push(list_elem_5);
4220          }
4221          i_prot.read_list_end()?;
4222          f_8 = Some(val);
4223        },
4224        9 => {
4225          let val = i_prot.read_i64()?;
4226          f_9 = Some(val);
4227        },
4228        10 => {
4229          let val = i_prot.read_i64()?;
4230          f_10 = Some(val);
4231        },
4232        11 => {
4233          let val = i_prot.read_i64()?;
4234          f_11 = Some(val);
4235        },
4236        12 => {
4237          let val = Statistics::read_from_in_protocol(i_prot)?;
4238          f_12 = Some(val);
4239        },
4240        13 => {
4241          let list_ident = i_prot.read_list_begin()?;
4242          let mut val: Vec<PageEncodingStats> = Vec::with_capacity(list_ident.size as usize);
4243          for _ in 0..list_ident.size {
4244            let list_elem_6 = PageEncodingStats::read_from_in_protocol(i_prot)?;
4245            val.push(list_elem_6);
4246          }
4247          i_prot.read_list_end()?;
4248          f_13 = Some(val);
4249        },
4250        14 => {
4251          let val = i_prot.read_i64()?;
4252          f_14 = Some(val);
4253        },
4254        15 => {
4255          let val = i_prot.read_i32()?;
4256          f_15 = Some(val);
4257        },
4258        16 => {
4259          let val = SizeStatistics::read_from_in_protocol(i_prot)?;
4260          f_16 = Some(val);
4261        },
4262        17 => {
4263          let val = GeospatialStatistics::read_from_in_protocol(i_prot)?;
4264          f_17 = Some(val);
4265        },
4266        _ => {
4267          i_prot.skip(field_ident.field_type)?;
4268        },
4269      };
4270      i_prot.read_field_end()?;
4271    }
4272    i_prot.read_struct_end()?;
4273    verify_required_field_exists("ColumnMetaData.type_", &f_1)?;
4274    verify_required_field_exists("ColumnMetaData.encodings", &f_2)?;
4275    verify_required_field_exists("ColumnMetaData.path_in_schema", &f_3)?;
4276    verify_required_field_exists("ColumnMetaData.codec", &f_4)?;
4277    verify_required_field_exists("ColumnMetaData.num_values", &f_5)?;
4278    verify_required_field_exists("ColumnMetaData.total_uncompressed_size", &f_6)?;
4279    verify_required_field_exists("ColumnMetaData.total_compressed_size", &f_7)?;
4280    verify_required_field_exists("ColumnMetaData.data_page_offset", &f_9)?;
4281    let ret = ColumnMetaData {
4282      type_: f_1.expect("auto-generated code should have checked for presence of required fields"),
4283      encodings: f_2.expect("auto-generated code should have checked for presence of required fields"),
4284      path_in_schema: f_3.expect("auto-generated code should have checked for presence of required fields"),
4285      codec: f_4.expect("auto-generated code should have checked for presence of required fields"),
4286      num_values: f_5.expect("auto-generated code should have checked for presence of required fields"),
4287      total_uncompressed_size: f_6.expect("auto-generated code should have checked for presence of required fields"),
4288      total_compressed_size: f_7.expect("auto-generated code should have checked for presence of required fields"),
4289      key_value_metadata: f_8,
4290      data_page_offset: f_9.expect("auto-generated code should have checked for presence of required fields"),
4291      index_page_offset: f_10,
4292      dictionary_page_offset: f_11,
4293      statistics: f_12,
4294      encoding_stats: f_13,
4295      bloom_filter_offset: f_14,
4296      bloom_filter_length: f_15,
4297      size_statistics: f_16,
4298      geospatial_statistics: f_17,
4299    };
4300    Ok(ret)
4301  }
4302  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
4303    let struct_ident = TStructIdentifier::new("ColumnMetaData");
4304    o_prot.write_struct_begin(&struct_ident)?;
4305    o_prot.write_field_begin(&TFieldIdentifier::new("type", TType::I32, 1))?;
4306    self.type_.write_to_out_protocol(o_prot)?;
4307    o_prot.write_field_end()?;
4308    o_prot.write_field_begin(&TFieldIdentifier::new("encodings", TType::List, 2))?;
4309    o_prot.write_list_begin(&TListIdentifier::new(TType::I32, self.encodings.len() as i32))?;
4310    for e in &self.encodings {
4311      e.write_to_out_protocol(o_prot)?;
4312    }
4313    o_prot.write_list_end()?;
4314    o_prot.write_field_end()?;
4315    o_prot.write_field_begin(&TFieldIdentifier::new("path_in_schema", TType::List, 3))?;
4316    o_prot.write_list_begin(&TListIdentifier::new(TType::String, self.path_in_schema.len() as i32))?;
4317    for e in &self.path_in_schema {
4318      o_prot.write_string(e)?;
4319    }
4320    o_prot.write_list_end()?;
4321    o_prot.write_field_end()?;
4322    o_prot.write_field_begin(&TFieldIdentifier::new("codec", TType::I32, 4))?;
4323    self.codec.write_to_out_protocol(o_prot)?;
4324    o_prot.write_field_end()?;
4325    o_prot.write_field_begin(&TFieldIdentifier::new("num_values", TType::I64, 5))?;
4326    o_prot.write_i64(self.num_values)?;
4327    o_prot.write_field_end()?;
4328    o_prot.write_field_begin(&TFieldIdentifier::new("total_uncompressed_size", TType::I64, 6))?;
4329    o_prot.write_i64(self.total_uncompressed_size)?;
4330    o_prot.write_field_end()?;
4331    o_prot.write_field_begin(&TFieldIdentifier::new("total_compressed_size", TType::I64, 7))?;
4332    o_prot.write_i64(self.total_compressed_size)?;
4333    o_prot.write_field_end()?;
4334    if let Some(ref fld_var) = self.key_value_metadata {
4335      o_prot.write_field_begin(&TFieldIdentifier::new("key_value_metadata", TType::List, 8))?;
4336      o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, fld_var.len() as i32))?;
4337      for e in fld_var {
4338        e.write_to_out_protocol(o_prot)?;
4339      }
4340      o_prot.write_list_end()?;
4341      o_prot.write_field_end()?
4342    }
4343    o_prot.write_field_begin(&TFieldIdentifier::new("data_page_offset", TType::I64, 9))?;
4344    o_prot.write_i64(self.data_page_offset)?;
4345    o_prot.write_field_end()?;
4346    if let Some(fld_var) = self.index_page_offset {
4347      o_prot.write_field_begin(&TFieldIdentifier::new("index_page_offset", TType::I64, 10))?;
4348      o_prot.write_i64(fld_var)?;
4349      o_prot.write_field_end()?
4350    }
4351    if let Some(fld_var) = self.dictionary_page_offset {
4352      o_prot.write_field_begin(&TFieldIdentifier::new("dictionary_page_offset", TType::I64, 11))?;
4353      o_prot.write_i64(fld_var)?;
4354      o_prot.write_field_end()?
4355    }
4356    if let Some(ref fld_var) = self.statistics {
4357      o_prot.write_field_begin(&TFieldIdentifier::new("statistics", TType::Struct, 12))?;
4358      fld_var.write_to_out_protocol(o_prot)?;
4359      o_prot.write_field_end()?
4360    }
4361    if let Some(ref fld_var) = self.encoding_stats {
4362      o_prot.write_field_begin(&TFieldIdentifier::new("encoding_stats", TType::List, 13))?;
4363      o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, fld_var.len() as i32))?;
4364      for e in fld_var {
4365        e.write_to_out_protocol(o_prot)?;
4366      }
4367      o_prot.write_list_end()?;
4368      o_prot.write_field_end()?
4369    }
4370    if let Some(fld_var) = self.bloom_filter_offset {
4371      o_prot.write_field_begin(&TFieldIdentifier::new("bloom_filter_offset", TType::I64, 14))?;
4372      o_prot.write_i64(fld_var)?;
4373      o_prot.write_field_end()?
4374    }
4375    if let Some(fld_var) = self.bloom_filter_length {
4376      o_prot.write_field_begin(&TFieldIdentifier::new("bloom_filter_length", TType::I32, 15))?;
4377      o_prot.write_i32(fld_var)?;
4378      o_prot.write_field_end()?
4379    }
4380    if let Some(ref fld_var) = self.size_statistics {
4381      o_prot.write_field_begin(&TFieldIdentifier::new("size_statistics", TType::Struct, 16))?;
4382      fld_var.write_to_out_protocol(o_prot)?;
4383      o_prot.write_field_end()?
4384    }
4385    if let Some(ref fld_var) = self.geospatial_statistics {
4386      o_prot.write_field_begin(&TFieldIdentifier::new("geospatial_statistics", TType::Struct, 17))?;
4387      fld_var.write_to_out_protocol(o_prot)?;
4388      o_prot.write_field_end()?
4389    }
4390    o_prot.write_field_stop()?;
4391    o_prot.write_struct_end()
4392  }
4393}
4394
4395//
4396// EncryptionWithFooterKey
4397//
4398
4399#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
4400pub struct EncryptionWithFooterKey {
4401}
4402
4403impl EncryptionWithFooterKey {
4404  pub fn new() -> EncryptionWithFooterKey {
4405    EncryptionWithFooterKey {}
4406  }
4407}
4408
4409impl crate::thrift::TSerializable for EncryptionWithFooterKey {
4410  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<EncryptionWithFooterKey> {
4411    i_prot.read_struct_begin()?;
4412    loop {
4413      let field_ident = i_prot.read_field_begin()?;
4414      if field_ident.field_type == TType::Stop {
4415        break;
4416      }
4417      i_prot.skip(field_ident.field_type)?;
4418      i_prot.read_field_end()?;
4419    }
4420    i_prot.read_struct_end()?;
4421    let ret = EncryptionWithFooterKey {};
4422    Ok(ret)
4423  }
4424  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
4425    let struct_ident = TStructIdentifier::new("EncryptionWithFooterKey");
4426    o_prot.write_struct_begin(&struct_ident)?;
4427    o_prot.write_field_stop()?;
4428    o_prot.write_struct_end()
4429  }
4430}
4431
4432//
4433// EncryptionWithColumnKey
4434//
4435
4436#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
4437pub struct EncryptionWithColumnKey {
4438  /// Column path in schema *
4439  pub path_in_schema: Vec<String>,
4440  /// Retrieval metadata of column encryption key *
4441  pub key_metadata: Option<Vec<u8>>,
4442}
4443
4444impl EncryptionWithColumnKey {
4445  pub fn new<F2>(path_in_schema: Vec<String>, key_metadata: F2) -> EncryptionWithColumnKey where F2: Into<Option<Vec<u8>>> {
4446    EncryptionWithColumnKey {
4447      path_in_schema,
4448      key_metadata: key_metadata.into(),
4449    }
4450  }
4451}
4452
4453impl crate::thrift::TSerializable for EncryptionWithColumnKey {
4454  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<EncryptionWithColumnKey> {
4455    i_prot.read_struct_begin()?;
4456    let mut f_1: Option<Vec<String>> = None;
4457    let mut f_2: Option<Vec<u8>> = None;
4458    loop {
4459      let field_ident = i_prot.read_field_begin()?;
4460      if field_ident.field_type == TType::Stop {
4461        break;
4462      }
4463      let field_id = field_id(&field_ident)?;
4464      match field_id {
4465        1 => {
4466          let list_ident = i_prot.read_list_begin()?;
4467          let mut val: Vec<String> = Vec::with_capacity(list_ident.size as usize);
4468          for _ in 0..list_ident.size {
4469            let list_elem_7 = i_prot.read_string()?;
4470            val.push(list_elem_7);
4471          }
4472          i_prot.read_list_end()?;
4473          f_1 = Some(val);
4474        },
4475        2 => {
4476          let val = i_prot.read_bytes()?;
4477          f_2 = Some(val);
4478        },
4479        _ => {
4480          i_prot.skip(field_ident.field_type)?;
4481        },
4482      };
4483      i_prot.read_field_end()?;
4484    }
4485    i_prot.read_struct_end()?;
4486    verify_required_field_exists("EncryptionWithColumnKey.path_in_schema", &f_1)?;
4487    let ret = EncryptionWithColumnKey {
4488      path_in_schema: f_1.expect("auto-generated code should have checked for presence of required fields"),
4489      key_metadata: f_2,
4490    };
4491    Ok(ret)
4492  }
4493  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
4494    let struct_ident = TStructIdentifier::new("EncryptionWithColumnKey");
4495    o_prot.write_struct_begin(&struct_ident)?;
4496    o_prot.write_field_begin(&TFieldIdentifier::new("path_in_schema", TType::List, 1))?;
4497    o_prot.write_list_begin(&TListIdentifier::new(TType::String, self.path_in_schema.len() as i32))?;
4498    for e in &self.path_in_schema {
4499      o_prot.write_string(e)?;
4500    }
4501    o_prot.write_list_end()?;
4502    o_prot.write_field_end()?;
4503    if let Some(ref fld_var) = self.key_metadata {
4504      o_prot.write_field_begin(&TFieldIdentifier::new("key_metadata", TType::String, 2))?;
4505      o_prot.write_bytes(fld_var)?;
4506      o_prot.write_field_end()?
4507    }
4508    o_prot.write_field_stop()?;
4509    o_prot.write_struct_end()
4510  }
4511}
4512
4513//
4514// ColumnCryptoMetaData
4515//
4516
4517#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
4518pub enum ColumnCryptoMetaData {
4519  ENCRYPTIONWITHFOOTERKEY(EncryptionWithFooterKey),
4520  ENCRYPTIONWITHCOLUMNKEY(EncryptionWithColumnKey),
4521}
4522
4523impl crate::thrift::TSerializable for ColumnCryptoMetaData {
4524  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<ColumnCryptoMetaData> {
4525    let mut ret: Option<ColumnCryptoMetaData> = None;
4526    let mut received_field_count = 0;
4527    i_prot.read_struct_begin()?;
4528    loop {
4529      let field_ident = i_prot.read_field_begin()?;
4530      if field_ident.field_type == TType::Stop {
4531        break;
4532      }
4533      let field_id = field_id(&field_ident)?;
4534      match field_id {
4535        1 => {
4536          let val = EncryptionWithFooterKey::read_from_in_protocol(i_prot)?;
4537          if ret.is_none() {
4538            ret = Some(ColumnCryptoMetaData::ENCRYPTIONWITHFOOTERKEY(val));
4539          }
4540          received_field_count += 1;
4541        },
4542        2 => {
4543          let val = EncryptionWithColumnKey::read_from_in_protocol(i_prot)?;
4544          if ret.is_none() {
4545            ret = Some(ColumnCryptoMetaData::ENCRYPTIONWITHCOLUMNKEY(val));
4546          }
4547          received_field_count += 1;
4548        },
4549        _ => {
4550          i_prot.skip(field_ident.field_type)?;
4551          received_field_count += 1;
4552        },
4553      };
4554      i_prot.read_field_end()?;
4555    }
4556    i_prot.read_struct_end()?;
4557    if received_field_count == 0 {
4558      Err(
4559        thrift::Error::Protocol(
4560          ProtocolError::new(
4561            ProtocolErrorKind::InvalidData,
4562            "received empty union from remote ColumnCryptoMetaData"
4563          )
4564        )
4565      )
4566    } else if received_field_count > 1 {
4567      Err(
4568        thrift::Error::Protocol(
4569          ProtocolError::new(
4570            ProtocolErrorKind::InvalidData,
4571            "received multiple fields for union from remote ColumnCryptoMetaData"
4572          )
4573        )
4574      )
4575    } else {
4576      ret.ok_or_else(|| thrift::Error::Protocol(ProtocolError::new(ProtocolErrorKind::InvalidData, "return value should have been constructed")))
4577    }
4578  }
4579  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
4580    let struct_ident = TStructIdentifier::new("ColumnCryptoMetaData");
4581    o_prot.write_struct_begin(&struct_ident)?;
4582    match *self {
4583      ColumnCryptoMetaData::ENCRYPTIONWITHFOOTERKEY(ref f) => {
4584        o_prot.write_field_begin(&TFieldIdentifier::new("ENCRYPTION_WITH_FOOTER_KEY", TType::Struct, 1))?;
4585        f.write_to_out_protocol(o_prot)?;
4586        o_prot.write_field_end()?;
4587      },
4588      ColumnCryptoMetaData::ENCRYPTIONWITHCOLUMNKEY(ref f) => {
4589        o_prot.write_field_begin(&TFieldIdentifier::new("ENCRYPTION_WITH_COLUMN_KEY", TType::Struct, 2))?;
4590        f.write_to_out_protocol(o_prot)?;
4591        o_prot.write_field_end()?;
4592      },
4593    }
4594    o_prot.write_field_stop()?;
4595    o_prot.write_struct_end()
4596  }
4597}
4598
4599//
4600// ColumnChunk
4601//
4602
4603#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
4604pub struct ColumnChunk {
4605  /// File where column data is stored.  If not set, assumed to be same file as
4606  /// metadata.  This path is relative to the current file.
4607  /// 
4608  pub file_path: Option<String>,
4609  /// Deprecated: Byte offset in file_path to the ColumnMetaData
4610  /// 
4611  /// Past use of this field has been inconsistent, with some implementations
4612  /// using it to point to the ColumnMetaData and some using it to point to
4613  /// the first page in the column chunk. In many cases, the ColumnMetaData at this
4614  /// location is wrong. This field is now deprecated and should not be used.
4615  /// Writers should set this field to 0 if no ColumnMetaData has been written outside
4616  /// the footer.
4617  pub file_offset: i64,
4618  /// Column metadata for this chunk. Some writers may also replicate this at the
4619  /// location pointed to by file_path/file_offset.
4620  /// Note: while marked as optional, this field is in fact required by most major
4621  /// Parquet implementations. As such, writers MUST populate this field.
4622  /// 
4623  pub meta_data: Option<ColumnMetaData>,
4624  /// File offset of ColumnChunk's OffsetIndex *
4625  pub offset_index_offset: Option<i64>,
4626  /// Size of ColumnChunk's OffsetIndex, in bytes *
4627  pub offset_index_length: Option<i32>,
4628  /// File offset of ColumnChunk's ColumnIndex *
4629  pub column_index_offset: Option<i64>,
4630  /// Size of ColumnChunk's ColumnIndex, in bytes *
4631  pub column_index_length: Option<i32>,
4632  /// Crypto metadata of encrypted columns *
4633  pub crypto_metadata: Option<ColumnCryptoMetaData>,
4634  /// Encrypted column metadata for this chunk *
4635  pub encrypted_column_metadata: Option<Vec<u8>>,
4636}
4637
4638impl ColumnChunk {
4639  pub fn new<F1, F3, F4, F5, F6, F7, F8, F9>(file_path: F1, file_offset: i64, meta_data: F3, offset_index_offset: F4, offset_index_length: F5, column_index_offset: F6, column_index_length: F7, crypto_metadata: F8, encrypted_column_metadata: F9) -> ColumnChunk where F1: Into<Option<String>>, F3: Into<Option<ColumnMetaData>>, F4: Into<Option<i64>>, F5: Into<Option<i32>>, F6: Into<Option<i64>>, F7: Into<Option<i32>>, F8: Into<Option<ColumnCryptoMetaData>>, F9: Into<Option<Vec<u8>>> {
4640    ColumnChunk {
4641      file_path: file_path.into(),
4642      file_offset,
4643      meta_data: meta_data.into(),
4644      offset_index_offset: offset_index_offset.into(),
4645      offset_index_length: offset_index_length.into(),
4646      column_index_offset: column_index_offset.into(),
4647      column_index_length: column_index_length.into(),
4648      crypto_metadata: crypto_metadata.into(),
4649      encrypted_column_metadata: encrypted_column_metadata.into(),
4650    }
4651  }
4652}
4653
4654impl crate::thrift::TSerializable for ColumnChunk {
4655  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<ColumnChunk> {
4656    i_prot.read_struct_begin()?;
4657    let mut f_1: Option<String> = None;
4658    let mut f_2: Option<i64> = None;
4659    let mut f_3: Option<ColumnMetaData> = None;
4660    let mut f_4: Option<i64> = None;
4661    let mut f_5: Option<i32> = None;
4662    let mut f_6: Option<i64> = None;
4663    let mut f_7: Option<i32> = None;
4664    let mut f_8: Option<ColumnCryptoMetaData> = None;
4665    let mut f_9: Option<Vec<u8>> = None;
4666    loop {
4667      let field_ident = i_prot.read_field_begin()?;
4668      if field_ident.field_type == TType::Stop {
4669        break;
4670      }
4671      let field_id = field_id(&field_ident)?;
4672      match field_id {
4673        1 => {
4674          let val = i_prot.read_string()?;
4675          f_1 = Some(val);
4676        },
4677        2 => {
4678          let val = i_prot.read_i64()?;
4679          f_2 = Some(val);
4680        },
4681        3 => {
4682          let val = ColumnMetaData::read_from_in_protocol(i_prot)?;
4683          f_3 = Some(val);
4684        },
4685        4 => {
4686          let val = i_prot.read_i64()?;
4687          f_4 = Some(val);
4688        },
4689        5 => {
4690          let val = i_prot.read_i32()?;
4691          f_5 = Some(val);
4692        },
4693        6 => {
4694          let val = i_prot.read_i64()?;
4695          f_6 = Some(val);
4696        },
4697        7 => {
4698          let val = i_prot.read_i32()?;
4699          f_7 = Some(val);
4700        },
4701        8 => {
4702          let val = ColumnCryptoMetaData::read_from_in_protocol(i_prot)?;
4703          f_8 = Some(val);
4704        },
4705        9 => {
4706          let val = i_prot.read_bytes()?;
4707          f_9 = Some(val);
4708        },
4709        _ => {
4710          i_prot.skip(field_ident.field_type)?;
4711        },
4712      };
4713      i_prot.read_field_end()?;
4714    }
4715    i_prot.read_struct_end()?;
4716    verify_required_field_exists("ColumnChunk.file_offset", &f_2)?;
4717    let ret = ColumnChunk {
4718      file_path: f_1,
4719      file_offset: f_2.expect("auto-generated code should have checked for presence of required fields"),
4720      meta_data: f_3,
4721      offset_index_offset: f_4,
4722      offset_index_length: f_5,
4723      column_index_offset: f_6,
4724      column_index_length: f_7,
4725      crypto_metadata: f_8,
4726      encrypted_column_metadata: f_9,
4727    };
4728    Ok(ret)
4729  }
4730  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
4731    let struct_ident = TStructIdentifier::new("ColumnChunk");
4732    o_prot.write_struct_begin(&struct_ident)?;
4733    if let Some(ref fld_var) = self.file_path {
4734      o_prot.write_field_begin(&TFieldIdentifier::new("file_path", TType::String, 1))?;
4735      o_prot.write_string(fld_var)?;
4736      o_prot.write_field_end()?
4737    }
4738    o_prot.write_field_begin(&TFieldIdentifier::new("file_offset", TType::I64, 2))?;
4739    o_prot.write_i64(self.file_offset)?;
4740    o_prot.write_field_end()?;
4741    if let Some(ref fld_var) = self.meta_data {
4742      o_prot.write_field_begin(&TFieldIdentifier::new("meta_data", TType::Struct, 3))?;
4743      fld_var.write_to_out_protocol(o_prot)?;
4744      o_prot.write_field_end()?
4745    }
4746    if let Some(fld_var) = self.offset_index_offset {
4747      o_prot.write_field_begin(&TFieldIdentifier::new("offset_index_offset", TType::I64, 4))?;
4748      o_prot.write_i64(fld_var)?;
4749      o_prot.write_field_end()?
4750    }
4751    if let Some(fld_var) = self.offset_index_length {
4752      o_prot.write_field_begin(&TFieldIdentifier::new("offset_index_length", TType::I32, 5))?;
4753      o_prot.write_i32(fld_var)?;
4754      o_prot.write_field_end()?
4755    }
4756    if let Some(fld_var) = self.column_index_offset {
4757      o_prot.write_field_begin(&TFieldIdentifier::new("column_index_offset", TType::I64, 6))?;
4758      o_prot.write_i64(fld_var)?;
4759      o_prot.write_field_end()?
4760    }
4761    if let Some(fld_var) = self.column_index_length {
4762      o_prot.write_field_begin(&TFieldIdentifier::new("column_index_length", TType::I32, 7))?;
4763      o_prot.write_i32(fld_var)?;
4764      o_prot.write_field_end()?
4765    }
4766    if let Some(ref fld_var) = self.crypto_metadata {
4767      o_prot.write_field_begin(&TFieldIdentifier::new("crypto_metadata", TType::Struct, 8))?;
4768      fld_var.write_to_out_protocol(o_prot)?;
4769      o_prot.write_field_end()?
4770    }
4771    if let Some(ref fld_var) = self.encrypted_column_metadata {
4772      o_prot.write_field_begin(&TFieldIdentifier::new("encrypted_column_metadata", TType::String, 9))?;
4773      o_prot.write_bytes(fld_var)?;
4774      o_prot.write_field_end()?
4775    }
4776    o_prot.write_field_stop()?;
4777    o_prot.write_struct_end()
4778  }
4779}
4780
4781//
4782// RowGroup
4783//
4784
4785#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
4786pub struct RowGroup {
4787  /// Metadata for each column chunk in this row group.
4788  /// This list must have the same order as the SchemaElement list in FileMetaData.
4789  /// 
4790  pub columns: Vec<ColumnChunk>,
4791  /// Total byte size of all the uncompressed column data in this row group *
4792  pub total_byte_size: i64,
4793  /// Number of rows in this row group *
4794  pub num_rows: i64,
4795  /// If set, specifies a sort ordering of the rows in this RowGroup.
4796  /// The sorting columns can be a subset of all the columns.
4797  pub sorting_columns: Option<Vec<SortingColumn>>,
4798  /// Byte offset from beginning of file to first page (data or dictionary)
4799  /// in this row group *
4800  pub file_offset: Option<i64>,
4801  /// Total byte size of all compressed (and potentially encrypted) column data
4802  /// in this row group *
4803  pub total_compressed_size: Option<i64>,
4804  /// Row group ordinal in the file *
4805  pub ordinal: Option<i16>,
4806}
4807
4808impl RowGroup {
4809  pub fn new<F4, F5, F6, F7>(columns: Vec<ColumnChunk>, total_byte_size: i64, num_rows: i64, sorting_columns: F4, file_offset: F5, total_compressed_size: F6, ordinal: F7) -> RowGroup where F4: Into<Option<Vec<SortingColumn>>>, F5: Into<Option<i64>>, F6: Into<Option<i64>>, F7: Into<Option<i16>> {
4810    RowGroup {
4811      columns,
4812      total_byte_size,
4813      num_rows,
4814      sorting_columns: sorting_columns.into(),
4815      file_offset: file_offset.into(),
4816      total_compressed_size: total_compressed_size.into(),
4817      ordinal: ordinal.into(),
4818    }
4819  }
4820}
4821
4822impl crate::thrift::TSerializable for RowGroup {
4823  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<RowGroup> {
4824    i_prot.read_struct_begin()?;
4825    let mut f_1: Option<Vec<ColumnChunk>> = None;
4826    let mut f_2: Option<i64> = None;
4827    let mut f_3: Option<i64> = None;
4828    let mut f_4: Option<Vec<SortingColumn>> = None;
4829    let mut f_5: Option<i64> = None;
4830    let mut f_6: Option<i64> = None;
4831    let mut f_7: Option<i16> = None;
4832    loop {
4833      let field_ident = i_prot.read_field_begin()?;
4834      if field_ident.field_type == TType::Stop {
4835        break;
4836      }
4837      let field_id = field_id(&field_ident)?;
4838      match field_id {
4839        1 => {
4840          let list_ident = i_prot.read_list_begin()?;
4841          let mut val: Vec<ColumnChunk> = Vec::with_capacity(list_ident.size as usize);
4842          for _ in 0..list_ident.size {
4843            let list_elem_8 = ColumnChunk::read_from_in_protocol(i_prot)?;
4844            val.push(list_elem_8);
4845          }
4846          i_prot.read_list_end()?;
4847          f_1 = Some(val);
4848        },
4849        2 => {
4850          let val = i_prot.read_i64()?;
4851          f_2 = Some(val);
4852        },
4853        3 => {
4854          let val = i_prot.read_i64()?;
4855          f_3 = Some(val);
4856        },
4857        4 => {
4858          let list_ident = i_prot.read_list_begin()?;
4859          let mut val: Vec<SortingColumn> = Vec::with_capacity(list_ident.size as usize);
4860          for _ in 0..list_ident.size {
4861            let list_elem_9 = SortingColumn::read_from_in_protocol(i_prot)?;
4862            val.push(list_elem_9);
4863          }
4864          i_prot.read_list_end()?;
4865          f_4 = Some(val);
4866        },
4867        5 => {
4868          let val = i_prot.read_i64()?;
4869          f_5 = Some(val);
4870        },
4871        6 => {
4872          let val = i_prot.read_i64()?;
4873          f_6 = Some(val);
4874        },
4875        7 => {
4876          let val = i_prot.read_i16()?;
4877          f_7 = Some(val);
4878        },
4879        _ => {
4880          i_prot.skip(field_ident.field_type)?;
4881        },
4882      };
4883      i_prot.read_field_end()?;
4884    }
4885    i_prot.read_struct_end()?;
4886    verify_required_field_exists("RowGroup.columns", &f_1)?;
4887    verify_required_field_exists("RowGroup.total_byte_size", &f_2)?;
4888    verify_required_field_exists("RowGroup.num_rows", &f_3)?;
4889    let ret = RowGroup {
4890      columns: f_1.expect("auto-generated code should have checked for presence of required fields"),
4891      total_byte_size: f_2.expect("auto-generated code should have checked for presence of required fields"),
4892      num_rows: f_3.expect("auto-generated code should have checked for presence of required fields"),
4893      sorting_columns: f_4,
4894      file_offset: f_5,
4895      total_compressed_size: f_6,
4896      ordinal: f_7,
4897    };
4898    Ok(ret)
4899  }
4900  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
4901    let struct_ident = TStructIdentifier::new("RowGroup");
4902    o_prot.write_struct_begin(&struct_ident)?;
4903    o_prot.write_field_begin(&TFieldIdentifier::new("columns", TType::List, 1))?;
4904    o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, self.columns.len() as i32))?;
4905    for e in &self.columns {
4906      e.write_to_out_protocol(o_prot)?;
4907    }
4908    o_prot.write_list_end()?;
4909    o_prot.write_field_end()?;
4910    o_prot.write_field_begin(&TFieldIdentifier::new("total_byte_size", TType::I64, 2))?;
4911    o_prot.write_i64(self.total_byte_size)?;
4912    o_prot.write_field_end()?;
4913    o_prot.write_field_begin(&TFieldIdentifier::new("num_rows", TType::I64, 3))?;
4914    o_prot.write_i64(self.num_rows)?;
4915    o_prot.write_field_end()?;
4916    if let Some(ref fld_var) = self.sorting_columns {
4917      o_prot.write_field_begin(&TFieldIdentifier::new("sorting_columns", TType::List, 4))?;
4918      o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, fld_var.len() as i32))?;
4919      for e in fld_var {
4920        e.write_to_out_protocol(o_prot)?;
4921      }
4922      o_prot.write_list_end()?;
4923      o_prot.write_field_end()?
4924    }
4925    if let Some(fld_var) = self.file_offset {
4926      o_prot.write_field_begin(&TFieldIdentifier::new("file_offset", TType::I64, 5))?;
4927      o_prot.write_i64(fld_var)?;
4928      o_prot.write_field_end()?
4929    }
4930    if let Some(fld_var) = self.total_compressed_size {
4931      o_prot.write_field_begin(&TFieldIdentifier::new("total_compressed_size", TType::I64, 6))?;
4932      o_prot.write_i64(fld_var)?;
4933      o_prot.write_field_end()?
4934    }
4935    if let Some(fld_var) = self.ordinal {
4936      o_prot.write_field_begin(&TFieldIdentifier::new("ordinal", TType::I16, 7))?;
4937      o_prot.write_i16(fld_var)?;
4938      o_prot.write_field_end()?
4939    }
4940    o_prot.write_field_stop()?;
4941    o_prot.write_struct_end()
4942  }
4943}
4944
4945//
4946// TypeDefinedOrder
4947//
4948
4949/// Empty struct to signal the order defined by the physical or logical type
4950#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
4951pub struct TypeDefinedOrder {
4952}
4953
4954impl TypeDefinedOrder {
4955  pub fn new() -> TypeDefinedOrder {
4956    TypeDefinedOrder {}
4957  }
4958}
4959
4960impl crate::thrift::TSerializable for TypeDefinedOrder {
4961  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<TypeDefinedOrder> {
4962    i_prot.read_struct_begin()?;
4963    loop {
4964      let field_ident = i_prot.read_field_begin()?;
4965      if field_ident.field_type == TType::Stop {
4966        break;
4967      }
4968      i_prot.skip(field_ident.field_type)?;
4969      i_prot.read_field_end()?;
4970    }
4971    i_prot.read_struct_end()?;
4972    let ret = TypeDefinedOrder {};
4973    Ok(ret)
4974  }
4975  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
4976    let struct_ident = TStructIdentifier::new("TypeDefinedOrder");
4977    o_prot.write_struct_begin(&struct_ident)?;
4978    o_prot.write_field_stop()?;
4979    o_prot.write_struct_end()
4980  }
4981}
4982
4983//
4984// ColumnOrder
4985//
4986
4987#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
4988pub enum ColumnOrder {
4989  TYPEORDER(TypeDefinedOrder),
4990}
4991
4992impl crate::thrift::TSerializable for ColumnOrder {
4993  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<ColumnOrder> {
4994    let mut ret: Option<ColumnOrder> = None;
4995    let mut received_field_count = 0;
4996    i_prot.read_struct_begin()?;
4997    loop {
4998      let field_ident = i_prot.read_field_begin()?;
4999      if field_ident.field_type == TType::Stop {
5000        break;
5001      }
5002      let field_id = field_id(&field_ident)?;
5003      match field_id {
5004        1 => {
5005          let val = TypeDefinedOrder::read_from_in_protocol(i_prot)?;
5006          if ret.is_none() {
5007            ret = Some(ColumnOrder::TYPEORDER(val));
5008          }
5009          received_field_count += 1;
5010        },
5011        _ => {
5012          i_prot.skip(field_ident.field_type)?;
5013          received_field_count += 1;
5014        },
5015      };
5016      i_prot.read_field_end()?;
5017    }
5018    i_prot.read_struct_end()?;
5019    if received_field_count == 0 {
5020      Err(
5021        thrift::Error::Protocol(
5022          ProtocolError::new(
5023            ProtocolErrorKind::InvalidData,
5024            "received empty union from remote ColumnOrder"
5025          )
5026        )
5027      )
5028    } else if received_field_count > 1 {
5029      Err(
5030        thrift::Error::Protocol(
5031          ProtocolError::new(
5032            ProtocolErrorKind::InvalidData,
5033            "received multiple fields for union from remote ColumnOrder"
5034          )
5035        )
5036      )
5037    } else {
5038      ret.ok_or_else(|| thrift::Error::Protocol(ProtocolError::new(ProtocolErrorKind::InvalidData, "return value should have been constructed")))
5039    }
5040  }
5041  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
5042    let struct_ident = TStructIdentifier::new("ColumnOrder");
5043    o_prot.write_struct_begin(&struct_ident)?;
5044    match *self {
5045      ColumnOrder::TYPEORDER(ref f) => {
5046        o_prot.write_field_begin(&TFieldIdentifier::new("TYPE_ORDER", TType::Struct, 1))?;
5047        f.write_to_out_protocol(o_prot)?;
5048        o_prot.write_field_end()?;
5049      },
5050    }
5051    o_prot.write_field_stop()?;
5052    o_prot.write_struct_end()
5053  }
5054}
5055
5056//
5057// PageLocation
5058//
5059
5060#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
5061pub struct PageLocation {
5062  /// Offset of the page in the file *
5063  pub offset: i64,
5064  /// Size of the page, including header. Sum of compressed_page_size and header
5065  /// length
5066  pub compressed_page_size: i32,
5067  /// Index within the RowGroup of the first row of the page. When an
5068  /// OffsetIndex is present, pages must begin on row boundaries
5069  /// (repetition_level = 0).
5070  pub first_row_index: i64,
5071}
5072
5073impl PageLocation {
5074  pub fn new(offset: i64, compressed_page_size: i32, first_row_index: i64) -> PageLocation {
5075    PageLocation {
5076      offset,
5077      compressed_page_size,
5078      first_row_index,
5079    }
5080  }
5081}
5082
5083impl crate::thrift::TSerializable for PageLocation {
5084  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<PageLocation> {
5085    i_prot.read_struct_begin()?;
5086    let mut f_1: Option<i64> = None;
5087    let mut f_2: Option<i32> = None;
5088    let mut f_3: Option<i64> = None;
5089    loop {
5090      let field_ident = i_prot.read_field_begin()?;
5091      if field_ident.field_type == TType::Stop {
5092        break;
5093      }
5094      let field_id = field_id(&field_ident)?;
5095      match field_id {
5096        1 => {
5097          let val = i_prot.read_i64()?;
5098          f_1 = Some(val);
5099        },
5100        2 => {
5101          let val = i_prot.read_i32()?;
5102          f_2 = Some(val);
5103        },
5104        3 => {
5105          let val = i_prot.read_i64()?;
5106          f_3 = Some(val);
5107        },
5108        _ => {
5109          i_prot.skip(field_ident.field_type)?;
5110        },
5111      };
5112      i_prot.read_field_end()?;
5113    }
5114    i_prot.read_struct_end()?;
5115    verify_required_field_exists("PageLocation.offset", &f_1)?;
5116    verify_required_field_exists("PageLocation.compressed_page_size", &f_2)?;
5117    verify_required_field_exists("PageLocation.first_row_index", &f_3)?;
5118    let ret = PageLocation {
5119      offset: f_1.expect("auto-generated code should have checked for presence of required fields"),
5120      compressed_page_size: f_2.expect("auto-generated code should have checked for presence of required fields"),
5121      first_row_index: f_3.expect("auto-generated code should have checked for presence of required fields"),
5122    };
5123    Ok(ret)
5124  }
5125  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
5126    let struct_ident = TStructIdentifier::new("PageLocation");
5127    o_prot.write_struct_begin(&struct_ident)?;
5128    o_prot.write_field_begin(&TFieldIdentifier::new("offset", TType::I64, 1))?;
5129    o_prot.write_i64(self.offset)?;
5130    o_prot.write_field_end()?;
5131    o_prot.write_field_begin(&TFieldIdentifier::new("compressed_page_size", TType::I32, 2))?;
5132    o_prot.write_i32(self.compressed_page_size)?;
5133    o_prot.write_field_end()?;
5134    o_prot.write_field_begin(&TFieldIdentifier::new("first_row_index", TType::I64, 3))?;
5135    o_prot.write_i64(self.first_row_index)?;
5136    o_prot.write_field_end()?;
5137    o_prot.write_field_stop()?;
5138    o_prot.write_struct_end()
5139  }
5140}
5141
5142//
5143// OffsetIndex
5144//
5145
5146/// Optional offsets for each data page in a ColumnChunk.
5147/// 
5148/// Forms part of the page index, along with ColumnIndex.
5149/// 
5150/// OffsetIndex may be present even if ColumnIndex is not.
5151#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
5152pub struct OffsetIndex {
5153  /// PageLocations, ordered by increasing PageLocation.offset. It is required
5154  /// that page_locations\[i\].first_row_index < page_locations\[i+1\].first_row_index.
5155  pub page_locations: Vec<PageLocation>,
5156  /// Unencoded/uncompressed size for BYTE_ARRAY types.
5157  /// 
5158  /// See documention for unencoded_byte_array_data_bytes in SizeStatistics for
5159  /// more details on this field.
5160  pub unencoded_byte_array_data_bytes: Option<Vec<i64>>,
5161}
5162
5163impl OffsetIndex {
5164  pub fn new<F2>(page_locations: Vec<PageLocation>, unencoded_byte_array_data_bytes: F2) -> OffsetIndex where F2: Into<Option<Vec<i64>>> {
5165    OffsetIndex {
5166      page_locations,
5167      unencoded_byte_array_data_bytes: unencoded_byte_array_data_bytes.into(),
5168    }
5169  }
5170}
5171
5172impl crate::thrift::TSerializable for OffsetIndex {
5173  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<OffsetIndex> {
5174    i_prot.read_struct_begin()?;
5175    let mut f_1: Option<Vec<PageLocation>> = None;
5176    let mut f_2: Option<Vec<i64>> = None;
5177    loop {
5178      let field_ident = i_prot.read_field_begin()?;
5179      if field_ident.field_type == TType::Stop {
5180        break;
5181      }
5182      let field_id = field_id(&field_ident)?;
5183      match field_id {
5184        1 => {
5185          let list_ident = i_prot.read_list_begin()?;
5186          let mut val: Vec<PageLocation> = Vec::with_capacity(list_ident.size as usize);
5187          for _ in 0..list_ident.size {
5188            let list_elem_10 = PageLocation::read_from_in_protocol(i_prot)?;
5189            val.push(list_elem_10);
5190          }
5191          i_prot.read_list_end()?;
5192          f_1 = Some(val);
5193        },
5194        2 => {
5195          let list_ident = i_prot.read_list_begin()?;
5196          let mut val: Vec<i64> = Vec::with_capacity(list_ident.size as usize);
5197          for _ in 0..list_ident.size {
5198            let list_elem_11 = i_prot.read_i64()?;
5199            val.push(list_elem_11);
5200          }
5201          i_prot.read_list_end()?;
5202          f_2 = Some(val);
5203        },
5204        _ => {
5205          i_prot.skip(field_ident.field_type)?;
5206        },
5207      };
5208      i_prot.read_field_end()?;
5209    }
5210    i_prot.read_struct_end()?;
5211    verify_required_field_exists("OffsetIndex.page_locations", &f_1)?;
5212    let ret = OffsetIndex {
5213      page_locations: f_1.expect("auto-generated code should have checked for presence of required fields"),
5214      unencoded_byte_array_data_bytes: f_2,
5215    };
5216    Ok(ret)
5217  }
5218  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
5219    let struct_ident = TStructIdentifier::new("OffsetIndex");
5220    o_prot.write_struct_begin(&struct_ident)?;
5221    o_prot.write_field_begin(&TFieldIdentifier::new("page_locations", TType::List, 1))?;
5222    o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, self.page_locations.len() as i32))?;
5223    for e in &self.page_locations {
5224      e.write_to_out_protocol(o_prot)?;
5225    }
5226    o_prot.write_list_end()?;
5227    o_prot.write_field_end()?;
5228    if let Some(ref fld_var) = self.unencoded_byte_array_data_bytes {
5229      o_prot.write_field_begin(&TFieldIdentifier::new("unencoded_byte_array_data_bytes", TType::List, 2))?;
5230      o_prot.write_list_begin(&TListIdentifier::new(TType::I64, fld_var.len() as i32))?;
5231      for e in fld_var {
5232        o_prot.write_i64(*e)?;
5233      }
5234      o_prot.write_list_end()?;
5235      o_prot.write_field_end()?
5236    }
5237    o_prot.write_field_stop()?;
5238    o_prot.write_struct_end()
5239  }
5240}
5241
5242//
5243// ColumnIndex
5244//
5245
5246/// Optional statistics for each data page in a ColumnChunk.
5247/// 
5248/// Forms part the page index, along with OffsetIndex.
5249/// 
5250/// If this structure is present, OffsetIndex must also be present.
5251/// 
5252/// For each field in this structure, `<field>`\[i\] refers to the page at
5253/// OffsetIndex.page_locations\[i\]
5254#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
5255pub struct ColumnIndex {
5256  /// A list of Boolean values to determine the validity of the corresponding
5257  /// min and max values. If true, a page contains only null values, and writers
5258  /// have to set the corresponding entries in min_values and max_values to
5259  /// byte\[0\], so that all lists have the same length. If false, the
5260  /// corresponding entries in min_values and max_values must be valid.
5261  pub null_pages: Vec<bool>,
5262  /// Two lists containing lower and upper bounds for the values of each page
5263  /// determined by the ColumnOrder of the column. These may be the actual
5264  /// minimum and maximum values found on a page, but can also be (more compact)
5265  /// values that do not exist on a page. For example, instead of storing ""Blart
5266  /// Versenwald III", a writer may set min_values\[i\]="B", max_values\[i\]="C".
5267  /// Such more compact values must still be valid values within the column's
5268  /// logical type. Readers must make sure that list entries are populated before
5269  /// using them by inspecting null_pages.
5270  pub min_values: Vec<Vec<u8>>,
5271  pub max_values: Vec<Vec<u8>>,
5272  /// Stores whether both min_values and max_values are ordered and if so, in
5273  /// which direction. This allows readers to perform binary searches in both
5274  /// lists. Readers cannot assume that max_values\[i\] <= min_values\[i+1\], even
5275  /// if the lists are ordered.
5276  pub boundary_order: BoundaryOrder,
5277  /// A list containing the number of null values for each page
5278  /// 
5279  /// Writers SHOULD always write this field even if no null values
5280  /// are present or the column is not nullable.
5281  /// Readers MUST distinguish between null_counts not being present
5282  /// and null_count being 0.
5283  /// If null_counts are not present, readers MUST NOT assume all
5284  /// null counts are 0.
5285  pub null_counts: Option<Vec<i64>>,
5286  /// Contains repetition level histograms for each page
5287  /// concatenated together.  The repetition_level_histogram field on
5288  /// SizeStatistics contains more details.
5289  /// 
5290  /// When present the length should always be (number of pages *
5291  /// (max_repetition_level + 1)) elements.
5292  /// 
5293  /// Element 0 is the first element of the histogram for the first page.
5294  /// Element (max_repetition_level + 1) is the first element of the histogram
5295  /// for the second page.
5296  /// 
5297  pub repetition_level_histograms: Option<Vec<i64>>,
5298  /// Same as repetition_level_histograms except for definitions levels.
5299  /// 
5300  pub definition_level_histograms: Option<Vec<i64>>,
5301}
5302
5303impl ColumnIndex {
5304  pub fn new<F5, F6, F7>(null_pages: Vec<bool>, min_values: Vec<Vec<u8>>, max_values: Vec<Vec<u8>>, boundary_order: BoundaryOrder, null_counts: F5, repetition_level_histograms: F6, definition_level_histograms: F7) -> ColumnIndex where F5: Into<Option<Vec<i64>>>, F6: Into<Option<Vec<i64>>>, F7: Into<Option<Vec<i64>>> {
5305    ColumnIndex {
5306      null_pages,
5307      min_values,
5308      max_values,
5309      boundary_order,
5310      null_counts: null_counts.into(),
5311      repetition_level_histograms: repetition_level_histograms.into(),
5312      definition_level_histograms: definition_level_histograms.into(),
5313    }
5314  }
5315}
5316
5317impl crate::thrift::TSerializable for ColumnIndex {
5318  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<ColumnIndex> {
5319    i_prot.read_struct_begin()?;
5320    let mut f_1: Option<Vec<bool>> = None;
5321    let mut f_2: Option<Vec<Vec<u8>>> = None;
5322    let mut f_3: Option<Vec<Vec<u8>>> = None;
5323    let mut f_4: Option<BoundaryOrder> = None;
5324    let mut f_5: Option<Vec<i64>> = None;
5325    let mut f_6: Option<Vec<i64>> = None;
5326    let mut f_7: Option<Vec<i64>> = None;
5327    loop {
5328      let field_ident = i_prot.read_field_begin()?;
5329      if field_ident.field_type == TType::Stop {
5330        break;
5331      }
5332      let field_id = field_id(&field_ident)?;
5333      match field_id {
5334        1 => {
5335          let list_ident = i_prot.read_list_begin()?;
5336          let mut val: Vec<bool> = Vec::with_capacity(list_ident.size as usize);
5337          for _ in 0..list_ident.size {
5338            let list_elem_12 = i_prot.read_bool()?;
5339            val.push(list_elem_12);
5340          }
5341          i_prot.read_list_end()?;
5342          f_1 = Some(val);
5343        },
5344        2 => {
5345          let list_ident = i_prot.read_list_begin()?;
5346          let mut val: Vec<Vec<u8>> = Vec::with_capacity(list_ident.size as usize);
5347          for _ in 0..list_ident.size {
5348            let list_elem_13 = i_prot.read_bytes()?;
5349            val.push(list_elem_13);
5350          }
5351          i_prot.read_list_end()?;
5352          f_2 = Some(val);
5353        },
5354        3 => {
5355          let list_ident = i_prot.read_list_begin()?;
5356          let mut val: Vec<Vec<u8>> = Vec::with_capacity(list_ident.size as usize);
5357          for _ in 0..list_ident.size {
5358            let list_elem_14 = i_prot.read_bytes()?;
5359            val.push(list_elem_14);
5360          }
5361          i_prot.read_list_end()?;
5362          f_3 = Some(val);
5363        },
5364        4 => {
5365          let val = BoundaryOrder::read_from_in_protocol(i_prot)?;
5366          f_4 = Some(val);
5367        },
5368        5 => {
5369          let list_ident = i_prot.read_list_begin()?;
5370          let mut val: Vec<i64> = Vec::with_capacity(list_ident.size as usize);
5371          for _ in 0..list_ident.size {
5372            let list_elem_15 = i_prot.read_i64()?;
5373            val.push(list_elem_15);
5374          }
5375          i_prot.read_list_end()?;
5376          f_5 = Some(val);
5377        },
5378        6 => {
5379          let list_ident = i_prot.read_list_begin()?;
5380          let mut val: Vec<i64> = Vec::with_capacity(list_ident.size as usize);
5381          for _ in 0..list_ident.size {
5382            let list_elem_16 = i_prot.read_i64()?;
5383            val.push(list_elem_16);
5384          }
5385          i_prot.read_list_end()?;
5386          f_6 = Some(val);
5387        },
5388        7 => {
5389          let list_ident = i_prot.read_list_begin()?;
5390          let mut val: Vec<i64> = Vec::with_capacity(list_ident.size as usize);
5391          for _ in 0..list_ident.size {
5392            let list_elem_17 = i_prot.read_i64()?;
5393            val.push(list_elem_17);
5394          }
5395          i_prot.read_list_end()?;
5396          f_7 = Some(val);
5397        },
5398        _ => {
5399          i_prot.skip(field_ident.field_type)?;
5400        },
5401      };
5402      i_prot.read_field_end()?;
5403    }
5404    i_prot.read_struct_end()?;
5405    verify_required_field_exists("ColumnIndex.null_pages", &f_1)?;
5406    verify_required_field_exists("ColumnIndex.min_values", &f_2)?;
5407    verify_required_field_exists("ColumnIndex.max_values", &f_3)?;
5408    verify_required_field_exists("ColumnIndex.boundary_order", &f_4)?;
5409    let ret = ColumnIndex {
5410      null_pages: f_1.expect("auto-generated code should have checked for presence of required fields"),
5411      min_values: f_2.expect("auto-generated code should have checked for presence of required fields"),
5412      max_values: f_3.expect("auto-generated code should have checked for presence of required fields"),
5413      boundary_order: f_4.expect("auto-generated code should have checked for presence of required fields"),
5414      null_counts: f_5,
5415      repetition_level_histograms: f_6,
5416      definition_level_histograms: f_7,
5417    };
5418    Ok(ret)
5419  }
5420  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
5421    let struct_ident = TStructIdentifier::new("ColumnIndex");
5422    o_prot.write_struct_begin(&struct_ident)?;
5423    o_prot.write_field_begin(&TFieldIdentifier::new("null_pages", TType::List, 1))?;
5424    o_prot.write_list_begin(&TListIdentifier::new(TType::Bool, self.null_pages.len() as i32))?;
5425    for e in &self.null_pages {
5426      o_prot.write_bool(*e)?;
5427    }
5428    o_prot.write_list_end()?;
5429    o_prot.write_field_end()?;
5430    o_prot.write_field_begin(&TFieldIdentifier::new("min_values", TType::List, 2))?;
5431    o_prot.write_list_begin(&TListIdentifier::new(TType::String, self.min_values.len() as i32))?;
5432    for e in &self.min_values {
5433      o_prot.write_bytes(e)?;
5434    }
5435    o_prot.write_list_end()?;
5436    o_prot.write_field_end()?;
5437    o_prot.write_field_begin(&TFieldIdentifier::new("max_values", TType::List, 3))?;
5438    o_prot.write_list_begin(&TListIdentifier::new(TType::String, self.max_values.len() as i32))?;
5439    for e in &self.max_values {
5440      o_prot.write_bytes(e)?;
5441    }
5442    o_prot.write_list_end()?;
5443    o_prot.write_field_end()?;
5444    o_prot.write_field_begin(&TFieldIdentifier::new("boundary_order", TType::I32, 4))?;
5445    self.boundary_order.write_to_out_protocol(o_prot)?;
5446    o_prot.write_field_end()?;
5447    if let Some(ref fld_var) = self.null_counts {
5448      o_prot.write_field_begin(&TFieldIdentifier::new("null_counts", TType::List, 5))?;
5449      o_prot.write_list_begin(&TListIdentifier::new(TType::I64, fld_var.len() as i32))?;
5450      for e in fld_var {
5451        o_prot.write_i64(*e)?;
5452      }
5453      o_prot.write_list_end()?;
5454      o_prot.write_field_end()?
5455    }
5456    if let Some(ref fld_var) = self.repetition_level_histograms {
5457      o_prot.write_field_begin(&TFieldIdentifier::new("repetition_level_histograms", TType::List, 6))?;
5458      o_prot.write_list_begin(&TListIdentifier::new(TType::I64, fld_var.len() as i32))?;
5459      for e in fld_var {
5460        o_prot.write_i64(*e)?;
5461      }
5462      o_prot.write_list_end()?;
5463      o_prot.write_field_end()?
5464    }
5465    if let Some(ref fld_var) = self.definition_level_histograms {
5466      o_prot.write_field_begin(&TFieldIdentifier::new("definition_level_histograms", TType::List, 7))?;
5467      o_prot.write_list_begin(&TListIdentifier::new(TType::I64, fld_var.len() as i32))?;
5468      for e in fld_var {
5469        o_prot.write_i64(*e)?;
5470      }
5471      o_prot.write_list_end()?;
5472      o_prot.write_field_end()?
5473    }
5474    o_prot.write_field_stop()?;
5475    o_prot.write_struct_end()
5476  }
5477}
5478
5479//
5480// AesGcmV1
5481//
5482
5483#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
5484pub struct AesGcmV1 {
5485  /// AAD prefix *
5486  pub aad_prefix: Option<Vec<u8>>,
5487  /// Unique file identifier part of AAD suffix *
5488  pub aad_file_unique: Option<Vec<u8>>,
5489  /// In files encrypted with AAD prefix without storing it,
5490  /// readers must supply the prefix *
5491  pub supply_aad_prefix: Option<bool>,
5492}
5493
5494impl AesGcmV1 {
5495  pub fn new<F1, F2, F3>(aad_prefix: F1, aad_file_unique: F2, supply_aad_prefix: F3) -> AesGcmV1 where F1: Into<Option<Vec<u8>>>, F2: Into<Option<Vec<u8>>>, F3: Into<Option<bool>> {
5496    AesGcmV1 {
5497      aad_prefix: aad_prefix.into(),
5498      aad_file_unique: aad_file_unique.into(),
5499      supply_aad_prefix: supply_aad_prefix.into(),
5500    }
5501  }
5502}
5503
5504impl crate::thrift::TSerializable for AesGcmV1 {
5505  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<AesGcmV1> {
5506    i_prot.read_struct_begin()?;
5507    let mut f_1: Option<Vec<u8>> = None;
5508    let mut f_2: Option<Vec<u8>> = None;
5509    let mut f_3: Option<bool> = None;
5510    loop {
5511      let field_ident = i_prot.read_field_begin()?;
5512      if field_ident.field_type == TType::Stop {
5513        break;
5514      }
5515      let field_id = field_id(&field_ident)?;
5516      match field_id {
5517        1 => {
5518          let val = i_prot.read_bytes()?;
5519          f_1 = Some(val);
5520        },
5521        2 => {
5522          let val = i_prot.read_bytes()?;
5523          f_2 = Some(val);
5524        },
5525        3 => {
5526          let val = i_prot.read_bool()?;
5527          f_3 = Some(val);
5528        },
5529        _ => {
5530          i_prot.skip(field_ident.field_type)?;
5531        },
5532      };
5533      i_prot.read_field_end()?;
5534    }
5535    i_prot.read_struct_end()?;
5536    let ret = AesGcmV1 {
5537      aad_prefix: f_1,
5538      aad_file_unique: f_2,
5539      supply_aad_prefix: f_3,
5540    };
5541    Ok(ret)
5542  }
5543  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
5544    let struct_ident = TStructIdentifier::new("AesGcmV1");
5545    o_prot.write_struct_begin(&struct_ident)?;
5546    if let Some(ref fld_var) = self.aad_prefix {
5547      o_prot.write_field_begin(&TFieldIdentifier::new("aad_prefix", TType::String, 1))?;
5548      o_prot.write_bytes(fld_var)?;
5549      o_prot.write_field_end()?
5550    }
5551    if let Some(ref fld_var) = self.aad_file_unique {
5552      o_prot.write_field_begin(&TFieldIdentifier::new("aad_file_unique", TType::String, 2))?;
5553      o_prot.write_bytes(fld_var)?;
5554      o_prot.write_field_end()?
5555    }
5556    if let Some(fld_var) = self.supply_aad_prefix {
5557      o_prot.write_field_begin(&TFieldIdentifier::new("supply_aad_prefix", TType::Bool, 3))?;
5558      o_prot.write_bool(fld_var)?;
5559      o_prot.write_field_end()?
5560    }
5561    o_prot.write_field_stop()?;
5562    o_prot.write_struct_end()
5563  }
5564}
5565
5566//
5567// AesGcmCtrV1
5568//
5569
5570#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
5571pub struct AesGcmCtrV1 {
5572  /// AAD prefix *
5573  pub aad_prefix: Option<Vec<u8>>,
5574  /// Unique file identifier part of AAD suffix *
5575  pub aad_file_unique: Option<Vec<u8>>,
5576  /// In files encrypted with AAD prefix without storing it,
5577  /// readers must supply the prefix *
5578  pub supply_aad_prefix: Option<bool>,
5579}
5580
5581impl AesGcmCtrV1 {
5582  pub fn new<F1, F2, F3>(aad_prefix: F1, aad_file_unique: F2, supply_aad_prefix: F3) -> AesGcmCtrV1 where F1: Into<Option<Vec<u8>>>, F2: Into<Option<Vec<u8>>>, F3: Into<Option<bool>> {
5583    AesGcmCtrV1 {
5584      aad_prefix: aad_prefix.into(),
5585      aad_file_unique: aad_file_unique.into(),
5586      supply_aad_prefix: supply_aad_prefix.into(),
5587    }
5588  }
5589}
5590
5591impl crate::thrift::TSerializable for AesGcmCtrV1 {
5592  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<AesGcmCtrV1> {
5593    i_prot.read_struct_begin()?;
5594    let mut f_1: Option<Vec<u8>> = None;
5595    let mut f_2: Option<Vec<u8>> = None;
5596    let mut f_3: Option<bool> = None;
5597    loop {
5598      let field_ident = i_prot.read_field_begin()?;
5599      if field_ident.field_type == TType::Stop {
5600        break;
5601      }
5602      let field_id = field_id(&field_ident)?;
5603      match field_id {
5604        1 => {
5605          let val = i_prot.read_bytes()?;
5606          f_1 = Some(val);
5607        },
5608        2 => {
5609          let val = i_prot.read_bytes()?;
5610          f_2 = Some(val);
5611        },
5612        3 => {
5613          let val = i_prot.read_bool()?;
5614          f_3 = Some(val);
5615        },
5616        _ => {
5617          i_prot.skip(field_ident.field_type)?;
5618        },
5619      };
5620      i_prot.read_field_end()?;
5621    }
5622    i_prot.read_struct_end()?;
5623    let ret = AesGcmCtrV1 {
5624      aad_prefix: f_1,
5625      aad_file_unique: f_2,
5626      supply_aad_prefix: f_3,
5627    };
5628    Ok(ret)
5629  }
5630  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
5631    let struct_ident = TStructIdentifier::new("AesGcmCtrV1");
5632    o_prot.write_struct_begin(&struct_ident)?;
5633    if let Some(ref fld_var) = self.aad_prefix {
5634      o_prot.write_field_begin(&TFieldIdentifier::new("aad_prefix", TType::String, 1))?;
5635      o_prot.write_bytes(fld_var)?;
5636      o_prot.write_field_end()?
5637    }
5638    if let Some(ref fld_var) = self.aad_file_unique {
5639      o_prot.write_field_begin(&TFieldIdentifier::new("aad_file_unique", TType::String, 2))?;
5640      o_prot.write_bytes(fld_var)?;
5641      o_prot.write_field_end()?
5642    }
5643    if let Some(fld_var) = self.supply_aad_prefix {
5644      o_prot.write_field_begin(&TFieldIdentifier::new("supply_aad_prefix", TType::Bool, 3))?;
5645      o_prot.write_bool(fld_var)?;
5646      o_prot.write_field_end()?
5647    }
5648    o_prot.write_field_stop()?;
5649    o_prot.write_struct_end()
5650  }
5651}
5652
5653//
5654// EncryptionAlgorithm
5655//
5656
5657#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
5658pub enum EncryptionAlgorithm {
5659  AESGCMV1(AesGcmV1),
5660  AESGCMCTRV1(AesGcmCtrV1),
5661}
5662
5663impl crate::thrift::TSerializable for EncryptionAlgorithm {
5664  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<EncryptionAlgorithm> {
5665    let mut ret: Option<EncryptionAlgorithm> = None;
5666    let mut received_field_count = 0;
5667    i_prot.read_struct_begin()?;
5668    loop {
5669      let field_ident = i_prot.read_field_begin()?;
5670      if field_ident.field_type == TType::Stop {
5671        break;
5672      }
5673      let field_id = field_id(&field_ident)?;
5674      match field_id {
5675        1 => {
5676          let val = AesGcmV1::read_from_in_protocol(i_prot)?;
5677          if ret.is_none() {
5678            ret = Some(EncryptionAlgorithm::AESGCMV1(val));
5679          }
5680          received_field_count += 1;
5681        },
5682        2 => {
5683          let val = AesGcmCtrV1::read_from_in_protocol(i_prot)?;
5684          if ret.is_none() {
5685            ret = Some(EncryptionAlgorithm::AESGCMCTRV1(val));
5686          }
5687          received_field_count += 1;
5688        },
5689        _ => {
5690          i_prot.skip(field_ident.field_type)?;
5691          received_field_count += 1;
5692        },
5693      };
5694      i_prot.read_field_end()?;
5695    }
5696    i_prot.read_struct_end()?;
5697    if received_field_count == 0 {
5698      Err(
5699        thrift::Error::Protocol(
5700          ProtocolError::new(
5701            ProtocolErrorKind::InvalidData,
5702            "received empty union from remote EncryptionAlgorithm"
5703          )
5704        )
5705      )
5706    } else if received_field_count > 1 {
5707      Err(
5708        thrift::Error::Protocol(
5709          ProtocolError::new(
5710            ProtocolErrorKind::InvalidData,
5711            "received multiple fields for union from remote EncryptionAlgorithm"
5712          )
5713        )
5714      )
5715    } else {
5716      ret.ok_or_else(|| thrift::Error::Protocol(ProtocolError::new(ProtocolErrorKind::InvalidData, "return value should have been constructed")))
5717    }
5718  }
5719  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
5720    let struct_ident = TStructIdentifier::new("EncryptionAlgorithm");
5721    o_prot.write_struct_begin(&struct_ident)?;
5722    match *self {
5723      EncryptionAlgorithm::AESGCMV1(ref f) => {
5724        o_prot.write_field_begin(&TFieldIdentifier::new("AES_GCM_V1", TType::Struct, 1))?;
5725        f.write_to_out_protocol(o_prot)?;
5726        o_prot.write_field_end()?;
5727      },
5728      EncryptionAlgorithm::AESGCMCTRV1(ref f) => {
5729        o_prot.write_field_begin(&TFieldIdentifier::new("AES_GCM_CTR_V1", TType::Struct, 2))?;
5730        f.write_to_out_protocol(o_prot)?;
5731        o_prot.write_field_end()?;
5732      },
5733    }
5734    o_prot.write_field_stop()?;
5735    o_prot.write_struct_end()
5736  }
5737}
5738
5739//
5740// FileMetaData
5741//
5742
5743/// Description for file metadata
5744#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
5745pub struct FileMetaData {
5746  /// Version of this file *
5747  pub version: i32,
5748  /// Parquet schema for this file.  This schema contains metadata for all the columns.
5749  /// The schema is represented as a tree with a single root.  The nodes of the tree
5750  /// are flattened to a list by doing a depth-first traversal.
5751  /// The column metadata contains the path in the schema for that column which can be
5752  /// used to map columns to nodes in the schema.
5753  /// The first element is the root *
5754  pub schema: Vec<SchemaElement>,
5755  /// Number of rows in this file *
5756  pub num_rows: i64,
5757  /// Row groups in this file *
5758  pub row_groups: Vec<RowGroup>,
5759  /// Optional key/value metadata *
5760  pub key_value_metadata: Option<Vec<KeyValue>>,
5761  /// String for application that wrote this file.  This should be in the format
5762  /// `<Application>` version `<App Version>` (build `<App Build Hash>`).
5763  /// e.g. impala version 1.0 (build 6cf94d29b2b7115df4de2c06e2ab4326d721eb55)
5764  /// 
5765  pub created_by: Option<String>,
5766  /// Sort order used for the min_value and max_value fields in the Statistics
5767  /// objects and the min_values and max_values fields in the ColumnIndex
5768  /// objects of each column in this file. Sort orders are listed in the order
5769  /// matching the columns in the schema. The indexes are not necessary the same
5770  /// though, because only leaf nodes of the schema are represented in the list
5771  /// of sort orders.
5772  /// 
5773  /// Without column_orders, the meaning of the min_value and max_value fields
5774  /// in the Statistics object and the ColumnIndex object is undefined. To ensure
5775  /// well-defined behaviour, if these fields are written to a Parquet file,
5776  /// column_orders must be written as well.
5777  /// 
5778  /// The obsolete min and max fields in the Statistics object are always sorted
5779  /// by signed comparison regardless of column_orders.
5780  pub column_orders: Option<Vec<ColumnOrder>>,
5781  /// Encryption algorithm. This field is set only in encrypted files
5782  /// with plaintext footer. Files with encrypted footer store algorithm id
5783  /// in FileCryptoMetaData structure.
5784  pub encryption_algorithm: Option<EncryptionAlgorithm>,
5785  /// Retrieval metadata of key used for signing the footer.
5786  /// Used only in encrypted files with plaintext footer.
5787  pub footer_signing_key_metadata: Option<Vec<u8>>,
5788}
5789
5790impl FileMetaData {
5791  pub fn new<F5, F6, F7, F8, F9>(version: i32, schema: Vec<SchemaElement>, num_rows: i64, row_groups: Vec<RowGroup>, key_value_metadata: F5, created_by: F6, column_orders: F7, encryption_algorithm: F8, footer_signing_key_metadata: F9) -> FileMetaData where F5: Into<Option<Vec<KeyValue>>>, F6: Into<Option<String>>, F7: Into<Option<Vec<ColumnOrder>>>, F8: Into<Option<EncryptionAlgorithm>>, F9: Into<Option<Vec<u8>>> {
5792    FileMetaData {
5793      version,
5794      schema,
5795      num_rows,
5796      row_groups,
5797      key_value_metadata: key_value_metadata.into(),
5798      created_by: created_by.into(),
5799      column_orders: column_orders.into(),
5800      encryption_algorithm: encryption_algorithm.into(),
5801      footer_signing_key_metadata: footer_signing_key_metadata.into(),
5802    }
5803  }
5804}
5805
5806impl crate::thrift::TSerializable for FileMetaData {
5807  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<FileMetaData> {
5808    i_prot.read_struct_begin()?;
5809    let mut f_1: Option<i32> = None;
5810    let mut f_2: Option<Vec<SchemaElement>> = None;
5811    let mut f_3: Option<i64> = None;
5812    let mut f_4: Option<Vec<RowGroup>> = None;
5813    let mut f_5: Option<Vec<KeyValue>> = None;
5814    let mut f_6: Option<String> = None;
5815    let mut f_7: Option<Vec<ColumnOrder>> = None;
5816    let mut f_8: Option<EncryptionAlgorithm> = None;
5817    let mut f_9: Option<Vec<u8>> = None;
5818    loop {
5819      let field_ident = i_prot.read_field_begin()?;
5820      if field_ident.field_type == TType::Stop {
5821        break;
5822      }
5823      let field_id = field_id(&field_ident)?;
5824      match field_id {
5825        1 => {
5826          let val = i_prot.read_i32()?;
5827          f_1 = Some(val);
5828        },
5829        2 => {
5830          let list_ident = i_prot.read_list_begin()?;
5831          let mut val: Vec<SchemaElement> = Vec::with_capacity(list_ident.size as usize);
5832          for _ in 0..list_ident.size {
5833            let list_elem_18 = SchemaElement::read_from_in_protocol(i_prot)?;
5834            val.push(list_elem_18);
5835          }
5836          i_prot.read_list_end()?;
5837          f_2 = Some(val);
5838        },
5839        3 => {
5840          let val = i_prot.read_i64()?;
5841          f_3 = Some(val);
5842        },
5843        4 => {
5844          let list_ident = i_prot.read_list_begin()?;
5845          let mut val: Vec<RowGroup> = Vec::with_capacity(list_ident.size as usize);
5846          for _ in 0..list_ident.size {
5847            let list_elem_19 = RowGroup::read_from_in_protocol(i_prot)?;
5848            val.push(list_elem_19);
5849          }
5850          i_prot.read_list_end()?;
5851          f_4 = Some(val);
5852        },
5853        5 => {
5854          let list_ident = i_prot.read_list_begin()?;
5855          let mut val: Vec<KeyValue> = Vec::with_capacity(list_ident.size as usize);
5856          for _ in 0..list_ident.size {
5857            let list_elem_20 = KeyValue::read_from_in_protocol(i_prot)?;
5858            val.push(list_elem_20);
5859          }
5860          i_prot.read_list_end()?;
5861          f_5 = Some(val);
5862        },
5863        6 => {
5864          let val = i_prot.read_string()?;
5865          f_6 = Some(val);
5866        },
5867        7 => {
5868          let list_ident = i_prot.read_list_begin()?;
5869          let mut val: Vec<ColumnOrder> = Vec::with_capacity(list_ident.size as usize);
5870          for _ in 0..list_ident.size {
5871            let list_elem_21 = ColumnOrder::read_from_in_protocol(i_prot)?;
5872            val.push(list_elem_21);
5873          }
5874          i_prot.read_list_end()?;
5875          f_7 = Some(val);
5876        },
5877        8 => {
5878          let val = EncryptionAlgorithm::read_from_in_protocol(i_prot)?;
5879          f_8 = Some(val);
5880        },
5881        9 => {
5882          let val = i_prot.read_bytes()?;
5883          f_9 = Some(val);
5884        },
5885        _ => {
5886          i_prot.skip(field_ident.field_type)?;
5887        },
5888      };
5889      i_prot.read_field_end()?;
5890    }
5891    i_prot.read_struct_end()?;
5892    verify_required_field_exists("FileMetaData.version", &f_1)?;
5893    verify_required_field_exists("FileMetaData.schema", &f_2)?;
5894    verify_required_field_exists("FileMetaData.num_rows", &f_3)?;
5895    verify_required_field_exists("FileMetaData.row_groups", &f_4)?;
5896    let ret = FileMetaData {
5897      version: f_1.expect("auto-generated code should have checked for presence of required fields"),
5898      schema: f_2.expect("auto-generated code should have checked for presence of required fields"),
5899      num_rows: f_3.expect("auto-generated code should have checked for presence of required fields"),
5900      row_groups: f_4.expect("auto-generated code should have checked for presence of required fields"),
5901      key_value_metadata: f_5,
5902      created_by: f_6,
5903      column_orders: f_7,
5904      encryption_algorithm: f_8,
5905      footer_signing_key_metadata: f_9,
5906    };
5907    Ok(ret)
5908  }
5909  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
5910    let struct_ident = TStructIdentifier::new("FileMetaData");
5911    o_prot.write_struct_begin(&struct_ident)?;
5912    o_prot.write_field_begin(&TFieldIdentifier::new("version", TType::I32, 1))?;
5913    o_prot.write_i32(self.version)?;
5914    o_prot.write_field_end()?;
5915    o_prot.write_field_begin(&TFieldIdentifier::new("schema", TType::List, 2))?;
5916    o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, self.schema.len() as i32))?;
5917    for e in &self.schema {
5918      e.write_to_out_protocol(o_prot)?;
5919    }
5920    o_prot.write_list_end()?;
5921    o_prot.write_field_end()?;
5922    o_prot.write_field_begin(&TFieldIdentifier::new("num_rows", TType::I64, 3))?;
5923    o_prot.write_i64(self.num_rows)?;
5924    o_prot.write_field_end()?;
5925    o_prot.write_field_begin(&TFieldIdentifier::new("row_groups", TType::List, 4))?;
5926    o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, self.row_groups.len() as i32))?;
5927    for e in &self.row_groups {
5928      e.write_to_out_protocol(o_prot)?;
5929    }
5930    o_prot.write_list_end()?;
5931    o_prot.write_field_end()?;
5932    if let Some(ref fld_var) = self.key_value_metadata {
5933      o_prot.write_field_begin(&TFieldIdentifier::new("key_value_metadata", TType::List, 5))?;
5934      o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, fld_var.len() as i32))?;
5935      for e in fld_var {
5936        e.write_to_out_protocol(o_prot)?;
5937      }
5938      o_prot.write_list_end()?;
5939      o_prot.write_field_end()?
5940    }
5941    if let Some(ref fld_var) = self.created_by {
5942      o_prot.write_field_begin(&TFieldIdentifier::new("created_by", TType::String, 6))?;
5943      o_prot.write_string(fld_var)?;
5944      o_prot.write_field_end()?
5945    }
5946    if let Some(ref fld_var) = self.column_orders {
5947      o_prot.write_field_begin(&TFieldIdentifier::new("column_orders", TType::List, 7))?;
5948      o_prot.write_list_begin(&TListIdentifier::new(TType::Struct, fld_var.len() as i32))?;
5949      for e in fld_var {
5950        e.write_to_out_protocol(o_prot)?;
5951      }
5952      o_prot.write_list_end()?;
5953      o_prot.write_field_end()?
5954    }
5955    if let Some(ref fld_var) = self.encryption_algorithm {
5956      o_prot.write_field_begin(&TFieldIdentifier::new("encryption_algorithm", TType::Struct, 8))?;
5957      fld_var.write_to_out_protocol(o_prot)?;
5958      o_prot.write_field_end()?
5959    }
5960    if let Some(ref fld_var) = self.footer_signing_key_metadata {
5961      o_prot.write_field_begin(&TFieldIdentifier::new("footer_signing_key_metadata", TType::String, 9))?;
5962      o_prot.write_bytes(fld_var)?;
5963      o_prot.write_field_end()?
5964    }
5965    o_prot.write_field_stop()?;
5966    o_prot.write_struct_end()
5967  }
5968}
5969
5970//
5971// FileCryptoMetaData
5972//
5973
5974/// Crypto metadata for files with encrypted footer *
5975#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
5976pub struct FileCryptoMetaData {
5977  /// Encryption algorithm. This field is only used for files
5978  /// with encrypted footer. Files with plaintext footer store algorithm id
5979  /// inside footer (FileMetaData structure).
5980  pub encryption_algorithm: EncryptionAlgorithm,
5981  /// Retrieval metadata of key used for encryption of footer,
5982  /// and (possibly) columns *
5983  pub key_metadata: Option<Vec<u8>>,
5984}
5985
5986impl FileCryptoMetaData {
5987  pub fn new<F2>(encryption_algorithm: EncryptionAlgorithm, key_metadata: F2) -> FileCryptoMetaData where F2: Into<Option<Vec<u8>>> {
5988    FileCryptoMetaData {
5989      encryption_algorithm,
5990      key_metadata: key_metadata.into(),
5991    }
5992  }
5993}
5994
5995impl crate::thrift::TSerializable for FileCryptoMetaData {
5996  fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<FileCryptoMetaData> {
5997    i_prot.read_struct_begin()?;
5998    let mut f_1: Option<EncryptionAlgorithm> = None;
5999    let mut f_2: Option<Vec<u8>> = None;
6000    loop {
6001      let field_ident = i_prot.read_field_begin()?;
6002      if field_ident.field_type == TType::Stop {
6003        break;
6004      }
6005      let field_id = field_id(&field_ident)?;
6006      match field_id {
6007        1 => {
6008          let val = EncryptionAlgorithm::read_from_in_protocol(i_prot)?;
6009          f_1 = Some(val);
6010        },
6011        2 => {
6012          let val = i_prot.read_bytes()?;
6013          f_2 = Some(val);
6014        },
6015        _ => {
6016          i_prot.skip(field_ident.field_type)?;
6017        },
6018      };
6019      i_prot.read_field_end()?;
6020    }
6021    i_prot.read_struct_end()?;
6022    verify_required_field_exists("FileCryptoMetaData.encryption_algorithm", &f_1)?;
6023    let ret = FileCryptoMetaData {
6024      encryption_algorithm: f_1.expect("auto-generated code should have checked for presence of required fields"),
6025      key_metadata: f_2,
6026    };
6027    Ok(ret)
6028  }
6029  fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
6030    let struct_ident = TStructIdentifier::new("FileCryptoMetaData");
6031    o_prot.write_struct_begin(&struct_ident)?;
6032    o_prot.write_field_begin(&TFieldIdentifier::new("encryption_algorithm", TType::Struct, 1))?;
6033    self.encryption_algorithm.write_to_out_protocol(o_prot)?;
6034    o_prot.write_field_end()?;
6035    if let Some(ref fld_var) = self.key_metadata {
6036      o_prot.write_field_begin(&TFieldIdentifier::new("key_metadata", TType::String, 2))?;
6037      o_prot.write_bytes(fld_var)?;
6038      o_prot.write_field_end()?
6039    }
6040    o_prot.write_field_stop()?;
6041    o_prot.write_struct_end()
6042  }
6043}
6044