be/src/format/parquet/level_decoder.h
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 | | #pragma once |
19 | | |
20 | | #include <gen_cpp/parquet_types.h> |
21 | | #include <stddef.h> |
22 | | |
23 | | #include <cstdint> |
24 | | |
25 | | #include "common/status.h" |
26 | | #include "format/parquet/parquet_common.h" |
27 | | #include "util/bit_stream_utils.h" |
28 | | #include "util/rle_encoding.h" |
29 | | #include "util/slice.h" |
30 | | |
31 | | namespace doris { |
32 | | #include "common/compile_check_begin.h" |
33 | | class LevelDecoder { |
34 | | public: |
35 | 363k | LevelDecoder() = default; |
36 | | ~LevelDecoder() = default; |
37 | | |
38 | | Status init(Slice* slice, tparquet::Encoding::type encoding, level_t max_level, |
39 | | uint32_t num_levels); |
40 | | |
41 | | Status init_v2(const Slice& levels, level_t max_level, uint32_t num_levels); |
42 | | |
43 | | inline bool has_levels() const { return _num_levels > 0; } |
44 | | |
45 | | size_t get_levels(level_t* levels, size_t n); |
46 | | |
47 | 2.13M | inline size_t get_next_run(level_t* val, size_t max_run) { |
48 | 2.13M | return _rle_decoder.GetNextRun(val, max_run); |
49 | 2.13M | } |
50 | | |
51 | 274M | inline level_t get_next() { |
52 | 274M | level_t next = -1; |
53 | 274M | _rle_decoder.Get(&next); |
54 | 274M | return next; |
55 | 274M | } |
56 | | |
57 | 33.3k | inline void rewind_one() { _rle_decoder.RewindOne(); } |
58 | | |
59 | 1 | const RleDecoder<level_t>& rle_decoder() const { return _rle_decoder; } |
60 | | |
61 | | private: |
62 | | tparquet::Encoding::type _encoding; |
63 | | level_t _bit_width = 0; |
64 | | level_t _max_level = 0; |
65 | | uint32_t _num_levels = 0; |
66 | | RleDecoder<level_t> _rle_decoder; |
67 | | BitReader _bit_packed_decoder; |
68 | | }; |
69 | | #include "common/compile_check_end.h" |
70 | | |
71 | | } // namespace doris |