be/src/format/parquet/vparquet_file_metadata.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/vparquet_file_metadata.h" |
19 | | |
20 | | #include <gen_cpp/parquet_types.h> |
21 | | |
22 | | #include <sstream> |
23 | | #include <vector> |
24 | | |
25 | | #include "format/parquet/schema_desc.h" |
26 | | #include "runtime/exec_env.h" |
27 | | #include "runtime/memory/mem_tracker_limiter.h" |
28 | | |
29 | | namespace doris { |
30 | | #include "common/compile_check_begin.h" |
31 | | |
32 | | FileMetaData::FileMetaData(tparquet::FileMetaData& metadata, size_t mem_size) |
33 | 99 | : _metadata(metadata), _mem_size(mem_size) { |
34 | 99 | ExecEnv::GetInstance()->parquet_meta_tracker()->consume(mem_size); |
35 | 99 | } |
36 | | |
37 | 99 | FileMetaData::~FileMetaData() { |
38 | 99 | ExecEnv::GetInstance()->parquet_meta_tracker()->release(_mem_size); |
39 | 99 | } |
40 | | |
41 | | Status FileMetaData::init_schema(const bool enable_mapping_varbinary, |
42 | 99 | bool enable_mapping_timestamp_tz) { |
43 | 99 | if (_metadata.schema[0].num_children <= 0) { |
44 | 0 | return Status::Corruption("Invalid parquet schema"); |
45 | 0 | } |
46 | 99 | _schema.set_enable_mapping_varbinary(enable_mapping_varbinary); |
47 | 99 | _schema.set_enable_mapping_timestamp_tz(enable_mapping_timestamp_tz); |
48 | 99 | return _schema.parse_from_thrift(_metadata.schema); |
49 | 99 | } |
50 | | |
51 | 93 | const tparquet::FileMetaData& FileMetaData::to_thrift() const { |
52 | 93 | return _metadata; |
53 | 93 | } |
54 | | |
55 | 0 | std::string FileMetaData::debug_string() const { |
56 | 0 | std::stringstream out; |
57 | 0 | out << "Parquet Metadata("; |
58 | 0 | out << "; version=" << _metadata.version; |
59 | 0 | out << ")"; |
60 | 0 | return out.str(); |
61 | 0 | } |
62 | | #include "common/compile_check_end.h" |
63 | | |
64 | | } // namespace doris |