be/src/format/parquet/decoder.cpp
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #include "format/parquet/decoder.h" |
19 | | |
20 | | #include <cctz/time_zone.h> |
21 | | #include <gen_cpp/parquet_types.h> |
22 | | |
23 | | #include "format/parquet/bool_plain_decoder.h" |
24 | | #include "format/parquet/bool_rle_decoder.h" |
25 | | #include "format/parquet/byte_array_dict_decoder.h" |
26 | | #include "format/parquet/byte_array_plain_decoder.h" |
27 | | #include "format/parquet/byte_stream_split_decoder.h" |
28 | | #include "format/parquet/delta_bit_pack_decoder.h" |
29 | | #include "format/parquet/fix_length_dict_decoder.hpp" |
30 | | #include "format/parquet/fix_length_plain_decoder.h" |
31 | | |
32 | | namespace doris { |
33 | | #include "common/compile_check_begin.h" |
34 | | Status Decoder::get_decoder(tparquet::Type::type type, tparquet::Encoding::type encoding, |
35 | 1.17k | std::unique_ptr<Decoder>& decoder) { |
36 | 1.17k | switch (encoding) { |
37 | 279 | case tparquet::Encoding::PLAIN: |
38 | 279 | switch (type) { |
39 | 68 | case tparquet::Type::BOOLEAN: |
40 | 68 | decoder.reset(new BoolPlainDecoder()); |
41 | 68 | break; |
42 | 38 | case tparquet::Type::BYTE_ARRAY: |
43 | 38 | decoder.reset(new ByteArrayPlainDecoder()); |
44 | 38 | break; |
45 | 66 | case tparquet::Type::INT32: |
46 | 85 | case tparquet::Type::INT64: |
47 | 87 | case tparquet::Type::INT96: |
48 | 112 | case tparquet::Type::FLOAT: |
49 | 140 | case tparquet::Type::DOUBLE: |
50 | 173 | case tparquet::Type::FIXED_LEN_BYTE_ARRAY: |
51 | 173 | decoder.reset(new FixLengthPlainDecoder()); |
52 | 173 | break; |
53 | 0 | default: |
54 | 0 | return Status::InternalError("Unsupported type {}(encoding={}) in parquet decoder", |
55 | 0 | tparquet::to_string(type), tparquet::to_string(encoding)); |
56 | 279 | } |
57 | 279 | break; |
58 | 892 | case tparquet::Encoding::RLE_DICTIONARY: |
59 | 892 | switch (type) { |
60 | 0 | case tparquet::Type::BOOLEAN: |
61 | 0 | return Status::InternalError("Bool type can't has dictionary page"); |
62 | 382 | case tparquet::Type::BYTE_ARRAY: |
63 | 382 | decoder.reset(new ByteArrayDictDecoder()); |
64 | 382 | break; |
65 | 321 | case tparquet::Type::INT32: |
66 | 321 | decoder.reset(new FixLengthDictDecoder<tparquet::Type::INT32>()); |
67 | 321 | break; |
68 | 90 | case tparquet::Type::INT64: |
69 | 90 | decoder.reset(new FixLengthDictDecoder<tparquet::Type::INT64>()); |
70 | 90 | break; |
71 | 32 | case tparquet::Type::INT96: |
72 | 32 | decoder.reset(new FixLengthDictDecoder<tparquet::Type::INT96>()); |
73 | 32 | break; |
74 | 15 | case tparquet::Type::FLOAT: |
75 | 15 | decoder.reset(new FixLengthDictDecoder<tparquet::Type::FLOAT>()); |
76 | 15 | break; |
77 | 22 | case tparquet::Type::DOUBLE: |
78 | 22 | decoder.reset(new FixLengthDictDecoder<tparquet::Type::DOUBLE>()); |
79 | 22 | break; |
80 | 30 | case tparquet::Type::FIXED_LEN_BYTE_ARRAY: |
81 | 30 | decoder.reset(new FixLengthDictDecoder<tparquet::Type::FIXED_LEN_BYTE_ARRAY>()); |
82 | 30 | break; |
83 | 0 | default: |
84 | 0 | return Status::InternalError("Unsupported type {}(encoding={}) in parquet decoder", |
85 | 0 | tparquet::to_string(type), tparquet::to_string(encoding)); |
86 | 892 | } |
87 | 892 | break; |
88 | 892 | case tparquet::Encoding::RLE: |
89 | 0 | switch (type) { |
90 | 0 | case tparquet::Type::BOOLEAN: |
91 | 0 | decoder.reset(new BoolRLEDecoder()); |
92 | 0 | break; |
93 | 0 | default: |
94 | 0 | return Status::InternalError("Unsupported type {}(encoding={}) in parquet decoder", |
95 | 0 | tparquet::to_string(type), tparquet::to_string(encoding)); |
96 | 0 | } |
97 | 0 | break; |
98 | 0 | case tparquet::Encoding::DELTA_BINARY_PACKED: |
99 | | // Supports only INT32 and INT64. |
100 | 0 | switch (type) { |
101 | 0 | case tparquet::Type::INT32: |
102 | 0 | decoder.reset(new DeltaBitPackDecoder<int32_t>()); |
103 | 0 | break; |
104 | 0 | case tparquet::Type::INT64: |
105 | 0 | decoder.reset(new DeltaBitPackDecoder<int64_t>()); |
106 | 0 | break; |
107 | 0 | default: |
108 | 0 | return Status::InternalError("DELTA_BINARY_PACKED only supports INT32 and INT64"); |
109 | 0 | } |
110 | 0 | break; |
111 | 0 | case tparquet::Encoding::DELTA_BYTE_ARRAY: |
112 | 0 | switch (type) { |
113 | 0 | case tparquet::Type::BYTE_ARRAY: |
114 | 0 | case tparquet::Type::FIXED_LEN_BYTE_ARRAY: |
115 | 0 | decoder.reset(new DeltaByteArrayDecoder()); |
116 | 0 | break; |
117 | 0 | default: |
118 | 0 | return Status::InternalError( |
119 | 0 | "DELTA_BYTE_ARRAY only supports BYTE_ARRAY, FIXED_LEN_BYTE_ARRAY."); |
120 | 0 | } |
121 | 0 | break; |
122 | 0 | case tparquet::Encoding::DELTA_LENGTH_BYTE_ARRAY: |
123 | 0 | switch (type) { |
124 | 0 | case tparquet::Type::BYTE_ARRAY: |
125 | 0 | decoder.reset(new DeltaLengthByteArrayDecoder()); |
126 | 0 | break; |
127 | 0 | default: |
128 | 0 | return Status::InternalError("DELTA_LENGTH_BYTE_ARRAY only supports BYTE_ARRAY."); |
129 | 0 | } |
130 | 0 | break; |
131 | 0 | case tparquet::Encoding::BYTE_STREAM_SPLIT: |
132 | 0 | switch (type) { |
133 | 0 | case tparquet::Type::INT32: |
134 | 0 | case tparquet::Type::INT64: |
135 | 0 | case tparquet::Type::INT96: |
136 | 0 | case tparquet::Type::FLOAT: |
137 | 0 | case tparquet::Type::DOUBLE: |
138 | 0 | case tparquet::Type::FIXED_LEN_BYTE_ARRAY: |
139 | 0 | decoder.reset(new ByteStreamSplitDecoder()); |
140 | 0 | break; |
141 | 0 | default: |
142 | 0 | return Status::InternalError("Unsupported type {}(encoding={}) in parquet decoder", |
143 | 0 | tparquet::to_string(type), tparquet::to_string(encoding)); |
144 | 0 | } |
145 | 0 | break; |
146 | 0 | default: |
147 | 0 | return Status::InternalError("Unsupported encoding {}(type={}) in parquet decoder", |
148 | 0 | tparquet::to_string(encoding), tparquet::to_string(type)); |
149 | 1.17k | } |
150 | 1.17k | return Status::OK(); |
151 | 1.17k | } |
152 | | #include "common/compile_check_end.h" |
153 | | |
154 | | } // namespace doris |