-
Notifications
You must be signed in to change notification settings - Fork 850
/
Copy pathformat.rs
5481 lines (5224 loc) · 186 KB
/
format.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//! See [`crate::file`] for easier to use APIs.
// Autogenerated by Thrift Compiler (0.20.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_extern_crates)]
#![allow(clippy::too_many_arguments, clippy::type_complexity, clippy::vec_box, clippy::wrong_self_convention)]
// Fix unexpected `cfg` condition name: `rustfmt` https://github.com/apache/arrow-rs/issues/5725
//#![cfg_attr(rustfmt, rustfmt_skip)]
use std::cell::RefCell;
use std::collections::{BTreeMap, BTreeSet};
use std::convert::{From, TryFrom};
use std::default::Default;
use std::error::Error;
use std::fmt;
use std::fmt::{Display, Formatter};
use std::rc::Rc;
use thrift::OrderedFloat;
use thrift::{ApplicationError, ApplicationErrorKind, ProtocolError, ProtocolErrorKind, TThriftClient};
use thrift::protocol::{TFieldIdentifier, TListIdentifier, TMapIdentifier, TMessageIdentifier, TMessageType, TInputProtocol, TOutputProtocol, TSerializable, TSetIdentifier, TStructIdentifier, TType};
use thrift::protocol::field_id;
use thrift::protocol::verify_expected_message_type;
use thrift::protocol::verify_expected_sequence_number;
use thrift::protocol::verify_expected_service_call;
use thrift::protocol::verify_required_field_exists;
/// Types supported by Parquet. These types are intended to be used in combination
/// with the encodings to control the on disk storage format.
/// For example INT16 is not included as a type since a good encoding of INT32
/// would handle this.
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Type(pub i32);
impl Type {
pub const BOOLEAN: Type = Type(0);
pub const INT32: Type = Type(1);
pub const INT64: Type = Type(2);
pub const INT96: Type = Type(3);
pub const FLOAT: Type = Type(4);
pub const DOUBLE: Type = Type(5);
pub const BYTE_ARRAY: Type = Type(6);
pub const FIXED_LEN_BYTE_ARRAY: Type = Type(7);
pub const ENUM_VALUES: &'static [Self] = &[
Self::BOOLEAN,
Self::INT32,
Self::INT64,
Self::INT96,
Self::FLOAT,
Self::DOUBLE,
Self::BYTE_ARRAY,
Self::FIXED_LEN_BYTE_ARRAY,
];
}
impl crate::thrift::TSerializable for Type {
#[allow(clippy::trivially_copy_pass_by_ref)]
fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
o_prot.write_i32(self.0)
}
fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<Type> {
let enum_value = i_prot.read_i32()?;
Ok(Type::from(enum_value))
}
}
impl From<i32> for Type {
fn from(i: i32) -> Self {
match i {
0 => Type::BOOLEAN,
1 => Type::INT32,
2 => Type::INT64,
3 => Type::INT96,
4 => Type::FLOAT,
5 => Type::DOUBLE,
6 => Type::BYTE_ARRAY,
7 => Type::FIXED_LEN_BYTE_ARRAY,
_ => Type(i)
}
}
}
impl From<&i32> for Type {
fn from(i: &i32) -> Self {
Type::from(*i)
}
}
impl From<Type> for i32 {
fn from(e: Type) -> i32 {
e.0
}
}
impl From<&Type> for i32 {
fn from(e: &Type) -> i32 {
e.0
}
}
/// DEPRECATED: Common types used by frameworks(e.g. hive, pig) using parquet.
/// ConvertedType is superseded by LogicalType. This enum should not be extended.
///
/// See LogicalTypes.md for conversion between ConvertedType and LogicalType.
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct ConvertedType(pub i32);
impl ConvertedType {
/// a BYTE_ARRAY actually contains UTF8 encoded chars
pub const UTF8: ConvertedType = ConvertedType(0);
/// a map is converted as an optional field containing a repeated key/value pair
pub const MAP: ConvertedType = ConvertedType(1);
/// a key/value pair is converted into a group of two fields
pub const MAP_KEY_VALUE: ConvertedType = ConvertedType(2);
/// a list is converted into an optional field containing a repeated field for its
/// values
pub const LIST: ConvertedType = ConvertedType(3);
/// an enum is converted into a BYTE_ARRAY field
pub const ENUM: ConvertedType = ConvertedType(4);
/// A decimal value.
///
/// This may be used to annotate BYTE_ARRAY or FIXED_LEN_BYTE_ARRAY primitive
/// types. The underlying byte array stores the unscaled value encoded as two's
/// complement using big-endian byte order (the most significant byte is the
/// zeroth element). The value of the decimal is the value * 10^{-scale}.
///
/// This must be accompanied by a (maximum) precision and a scale in the
/// SchemaElement. The precision specifies the number of digits in the decimal
/// and the scale stores the location of the decimal point. For example 1.23
/// would have precision 3 (3 total digits) and scale 2 (the decimal point is
/// 2 digits over).
pub const DECIMAL: ConvertedType = ConvertedType(5);
/// A Date
///
/// Stored as days since Unix epoch, encoded as the INT32 physical type.
///
pub const DATE: ConvertedType = ConvertedType(6);
/// A time
///
/// The total number of milliseconds since midnight. The value is stored
/// as an INT32 physical type.
pub const TIME_MILLIS: ConvertedType = ConvertedType(7);
/// A time.
///
/// The total number of microseconds since midnight. The value is stored as
/// an INT64 physical type.
pub const TIME_MICROS: ConvertedType = ConvertedType(8);
/// A date/time combination
///
/// Date and time recorded as milliseconds since the Unix epoch. Recorded as
/// a physical type of INT64.
pub const TIMESTAMP_MILLIS: ConvertedType = ConvertedType(9);
/// A date/time combination
///
/// Date and time recorded as microseconds since the Unix epoch. The value is
/// stored as an INT64 physical type.
pub const TIMESTAMP_MICROS: ConvertedType = ConvertedType(10);
/// An unsigned integer value.
///
/// The number describes the maximum number of meaningful data bits in
/// the stored value. 8, 16 and 32 bit values are stored using the
/// INT32 physical type. 64 bit values are stored using the INT64
/// physical type.
///
pub const UINT_8: ConvertedType = ConvertedType(11);
pub const UINT_16: ConvertedType = ConvertedType(12);
pub const UINT_32: ConvertedType = ConvertedType(13);
pub const UINT_64: ConvertedType = ConvertedType(14);
/// A signed integer value.
///
/// The number describes the maximum number of meaningful data bits in
/// the stored value. 8, 16 and 32 bit values are stored using the
/// INT32 physical type. 64 bit values are stored using the INT64
/// physical type.
///
pub const INT_8: ConvertedType = ConvertedType(15);
pub const INT_16: ConvertedType = ConvertedType(16);
pub const INT_32: ConvertedType = ConvertedType(17);
pub const INT_64: ConvertedType = ConvertedType(18);
/// An embedded JSON document
///
/// A JSON document embedded within a single UTF8 column.
pub const JSON: ConvertedType = ConvertedType(19);
/// An embedded BSON document
///
/// A BSON document embedded within a single BYTE_ARRAY column.
pub const BSON: ConvertedType = ConvertedType(20);
/// An interval of time
///
/// This type annotates data stored as a FIXED_LEN_BYTE_ARRAY of length 12
/// This data is composed of three separate little endian unsigned
/// integers. Each stores a component of a duration of time. The first
/// integer identifies the number of months associated with the duration,
/// the second identifies the number of days associated with the duration
/// and the third identifies the number of milliseconds associated with
/// the provided duration. This duration of time is independent of any
/// particular timezone or date.
pub const INTERVAL: ConvertedType = ConvertedType(21);
pub const ENUM_VALUES: &'static [Self] = &[
Self::UTF8,
Self::MAP,
Self::MAP_KEY_VALUE,
Self::LIST,
Self::ENUM,
Self::DECIMAL,
Self::DATE,
Self::TIME_MILLIS,
Self::TIME_MICROS,
Self::TIMESTAMP_MILLIS,
Self::TIMESTAMP_MICROS,
Self::UINT_8,
Self::UINT_16,
Self::UINT_32,
Self::UINT_64,
Self::INT_8,
Self::INT_16,
Self::INT_32,
Self::INT_64,
Self::JSON,
Self::BSON,
Self::INTERVAL,
];
}
impl crate::thrift::TSerializable for ConvertedType {
#[allow(clippy::trivially_copy_pass_by_ref)]
fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
o_prot.write_i32(self.0)
}
fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<ConvertedType> {
let enum_value = i_prot.read_i32()?;
Ok(ConvertedType::from(enum_value))
}
}
impl From<i32> for ConvertedType {
fn from(i: i32) -> Self {
match i {
0 => ConvertedType::UTF8,
1 => ConvertedType::MAP,
2 => ConvertedType::MAP_KEY_VALUE,
3 => ConvertedType::LIST,
4 => ConvertedType::ENUM,
5 => ConvertedType::DECIMAL,
6 => ConvertedType::DATE,
7 => ConvertedType::TIME_MILLIS,
8 => ConvertedType::TIME_MICROS,
9 => ConvertedType::TIMESTAMP_MILLIS,
10 => ConvertedType::TIMESTAMP_MICROS,
11 => ConvertedType::UINT_8,
12 => ConvertedType::UINT_16,
13 => ConvertedType::UINT_32,
14 => ConvertedType::UINT_64,
15 => ConvertedType::INT_8,
16 => ConvertedType::INT_16,
17 => ConvertedType::INT_32,
18 => ConvertedType::INT_64,
19 => ConvertedType::JSON,
20 => ConvertedType::BSON,
21 => ConvertedType::INTERVAL,
_ => ConvertedType(i)
}
}
}
impl From<&i32> for ConvertedType {
fn from(i: &i32) -> Self {
ConvertedType::from(*i)
}
}
impl From<ConvertedType> for i32 {
fn from(e: ConvertedType) -> i32 {
e.0
}
}
impl From<&ConvertedType> for i32 {
fn from(e: &ConvertedType) -> i32 {
e.0
}
}
/// Representation of Schemas
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct FieldRepetitionType(pub i32);
impl FieldRepetitionType {
/// This field is required (can not be null) and each row has exactly 1 value.
pub const REQUIRED: FieldRepetitionType = FieldRepetitionType(0);
/// The field is optional (can be null) and each row has 0 or 1 values.
pub const OPTIONAL: FieldRepetitionType = FieldRepetitionType(1);
/// The field is repeated and can contain 0 or more values
pub const REPEATED: FieldRepetitionType = FieldRepetitionType(2);
pub const ENUM_VALUES: &'static [Self] = &[
Self::REQUIRED,
Self::OPTIONAL,
Self::REPEATED,
];
}
impl crate::thrift::TSerializable for FieldRepetitionType {
#[allow(clippy::trivially_copy_pass_by_ref)]
fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
o_prot.write_i32(self.0)
}
fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<FieldRepetitionType> {
let enum_value = i_prot.read_i32()?;
Ok(FieldRepetitionType::from(enum_value))
}
}
impl From<i32> for FieldRepetitionType {
fn from(i: i32) -> Self {
match i {
0 => FieldRepetitionType::REQUIRED,
1 => FieldRepetitionType::OPTIONAL,
2 => FieldRepetitionType::REPEATED,
_ => FieldRepetitionType(i)
}
}
}
impl From<&i32> for FieldRepetitionType {
fn from(i: &i32) -> Self {
FieldRepetitionType::from(*i)
}
}
impl From<FieldRepetitionType> for i32 {
fn from(e: FieldRepetitionType) -> i32 {
e.0
}
}
impl From<&FieldRepetitionType> for i32 {
fn from(e: &FieldRepetitionType) -> i32 {
e.0
}
}
/// Encodings supported by Parquet. Not all encodings are valid for all types. These
/// enums are also used to specify the encoding of definition and repetition levels.
/// See the accompanying doc for the details of the more complicated encodings.
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Encoding(pub i32);
impl Encoding {
/// Default encoding.
/// BOOLEAN - 1 bit per value. 0 is false; 1 is true.
/// INT32 - 4 bytes per value. Stored as little-endian.
/// INT64 - 8 bytes per value. Stored as little-endian.
/// FLOAT - 4 bytes per value. IEEE. Stored as little-endian.
/// DOUBLE - 8 bytes per value. IEEE. Stored as little-endian.
/// BYTE_ARRAY - 4 byte length stored as little endian, followed by bytes.
/// FIXED_LEN_BYTE_ARRAY - Just the bytes.
pub const PLAIN: Encoding = Encoding(0);
/// Deprecated: Dictionary encoding. The values in the dictionary are encoded in the
/// plain type.
/// in a data page use RLE_DICTIONARY instead.
/// in a Dictionary page use PLAIN instead
pub const PLAIN_DICTIONARY: Encoding = Encoding(2);
/// Group packed run length encoding. Usable for definition/repetition levels
/// encoding and Booleans (on one bit: 0 is false; 1 is true.)
pub const RLE: Encoding = Encoding(3);
/// Bit packed encoding. This can only be used if the data has a known max
/// width. Usable for definition/repetition levels encoding.
pub const BIT_PACKED: Encoding = Encoding(4);
/// Delta encoding for integers. This can be used for int columns and works best
/// on sorted data
pub const DELTA_BINARY_PACKED: Encoding = Encoding(5);
/// Encoding for byte arrays to separate the length values and the data. The lengths
/// are encoded using DELTA_BINARY_PACKED
pub const DELTA_LENGTH_BYTE_ARRAY: Encoding = Encoding(6);
/// Incremental-encoded byte array. Prefix lengths are encoded using DELTA_BINARY_PACKED.
/// Suffixes are stored as delta length byte arrays.
pub const DELTA_BYTE_ARRAY: Encoding = Encoding(7);
/// Dictionary encoding: the ids are encoded using the RLE encoding
pub const RLE_DICTIONARY: Encoding = Encoding(8);
/// Encoding for fixed-width data (FLOAT, DOUBLE, INT32, INT64, FIXED_LEN_BYTE_ARRAY).
/// K byte-streams are created where K is the size in bytes of the data type.
/// The individual bytes of a value are scattered to the corresponding stream and
/// the streams are concatenated.
/// This itself does not reduce the size of the data but can lead to better compression
/// afterwards.
///
/// Added in 2.8 for FLOAT and DOUBLE.
/// Support for INT32, INT64 and FIXED_LEN_BYTE_ARRAY added in 2.11.
pub const BYTE_STREAM_SPLIT: Encoding = Encoding(9);
pub const ENUM_VALUES: &'static [Self] = &[
Self::PLAIN,
Self::PLAIN_DICTIONARY,
Self::RLE,
Self::BIT_PACKED,
Self::DELTA_BINARY_PACKED,
Self::DELTA_LENGTH_BYTE_ARRAY,
Self::DELTA_BYTE_ARRAY,
Self::RLE_DICTIONARY,
Self::BYTE_STREAM_SPLIT,
];
}
impl crate::thrift::TSerializable for Encoding {
#[allow(clippy::trivially_copy_pass_by_ref)]
fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
o_prot.write_i32(self.0)
}
fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<Encoding> {
let enum_value = i_prot.read_i32()?;
Ok(Encoding::from(enum_value))
}
}
impl From<i32> for Encoding {
fn from(i: i32) -> Self {
match i {
0 => Encoding::PLAIN,
2 => Encoding::PLAIN_DICTIONARY,
3 => Encoding::RLE,
4 => Encoding::BIT_PACKED,
5 => Encoding::DELTA_BINARY_PACKED,
6 => Encoding::DELTA_LENGTH_BYTE_ARRAY,
7 => Encoding::DELTA_BYTE_ARRAY,
8 => Encoding::RLE_DICTIONARY,
9 => Encoding::BYTE_STREAM_SPLIT,
_ => Encoding(i)
}
}
}
impl From<&i32> for Encoding {
fn from(i: &i32) -> Self {
Encoding::from(*i)
}
}
impl From<Encoding> for i32 {
fn from(e: Encoding) -> i32 {
e.0
}
}
impl From<&Encoding> for i32 {
fn from(e: &Encoding) -> i32 {
e.0
}
}
/// Supported compression algorithms.
///
/// Codecs added in format version X.Y can be read by readers based on X.Y and later.
/// Codec support may vary between readers based on the format version and
/// libraries available at runtime.
///
/// See Compression.md for a detailed specification of these algorithms.
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct CompressionCodec(pub i32);
impl CompressionCodec {
pub const UNCOMPRESSED: CompressionCodec = CompressionCodec(0);
pub const SNAPPY: CompressionCodec = CompressionCodec(1);
pub const GZIP: CompressionCodec = CompressionCodec(2);
pub const LZO: CompressionCodec = CompressionCodec(3);
pub const BROTLI: CompressionCodec = CompressionCodec(4);
pub const LZ4: CompressionCodec = CompressionCodec(5);
pub const ZSTD: CompressionCodec = CompressionCodec(6);
pub const LZ4_RAW: CompressionCodec = CompressionCodec(7);
pub const ENUM_VALUES: &'static [Self] = &[
Self::UNCOMPRESSED,
Self::SNAPPY,
Self::GZIP,
Self::LZO,
Self::BROTLI,
Self::LZ4,
Self::ZSTD,
Self::LZ4_RAW,
];
}
impl crate::thrift::TSerializable for CompressionCodec {
#[allow(clippy::trivially_copy_pass_by_ref)]
fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
o_prot.write_i32(self.0)
}
fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<CompressionCodec> {
let enum_value = i_prot.read_i32()?;
Ok(CompressionCodec::from(enum_value))
}
}
impl From<i32> for CompressionCodec {
fn from(i: i32) -> Self {
match i {
0 => CompressionCodec::UNCOMPRESSED,
1 => CompressionCodec::SNAPPY,
2 => CompressionCodec::GZIP,
3 => CompressionCodec::LZO,
4 => CompressionCodec::BROTLI,
5 => CompressionCodec::LZ4,
6 => CompressionCodec::ZSTD,
7 => CompressionCodec::LZ4_RAW,
_ => CompressionCodec(i)
}
}
}
impl From<&i32> for CompressionCodec {
fn from(i: &i32) -> Self {
CompressionCodec::from(*i)
}
}
impl From<CompressionCodec> for i32 {
fn from(e: CompressionCodec) -> i32 {
e.0
}
}
impl From<&CompressionCodec> for i32 {
fn from(e: &CompressionCodec) -> i32 {
e.0
}
}
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct PageType(pub i32);
impl PageType {
pub const DATA_PAGE: PageType = PageType(0);
pub const INDEX_PAGE: PageType = PageType(1);
pub const DICTIONARY_PAGE: PageType = PageType(2);
pub const DATA_PAGE_V2: PageType = PageType(3);
pub const ENUM_VALUES: &'static [Self] = &[
Self::DATA_PAGE,
Self::INDEX_PAGE,
Self::DICTIONARY_PAGE,
Self::DATA_PAGE_V2,
];
}
impl crate::thrift::TSerializable for PageType {
#[allow(clippy::trivially_copy_pass_by_ref)]
fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
o_prot.write_i32(self.0)
}
fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<PageType> {
let enum_value = i_prot.read_i32()?;
Ok(PageType::from(enum_value))
}
}
impl From<i32> for PageType {
fn from(i: i32) -> Self {
match i {
0 => PageType::DATA_PAGE,
1 => PageType::INDEX_PAGE,
2 => PageType::DICTIONARY_PAGE,
3 => PageType::DATA_PAGE_V2,
_ => PageType(i)
}
}
}
impl From<&i32> for PageType {
fn from(i: &i32) -> Self {
PageType::from(*i)
}
}
impl From<PageType> for i32 {
fn from(e: PageType) -> i32 {
e.0
}
}
impl From<&PageType> for i32 {
fn from(e: &PageType) -> i32 {
e.0
}
}
/// Enum to annotate whether lists of min/max elements inside ColumnIndex
/// are ordered and if so, in which direction.
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct BoundaryOrder(pub i32);
impl BoundaryOrder {
pub const UNORDERED: BoundaryOrder = BoundaryOrder(0);
pub const ASCENDING: BoundaryOrder = BoundaryOrder(1);
pub const DESCENDING: BoundaryOrder = BoundaryOrder(2);
pub const ENUM_VALUES: &'static [Self] = &[
Self::UNORDERED,
Self::ASCENDING,
Self::DESCENDING,
];
}
impl crate::thrift::TSerializable for BoundaryOrder {
#[allow(clippy::trivially_copy_pass_by_ref)]
fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
o_prot.write_i32(self.0)
}
fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<BoundaryOrder> {
let enum_value = i_prot.read_i32()?;
Ok(BoundaryOrder::from(enum_value))
}
}
impl From<i32> for BoundaryOrder {
fn from(i: i32) -> Self {
match i {
0 => BoundaryOrder::UNORDERED,
1 => BoundaryOrder::ASCENDING,
2 => BoundaryOrder::DESCENDING,
_ => BoundaryOrder(i)
}
}
}
impl From<&i32> for BoundaryOrder {
fn from(i: &i32) -> Self {
BoundaryOrder::from(*i)
}
}
impl From<BoundaryOrder> for i32 {
fn from(e: BoundaryOrder) -> i32 {
e.0
}
}
impl From<&BoundaryOrder> for i32 {
fn from(e: &BoundaryOrder) -> i32 {
e.0
}
}
//
// SizeStatistics
//
/// A structure for capturing metadata for estimating the unencoded,
/// uncompressed size of data written. This is useful for readers to estimate
/// how much memory is needed to reconstruct data in their memory model and for
/// fine grained filter pushdown on nested structures (the histograms contained
/// in this structure can help determine the number of nulls at a particular
/// nesting level and maximum length of lists).
#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct SizeStatistics {
/// The number of physical bytes stored for BYTE_ARRAY data values assuming
/// no encoding. This is exclusive of the bytes needed to store the length of
/// each byte array. In other words, this field is equivalent to the `(size
/// of PLAIN-ENCODING the byte array values) - (4 bytes * number of values
/// written)`. To determine unencoded sizes of other types readers can use
/// schema information multiplied by the number of non-null and null values.
/// The number of null/non-null values can be inferred from the histograms
/// below.
///
/// For example, if a column chunk is dictionary-encoded with dictionary
/// ["a", "bc", "cde"], and a data page contains the indices [0, 0, 1, 2],
/// then this value for that data page should be 7 (1 + 1 + 2 + 3).
///
/// This field should only be set for types that use BYTE_ARRAY as their
/// physical type.
pub unencoded_byte_array_data_bytes: Option<i64>,
/// When present, there is expected to be one element corresponding to each
/// repetition (i.e. size=max repetition_level+1) where each element
/// represents the number of times the repetition level was observed in the
/// data.
///
/// This field may be omitted if max_repetition_level is 0 without loss
/// of information.
///
pub repetition_level_histogram: Option<Vec<i64>>,
/// Same as repetition_level_histogram except for definition levels.
///
/// This field may be omitted if max_definition_level is 0 or 1 without
/// loss of information.
///
pub definition_level_histogram: Option<Vec<i64>>,
}
impl SizeStatistics {
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>>> {
SizeStatistics {
unencoded_byte_array_data_bytes: unencoded_byte_array_data_bytes.into(),
repetition_level_histogram: repetition_level_histogram.into(),
definition_level_histogram: definition_level_histogram.into(),
}
}
}
impl crate::thrift::TSerializable for SizeStatistics {
fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<SizeStatistics> {
i_prot.read_struct_begin()?;
let mut f_1: Option<i64> = None;
let mut f_2: Option<Vec<i64>> = None;
let mut f_3: Option<Vec<i64>> = None;
loop {
let field_ident = i_prot.read_field_begin()?;
if field_ident.field_type == TType::Stop {
break;
}
let field_id = field_id(&field_ident)?;
match field_id {
1 => {
let val = i_prot.read_i64()?;
f_1 = Some(val);
},
2 => {
let list_ident = i_prot.read_list_begin()?;
let mut val: Vec<i64> = Vec::with_capacity(list_ident.size as usize);
for _ in 0..list_ident.size {
let list_elem_0 = i_prot.read_i64()?;
val.push(list_elem_0);
}
i_prot.read_list_end()?;
f_2 = Some(val);
},
3 => {
let list_ident = i_prot.read_list_begin()?;
let mut val: Vec<i64> = Vec::with_capacity(list_ident.size as usize);
for _ in 0..list_ident.size {
let list_elem_1 = i_prot.read_i64()?;
val.push(list_elem_1);
}
i_prot.read_list_end()?;
f_3 = Some(val);
},
_ => {
i_prot.skip(field_ident.field_type)?;
},
};
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
let ret = SizeStatistics {
unencoded_byte_array_data_bytes: f_1,
repetition_level_histogram: f_2,
definition_level_histogram: f_3,
};
Ok(ret)
}
fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("SizeStatistics");
o_prot.write_struct_begin(&struct_ident)?;
if let Some(fld_var) = self.unencoded_byte_array_data_bytes {
o_prot.write_field_begin(&TFieldIdentifier::new("unencoded_byte_array_data_bytes", TType::I64, 1))?;
o_prot.write_i64(fld_var)?;
o_prot.write_field_end()?
}
if let Some(ref fld_var) = self.repetition_level_histogram {
o_prot.write_field_begin(&TFieldIdentifier::new("repetition_level_histogram", TType::List, 2))?;
o_prot.write_list_begin(&TListIdentifier::new(TType::I64, fld_var.len() as i32))?;
for e in fld_var {
o_prot.write_i64(*e)?;
}
o_prot.write_list_end()?;
o_prot.write_field_end()?
}
if let Some(ref fld_var) = self.definition_level_histogram {
o_prot.write_field_begin(&TFieldIdentifier::new("definition_level_histogram", TType::List, 3))?;
o_prot.write_list_begin(&TListIdentifier::new(TType::I64, fld_var.len() as i32))?;
for e in fld_var {
o_prot.write_i64(*e)?;
}
o_prot.write_list_end()?;
o_prot.write_field_end()?
}
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
}
//
// Statistics
//
/// Statistics per row group and per page
/// All fields are optional.
#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Statistics {
/// DEPRECATED: min and max value of the column. Use min_value and max_value.
///
/// Values are encoded using PLAIN encoding, except that variable-length byte
/// arrays do not include a length prefix.
///
/// These fields encode min and max values determined by signed comparison
/// only. New files should use the correct order for a column's logical type
/// and store the values in the min_value and max_value fields.
///
/// To support older readers, these may be set when the column order is
/// signed.
pub max: Option<Vec<u8>>,
pub min: Option<Vec<u8>>,
/// count of null value in the column
pub null_count: Option<i64>,
/// count of distinct values occurring
pub distinct_count: Option<i64>,
/// Lower and upper bound values for the column, determined by its ColumnOrder.
///
/// These may be the actual minimum and maximum values found on a page or column
/// chunk, but can also be (more compact) values that do not exist on a page or
/// column chunk. For example, instead of storing "Blart Versenwald III", a writer
/// may set min_value="B", max_value="C". Such more compact values must still be
/// valid values within the column's logical type.
///
/// Values are encoded using PLAIN encoding, except that variable-length byte
/// arrays do not include a length prefix.
pub max_value: Option<Vec<u8>>,
pub min_value: Option<Vec<u8>>,
/// If true, max_value is the actual maximum value for a column
pub is_max_value_exact: Option<bool>,
/// If true, min_value is the actual minimum value for a column
pub is_min_value_exact: Option<bool>,
}
impl Statistics {
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>> {
Statistics {
max: max.into(),
min: min.into(),
null_count: null_count.into(),
distinct_count: distinct_count.into(),
max_value: max_value.into(),
min_value: min_value.into(),
is_max_value_exact: is_max_value_exact.into(),
is_min_value_exact: is_min_value_exact.into(),
}
}
}
impl crate::thrift::TSerializable for Statistics {
fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<Statistics> {
i_prot.read_struct_begin()?;
let mut f_1: Option<Vec<u8>> = None;
let mut f_2: Option<Vec<u8>> = None;
let mut f_3: Option<i64> = None;
let mut f_4: Option<i64> = None;
let mut f_5: Option<Vec<u8>> = None;
let mut f_6: Option<Vec<u8>> = None;
let mut f_7: Option<bool> = None;
let mut f_8: Option<bool> = None;
loop {
let field_ident = i_prot.read_field_begin()?;
if field_ident.field_type == TType::Stop {
break;
}
let field_id = field_id(&field_ident)?;
match field_id {
1 => {
let val = i_prot.read_bytes()?;
f_1 = Some(val);
},
2 => {
let val = i_prot.read_bytes()?;
f_2 = Some(val);
},
3 => {
let val = i_prot.read_i64()?;
f_3 = Some(val);
},
4 => {
let val = i_prot.read_i64()?;
f_4 = Some(val);
},
5 => {
let val = i_prot.read_bytes()?;
f_5 = Some(val);
},
6 => {
let val = i_prot.read_bytes()?;
f_6 = Some(val);
},
7 => {
let val = i_prot.read_bool()?;
f_7 = Some(val);
},
8 => {
let val = i_prot.read_bool()?;
f_8 = Some(val);
},
_ => {
i_prot.skip(field_ident.field_type)?;
},
};
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
let ret = Statistics {
max: f_1,
min: f_2,
null_count: f_3,
distinct_count: f_4,
max_value: f_5,
min_value: f_6,
is_max_value_exact: f_7,
is_min_value_exact: f_8,
};
Ok(ret)
}
fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("Statistics");
o_prot.write_struct_begin(&struct_ident)?;
if let Some(ref fld_var) = self.max {
o_prot.write_field_begin(&TFieldIdentifier::new("max", TType::String, 1))?;
o_prot.write_bytes(fld_var)?;
o_prot.write_field_end()?
}
if let Some(ref fld_var) = self.min {
o_prot.write_field_begin(&TFieldIdentifier::new("min", TType::String, 2))?;
o_prot.write_bytes(fld_var)?;
o_prot.write_field_end()?
}
if let Some(fld_var) = self.null_count {
o_prot.write_field_begin(&TFieldIdentifier::new("null_count", TType::I64, 3))?;
o_prot.write_i64(fld_var)?;
o_prot.write_field_end()?
}
if let Some(fld_var) = self.distinct_count {
o_prot.write_field_begin(&TFieldIdentifier::new("distinct_count", TType::I64, 4))?;
o_prot.write_i64(fld_var)?;
o_prot.write_field_end()?
}
if let Some(ref fld_var) = self.max_value {
o_prot.write_field_begin(&TFieldIdentifier::new("max_value", TType::String, 5))?;
o_prot.write_bytes(fld_var)?;
o_prot.write_field_end()?
}
if let Some(ref fld_var) = self.min_value {
o_prot.write_field_begin(&TFieldIdentifier::new("min_value", TType::String, 6))?;
o_prot.write_bytes(fld_var)?;
o_prot.write_field_end()?
}
if let Some(fld_var) = self.is_max_value_exact {
o_prot.write_field_begin(&TFieldIdentifier::new("is_max_value_exact", TType::Bool, 7))?;
o_prot.write_bool(fld_var)?;
o_prot.write_field_end()?
}
if let Some(fld_var) = self.is_min_value_exact {
o_prot.write_field_begin(&TFieldIdentifier::new("is_min_value_exact", TType::Bool, 8))?;
o_prot.write_bool(fld_var)?;
o_prot.write_field_end()?
}
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
}
//
// StringType
//
/// Empty structs to use as logical type annotations
#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct StringType {
}
impl StringType {
pub fn new() -> StringType {
StringType {}
}
}
impl crate::thrift::TSerializable for StringType {
fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<StringType> {
i_prot.read_struct_begin()?;
loop {
let field_ident = i_prot.read_field_begin()?;
if field_ident.field_type == TType::Stop {
break;
}
i_prot.skip(field_ident.field_type)?;
i_prot.read_field_end()?;
}
i_prot.read_struct_end()?;
let ret = StringType {};
Ok(ret)
}
fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()> {
let struct_ident = TStructIdentifier::new("StringType");
o_prot.write_struct_begin(&struct_ident)?;
o_prot.write_field_stop()?;
o_prot.write_struct_end()
}
}
//
// UUIDType
//
#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct UUIDType {
}
impl UUIDType {
pub fn new() -> UUIDType {
UUIDType {}