1 | #pragma once |
2 | |
3 | #include <Core/Field.h> |
4 | #include <Core/NamesAndTypes.h> |
5 | #include <Core/ColumnsWithTypeAndName.h> |
6 | #include <Columns/IColumn.h> |
7 | |
8 | class IFunctionBase; |
9 | using FunctionBasePtr = std::shared_ptr<IFunctionBase>; |
10 | |
11 | |
12 | namespace DB |
13 | { |
14 | |
15 | |
16 | /** A column containing a lambda expression. |
17 | * Behaves like a constant-column. Contains an expression, but not input or output data. |
18 | */ |
19 | class ColumnFunction final : public COWHelper<IColumn, ColumnFunction> |
20 | { |
21 | private: |
22 | friend class COWHelper<IColumn, ColumnFunction>; |
23 | |
24 | ColumnFunction(size_t size, FunctionBasePtr function_, const ColumnsWithTypeAndName & columns_to_capture); |
25 | |
26 | public: |
27 | const char * getFamilyName() const override { return "Function" ; } |
28 | |
29 | MutableColumnPtr cloneResized(size_t size) const override; |
30 | |
31 | size_t size() const override { return size_; } |
32 | |
33 | ColumnPtr cut(size_t start, size_t length) const override; |
34 | ColumnPtr replicate(const Offsets & offsets) const override; |
35 | ColumnPtr filter(const Filter & filt, ssize_t result_size_hint) const override; |
36 | ColumnPtr permute(const Permutation & perm, size_t limit) const override; |
37 | ColumnPtr index(const IColumn & indexes, size_t limit) const override; |
38 | |
39 | std::vector<MutableColumnPtr> scatter(IColumn::ColumnIndex num_columns, |
40 | const IColumn::Selector & selector) const override; |
41 | |
42 | void getExtremes(Field &, Field &) const override {} |
43 | |
44 | size_t byteSize() const override; |
45 | size_t allocatedBytes() const override; |
46 | |
47 | void appendArguments(const ColumnsWithTypeAndName & columns); |
48 | ColumnWithTypeAndName reduce() const; |
49 | |
50 | Field operator[](size_t) const override |
51 | { |
52 | throw Exception("Cannot get value from " + getName(), ErrorCodes::NOT_IMPLEMENTED); |
53 | } |
54 | |
55 | void get(size_t, Field &) const override |
56 | { |
57 | throw Exception("Cannot get value from " + getName(), ErrorCodes::NOT_IMPLEMENTED); |
58 | } |
59 | |
60 | StringRef getDataAt(size_t) const override |
61 | { |
62 | throw Exception("Cannot get value from " + getName(), ErrorCodes::NOT_IMPLEMENTED); |
63 | } |
64 | |
65 | void insert(const Field &) override |
66 | { |
67 | throw Exception("Cannot insert into " + getName(), ErrorCodes::NOT_IMPLEMENTED); |
68 | } |
69 | |
70 | void insertDefault() override |
71 | { |
72 | throw Exception("Cannot insert into " + getName(), ErrorCodes::NOT_IMPLEMENTED); |
73 | } |
74 | |
75 | void insertRangeFrom(const IColumn &, size_t, size_t) override |
76 | { |
77 | throw Exception("Cannot insert into " + getName(), ErrorCodes::NOT_IMPLEMENTED); |
78 | } |
79 | |
80 | void insertData(const char *, size_t) override |
81 | { |
82 | throw Exception("Cannot insert into " + getName(), ErrorCodes::NOT_IMPLEMENTED); |
83 | } |
84 | |
85 | StringRef serializeValueIntoArena(size_t, Arena &, char const *&) const override |
86 | { |
87 | throw Exception("Cannot serialize from " + getName(), ErrorCodes::NOT_IMPLEMENTED); |
88 | } |
89 | |
90 | const char * deserializeAndInsertFromArena(const char *) override |
91 | { |
92 | throw Exception("Cannot deserialize to " + getName(), ErrorCodes::NOT_IMPLEMENTED); |
93 | } |
94 | |
95 | void updateHashWithValue(size_t, SipHash &) const override |
96 | { |
97 | throw Exception("updateHashWithValue is not implemented for " + getName(), ErrorCodes::NOT_IMPLEMENTED); |
98 | } |
99 | |
100 | void popBack(size_t) override |
101 | { |
102 | throw Exception("popBack is not implemented for " + getName(), ErrorCodes::NOT_IMPLEMENTED); |
103 | } |
104 | |
105 | int compareAt(size_t, size_t, const IColumn &, int) const override |
106 | { |
107 | throw Exception("compareAt is not implemented for " + getName(), ErrorCodes::NOT_IMPLEMENTED); |
108 | } |
109 | |
110 | void getPermutation(bool, size_t, int, Permutation &) const override |
111 | { |
112 | throw Exception("getPermutation is not implemented for " + getName(), ErrorCodes::NOT_IMPLEMENTED); |
113 | } |
114 | |
115 | void gather(ColumnGathererStream &) override |
116 | { |
117 | throw Exception("Method gather is not supported for " + getName(), ErrorCodes::NOT_IMPLEMENTED); |
118 | } |
119 | |
120 | private: |
121 | size_t size_; |
122 | FunctionBasePtr function; |
123 | ColumnsWithTypeAndName captured_columns; |
124 | |
125 | void appendArgument(const ColumnWithTypeAndName & column); |
126 | }; |
127 | |
128 | } |
129 | |