be/src/information_schema/schema_scanner_helper.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 "information_schema/schema_scanner_helper.h" |
19 | | |
20 | | #include "cctz/time_zone.h" |
21 | | #include "core/block/block.h" |
22 | | #include "core/data_type/data_type_factory.hpp" |
23 | | #include "core/data_type/primitive_type.h" |
24 | | #include "core/string_ref.h" |
25 | | #include "runtime/exec_env.h" |
26 | | #include "runtime/runtime_state.h" |
27 | | #include "util/client_cache.h" |
28 | | #include "util/thrift_rpc_helper.h" |
29 | | |
30 | | namespace doris { |
31 | | |
32 | | void SchemaScannerHelper::insert_string_value(int col_index, std::string_view str_val, |
33 | 1 | Block* block) { |
34 | 1 | MutableColumnPtr mutable_col_ptr; |
35 | 1 | mutable_col_ptr = block->get_by_position(col_index).column->assume_mutable(); |
36 | 1 | auto* nullable_column = assert_cast<ColumnNullable*>(mutable_col_ptr.get()); |
37 | 1 | IColumn* col_ptr = &nullable_column->get_nested_column(); |
38 | 1 | assert_cast<ColumnString*>(col_ptr)->insert_data(str_val.data(), str_val.size()); |
39 | 1 | nullable_column->push_false_to_nullmap(1); |
40 | 1 | } |
41 | | |
42 | | void SchemaScannerHelper::insert_datetime_value(int col_index, const std::vector<void*>& datas, |
43 | 0 | Block* block) { |
44 | 0 | MutableColumnPtr mutable_col_ptr; |
45 | 0 | mutable_col_ptr = block->get_by_position(col_index).column->assume_mutable(); |
46 | 0 | auto* nullable_column = assert_cast<ColumnNullable*>(mutable_col_ptr.get()); |
47 | 0 | IColumn* col_ptr = &nullable_column->get_nested_column(); |
48 | 0 | auto data = datas[0]; |
49 | 0 | assert_cast<ColumnDateTime*>(col_ptr)->insert_data(reinterpret_cast<char*>(data), 0); |
50 | 0 | nullable_column->push_false_to_nullmap(1); |
51 | 0 | } |
52 | | |
53 | | void SchemaScannerHelper::insert_datetime_value(int col_index, int64_t timestamp, |
54 | 0 | const cctz::time_zone& ctz, Block* block) { |
55 | 0 | MutableColumnPtr mutable_col_ptr; |
56 | 0 | mutable_col_ptr = block->get_by_position(col_index).column->assume_mutable(); |
57 | 0 | auto* nullable_column = assert_cast<ColumnNullable*>(mutable_col_ptr.get()); |
58 | 0 | IColumn* col_ptr = &nullable_column->get_nested_column(); |
59 | |
|
60 | 0 | std::vector<void*> datas(1); |
61 | 0 | VecDateTimeValue src[1]; |
62 | 0 | src[0].from_unixtime(timestamp, ctz); |
63 | 0 | datas[0] = src; |
64 | 0 | auto data = datas[0]; |
65 | 0 | assert_cast<ColumnDateTime*>(col_ptr)->insert_data(reinterpret_cast<char*>(data), 0); |
66 | 0 | nullable_column->push_false_to_nullmap(1); |
67 | 0 | } |
68 | | |
69 | 1 | void SchemaScannerHelper::insert_bool_value(int col_index, bool bool_val, Block* block) { |
70 | 1 | MutableColumnPtr mutable_col_ptr; |
71 | 1 | mutable_col_ptr = block->get_by_position(col_index).column->assume_mutable(); |
72 | 1 | auto* nullable_column = assert_cast<ColumnNullable*>(mutable_col_ptr.get()); |
73 | 1 | IColumn* col_ptr = &nullable_column->get_nested_column(); |
74 | 1 | assert_cast<ColumnBool*>(col_ptr)->insert_value(bool_val); |
75 | 1 | nullable_column->push_false_to_nullmap(1); |
76 | 1 | } |
77 | | |
78 | 0 | void SchemaScannerHelper::insert_int32_value(int col_index, int32_t int_val, Block* block) { |
79 | 0 | MutableColumnPtr mutable_col_ptr; |
80 | 0 | mutable_col_ptr = block->get_by_position(col_index).column->assume_mutable(); |
81 | 0 | auto* nullable_column = assert_cast<ColumnNullable*>(mutable_col_ptr.get()); |
82 | 0 | IColumn* col_ptr = &nullable_column->get_nested_column(); |
83 | 0 | assert_cast<ColumnInt32*>(col_ptr)->insert_value(int_val); |
84 | 0 | nullable_column->push_false_to_nullmap(1); |
85 | 0 | } |
86 | | |
87 | 2 | void SchemaScannerHelper::insert_int64_value(int col_index, int64_t int_val, Block* block) { |
88 | 2 | MutableColumnPtr mutable_col_ptr; |
89 | 2 | mutable_col_ptr = block->get_by_position(col_index).column->assume_mutable(); |
90 | 2 | auto* nullable_column = assert_cast<ColumnNullable*>(mutable_col_ptr.get()); |
91 | 2 | IColumn* col_ptr = &nullable_column->get_nested_column(); |
92 | 2 | assert_cast<ColumnInt64*>(col_ptr)->insert_value(int_val); |
93 | 2 | nullable_column->push_false_to_nullmap(1); |
94 | 2 | } |
95 | | |
96 | 0 | void SchemaScannerHelper::insert_double_value(int col_index, double double_val, Block* block) { |
97 | 0 | MutableColumnPtr mutable_col_ptr; |
98 | 0 | mutable_col_ptr = block->get_by_position(col_index).column->assume_mutable(); |
99 | 0 | auto* nullable_column = assert_cast<ColumnNullable*>(mutable_col_ptr.get()); |
100 | 0 | IColumn* col_ptr = &nullable_column->get_nested_column(); |
101 | 0 | assert_cast<ColumnFloat64*>(col_ptr)->insert_value(double_val); |
102 | 0 | nullable_column->push_false_to_nullmap(1); |
103 | 0 | } |
104 | | } // namespace doris |