forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_type_array.h
More file actions
120 lines (94 loc) · 4.21 KB
/
Copy pathdata_type_array.h
File metadata and controls
120 lines (94 loc) · 4.21 KB
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
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// This file is copied from
// https://github.com/ClickHouse/ClickHouse/blob/master/src/DataTypes/DataTypeArray.h
// and modified by Doris
#pragma once
#include <gen_cpp/Types_types.h>
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <string>
#include "common/status.h"
#include "runtime/define_primitive_type.h"
#include "runtime/types.h"
#include "serde/data_type_array_serde.h"
#include "vec/core/field.h"
#include "vec/core/types.h"
#include "vec/data_types/data_type.h"
#include "vec/data_types/serde/data_type_serde.h"
namespace doris {
class PColumnMeta;
namespace vectorized {
class BufferWritable;
class IColumn;
class ReadBuffer;
} // namespace vectorized
} // namespace doris
namespace doris::vectorized {
class DataTypeArray final : public IDataType {
private:
/// The type of array elements.
DataTypePtr nested;
public:
static constexpr bool is_parametric = true;
DataTypeArray(const DataTypePtr& nested_);
TypeIndex get_type_id() const override { return TypeIndex::Array; }
TypeDescriptor get_type_as_type_descriptor() const override {
TypeDescriptor desc(TYPE_ARRAY);
desc.add_sub_type(nested->get_type_as_type_descriptor());
return desc;
}
doris::FieldType get_storage_field_type() const override {
return doris::FieldType::OLAP_FIELD_TYPE_ARRAY;
}
std::string do_get_name() const override { return "Array(" + nested->get_name() + ")"; }
const char* get_family_name() const override { return "Array"; }
MutableColumnPtr create_column() const override;
Field get_default() const override;
[[noreturn]] Field get_field(const TExprNode& node) const override {
throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
"Unimplemented get_field for array");
__builtin_unreachable();
}
bool equals(const IDataType& rhs) const override;
bool have_subtypes() const override { return true; }
bool text_can_contain_only_valid_utf8() const override {
return nested->text_can_contain_only_valid_utf8();
}
bool is_comparable() const override { return nested->is_comparable(); }
bool is_value_unambiguously_represented_in_contiguous_memory_region() const override {
return nested->is_value_unambiguously_represented_in_contiguous_memory_region();
}
const DataTypePtr& get_nested_type() const { return nested; }
/// 1 for plain array, 2 for array of arrays and so on.
size_t get_number_of_dimensions() const;
int64_t get_uncompressed_serialized_bytes(const IColumn& column,
int be_exec_version) const override;
char* serialize(const IColumn& column, char* buf, int be_exec_version) const override;
const char* deserialize(const char* buf, MutableColumnPtr* column,
int be_exec_version) const override;
void to_pb_column_meta(PColumnMeta* col_meta) const override;
std::string to_string(const IColumn& column, size_t row_num) const override;
void to_string(const IColumn& column, size_t row_num, BufferWritable& ostr) const override;
Status from_string(ReadBuffer& rb, IColumn* column) const override;
DataTypeSerDeSPtr get_serde(int nesting_level = 1) const override {
return std::make_shared<DataTypeArraySerDe>(nested->get_serde(nesting_level + 1),
nesting_level);
};
};
} // namespace doris::vectorized