Skip to content

Commit 873107d

Browse files
committed
Review changes
1 parent 5948eb6 commit 873107d

File tree

9 files changed

+152
-554
lines changed

9 files changed

+152
-554
lines changed

clickhouse/columns/column.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ class Column : public std::enable_shared_from_this<Column> {
8080
/// Returns count of rows in the column.
8181
virtual size_t Size() const = 0;
8282

83-
/// Increase the capacity of the column (currently only supported by numeric/date types at this time)
84-
virtual void Reserve([[maybe_unused]]size_t new_cap) {}
85-
86-
/// Returns the capacity of the column (currently only supported by numeric/date types at this time)
87-
virtual size_t Capacity() const { return Size(); }
88-
8983
/// Makes slice of the current column.
9084
virtual ColumnRef Slice(size_t begin, size_t len) const = 0;
9185

clickhouse/columns/date.cpp

Lines changed: 30 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@ uint16_t ColumnDate::RawAt(size_t n) const {
3131
return data_->At(n);
3232
}
3333

34-
void ColumnDate::SwapElements(size_t pos1, size_t pos2) {
35-
data_->SwapElements(pos1, pos2);
34+
void ColumnDate::Append(ColumnRef column) {
35+
if (auto col = column->As<ColumnDate>()) {
36+
data_->Append(col->data_);
37+
}
3638
}
3739

38-
bool ColumnDate::CompareElementsGT(size_t pos1, size_t pos2) const {
39-
return data_->CompareElementsGT(pos1, pos2);
40+
std::vector<uint16_t> &ColumnDate::GetRawVector() {
41+
return data_->GetRawVector();
4042
}
4143

42-
bool ColumnDate::CompareElementsLT(size_t pos1, size_t pos2) const {
43-
return data_->CompareElementsLT(pos1, pos2);
44+
void ColumnDate::Reserve(size_t new_cap) {
45+
data_->Reserve(new_cap);
4446
}
4547

46-
void ColumnDate::Append(ColumnRef column) {
47-
if (auto col = column->As<ColumnDate>()) {
48-
data_->Append(col->data_);
49-
}
48+
size_t ColumnDate::Capacity() const {
49+
return data_->Capacity();
5050
}
5151

5252
bool ColumnDate::LoadBody(InputStream* input, size_t rows) {
@@ -61,14 +61,6 @@ size_t ColumnDate::Size() const {
6161
return data_->Size();
6262
}
6363

64-
void ColumnDate::Reserve(size_t new_cap) {
65-
data_->Reserve(new_cap);
66-
}
67-
68-
size_t ColumnDate::Capacity() const {
69-
return data_->Capacity();
70-
}
71-
7264
ColumnRef ColumnDate::Slice(size_t begin, size_t len) const {
7365
auto col = data_->Slice(begin, len)->As<ColumnUInt16>();
7466
auto result = std::make_shared<ColumnDate>();
@@ -118,24 +110,24 @@ void ColumnDate32::Append(ColumnRef column) {
118110
}
119111
}
120112

121-
void ColumnDate32::AppendRaw(int32_t value) {
122-
data_->Append(value);
113+
std::vector<int32_t> & ColumnDate32::GetRawVector() {
114+
return data_->GetRawVector();
123115
}
124116

125-
int32_t ColumnDate32::RawAt(size_t n) const {
126-
return data_->At(n);
117+
void ColumnDate32::Reserve(size_t new_cap) {
118+
data_->Reserve(new_cap);
127119
}
128120

129-
void ColumnDate32::SwapElements(size_t pos1, size_t pos2) {
130-
data_->SwapElements(pos1, pos2);
121+
size_t ColumnDate32::Capacity() const {
122+
return data_->Capacity();
131123
}
132124

133-
bool ColumnDate32::CompareElementsGT(size_t pos1, size_t pos2) const {
134-
return data_->CompareElementsGT(pos1, pos2);
125+
void ColumnDate32::AppendRaw(int32_t value) {
126+
data_->Append(value);
135127
}
136128

137-
bool ColumnDate32::CompareElementsLT(size_t pos1, size_t pos2) const {
138-
return data_->CompareElementsLT(pos1, pos2);
129+
int32_t ColumnDate32::RawAt(size_t n) const {
130+
return data_->At(n);
139131
}
140132

141133
bool ColumnDate32::LoadBody(InputStream* input, size_t rows) {
@@ -150,14 +142,6 @@ size_t ColumnDate32::Size() const {
150142
return data_->Size();
151143
}
152144

153-
void ColumnDate32::Reserve(size_t new_cap) {
154-
data_->Reserve(new_cap);
155-
}
156-
157-
size_t ColumnDate32::Capacity() const {
158-
return data_->Capacity();
159-
}
160-
161145
ColumnRef ColumnDate32::Slice(size_t begin, size_t len) const {
162146
auto col = data_->Slice(begin, len)->As<ColumnInt32>();
163147
auto result = std::make_shared<ColumnDate32>();
@@ -208,22 +192,22 @@ std::string ColumnDateTime::Timezone() const {
208192
return type_->As<DateTimeType>()->Timezone();
209193
}
210194

211-
void ColumnDateTime::SwapElements(size_t pos1, size_t pos2) {
212-
data_->SwapElements(pos1, pos2);
195+
void ColumnDateTime::Append(ColumnRef column) {
196+
if (auto col = column->As<ColumnDateTime>()) {
197+
data_->Append(col->data_);
198+
}
213199
}
214200

215-
bool ColumnDateTime::CompareElementsGT(size_t pos1, size_t pos2) const {
216-
return data_->CompareElementsGT(pos1, pos2);
201+
std::vector<uint32_t> & ColumnDateTime::GetRawVector() {
202+
return data_->GetRawVector();
217203
}
218204

219-
bool ColumnDateTime::CompareElementsLT(size_t pos1, size_t pos2) const {
220-
return data_->CompareElementsLT(pos1, pos2);
205+
void ColumnDateTime::Reserve(size_t new_cap) {
206+
data_->Reserve(new_cap);
221207
}
222208

223-
void ColumnDateTime::Append(ColumnRef column) {
224-
if (auto col = column->As<ColumnDateTime>()) {
225-
data_->Append(col->data_);
226-
}
209+
size_t ColumnDateTime::Capacity() const {
210+
return data_->Capacity();
227211
}
228212

229213
bool ColumnDateTime::LoadBody(InputStream* input, size_t rows) {
@@ -238,14 +222,6 @@ size_t ColumnDateTime::Size() const {
238222
return data_->Size();
239223
}
240224

241-
void ColumnDateTime::Reserve(size_t new_cap) {
242-
data_->Reserve(new_cap);
243-
}
244-
245-
size_t ColumnDateTime::Capacity() const {
246-
return data_->Capacity();
247-
}
248-
249225
void ColumnDateTime::Clear() {
250226
data_->Clear();
251227
}
@@ -301,18 +277,6 @@ Int64 ColumnDateTime64::At(size_t n) const {
301277
return static_cast<Int64>(data_->At(n));
302278
}
303279

304-
void ColumnDateTime64::SwapElements(size_t pos1, size_t pos2) {
305-
data_->SwapElements(pos1, pos2);
306-
}
307-
308-
bool ColumnDateTime64::CompareElementsGT(size_t pos1, size_t pos2) const {
309-
return data_->CompareElementsGT(pos1, pos2);
310-
}
311-
312-
bool ColumnDateTime64::CompareElementsLT(size_t pos1, size_t pos2) const {
313-
return data_->CompareElementsLT(pos1, pos2);
314-
}
315-
316280
std::string ColumnDateTime64::Timezone() const {
317281
return type_->As<DateTime64Type>()->Timezone();
318282
}
@@ -339,14 +303,6 @@ size_t ColumnDateTime64::Size() const {
339303
return data_->Size();
340304
}
341305

342-
void ColumnDateTime64::Reserve(size_t new_cap) {
343-
data_->Reserve(new_cap);
344-
}
345-
346-
size_t ColumnDateTime64::Capacity() const {
347-
return data_->Capacity();
348-
}
349-
350306
ItemView ColumnDateTime64::GetItem(size_t index) const {
351307
return ItemView(Type::DateTime64, data_->GetItem(index));
352308
}

clickhouse/columns/date.h

Lines changed: 20 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,17 @@ class ColumnDate : public Column {
2727
void AppendRaw(uint16_t value);
2828
uint16_t RawAt(size_t n) const;
2929

30-
/// Swap two Elements/rows in the column
31-
void SwapElements(size_t pos1, size_t pos2);
30+
/// Appends content of given column to the end of current one.
31+
void Append(ColumnRef column) override;
3232

33-
/// Test if the value at position 1 is greater than the value at position 2
34-
/// No range checking is performed for performance
35-
bool CompareElementsGT(size_t pos1, size_t pos2) const;
33+
/// Get Raw Vector Contents
34+
std::vector<uint16_t> & GetRawVector();
3635

37-
/// Test if the value at position 1 is less than the value at position 2
38-
/// No range checking is performed for performance
39-
bool CompareElementsLT(size_t pos1, size_t pos2) const;
36+
/// Increase the capacity of the column
37+
void Reserve(size_t new_cap);
4038

41-
/// Appends content of given column to the end of current one.
42-
void Append(ColumnRef column) override;
39+
/// Returns the capacity of the column
40+
size_t Capacity() const;
4341

4442
/// Loads column data from input stream.
4543
bool LoadBody(InputStream* input, size_t rows) override;
@@ -53,12 +51,6 @@ class ColumnDate : public Column {
5351
/// Returns count of rows in the column.
5452
size_t Size() const override;
5553

56-
/// Increase the capacity of the column
57-
void Reserve(size_t new_cap) override;
58-
59-
/// Returns the capacity of the column
60-
size_t Capacity() const override;
61-
6254
/// Makes slice of the current column.
6355
ColumnRef Slice(size_t begin, size_t len) const override;
6456
ColumnRef CloneEmpty() const override;
@@ -94,16 +86,14 @@ class ColumnDate32 : public Column {
9486
void AppendRaw(int32_t value);
9587
int32_t RawAt(size_t n) const;
9688

97-
/// Swap two Elements/rows in the column
98-
void SwapElements(size_t pos1, size_t pos2);
89+
/// Get Raw Vector Contents
90+
std::vector<int32_t> & GetRawVector();
9991

100-
/// Test if the value at position 1 is greater than the value at position 2
101-
/// No range checking is performed for performance
102-
bool CompareElementsGT(size_t pos1, size_t pos2) const;
92+
/// Increase the capacity of the column
93+
void Reserve(size_t new_cap);
10394

104-
/// Test if the value at position 1 is less than the value at position 2
105-
/// No range checking is performed for performance
106-
bool CompareElementsLT(size_t pos1, size_t pos2) const;
95+
/// Returns the capacity of the column
96+
size_t Capacity() const;
10797

10898
/// Loads column data from input stream.
10999
bool LoadBody(InputStream* input, size_t rows) override;
@@ -117,12 +107,6 @@ class ColumnDate32 : public Column {
117107
/// Returns count of rows in the column.
118108
size_t Size() const override;
119109

120-
/// Increase the capacity of the column
121-
void Reserve(size_t new_cap) override;
122-
123-
/// Returns the capacity of the column
124-
size_t Capacity() const override;
125-
126110
/// Makes slice of the current column.
127111
ColumnRef Slice(size_t begin, size_t len) const override;
128112
ColumnRef CloneEmpty() const override;
@@ -156,16 +140,14 @@ class ColumnDateTime : public Column {
156140
/// Timezone associated with a data column.
157141
std::string Timezone() const;
158142

159-
/// Swap two Elements/rows in the column
160-
void SwapElements(size_t pos1, size_t pos2);
143+
/// Get Raw Vector Contents
144+
std::vector<uint32_t> & GetRawVector();
161145

162-
/// Test if the value at position 1 is greater than the value at position 2
163-
/// No range checking is performed for performance
164-
bool CompareElementsGT(size_t pos1, size_t pos2) const;
146+
/// Increase the capacity of the column
147+
void Reserve(size_t new_cap);
165148

166-
/// Test if the value at position 1 is less than the value at position 2
167-
/// No range checking is performed for performance
168-
bool CompareElementsLT(size_t pos1, size_t pos2) const;
149+
/// Returns the capacity of the column
150+
size_t Capacity() const;
169151

170152
public:
171153
/// Appends content of given column to the end of current one.
@@ -183,12 +165,6 @@ class ColumnDateTime : public Column {
183165
/// Returns count of rows in the column.
184166
size_t Size() const override;
185167

186-
/// Increase the capacity of the column
187-
void Reserve(size_t new_cap) override;
188-
189-
/// Returns the capacity of the column
190-
size_t Capacity() const override;
191-
192168
/// Makes slice of the current column.
193169
ColumnRef Slice(size_t begin, size_t len) const override;
194170
ColumnRef CloneEmpty() const override;
@@ -223,17 +199,6 @@ class ColumnDateTime64 : public Column {
223199
/// Timezone associated with a data column.
224200
std::string Timezone() const;
225201

226-
/// Swap two Elements/rows in the column
227-
void SwapElements(size_t pos1, size_t pos2);
228-
229-
/// Test if the value at position 1 is greater than the value at position 2
230-
/// No range checking is performed for performance
231-
bool CompareElementsGT(size_t pos1, size_t pos2) const;
232-
233-
/// Test if the value at position 1 is less than the value at position 2
234-
/// No range checking is performed for performance
235-
bool CompareElementsLT(size_t pos1, size_t pos2) const;
236-
237202
public:
238203
/// Appends content of given column to the end of current one.
239204
void Append(ColumnRef column) override;
@@ -250,12 +215,6 @@ class ColumnDateTime64 : public Column {
250215
/// Returns count of rows in the column.
251216
size_t Size() const override;
252217

253-
/// Increase the capacity of the column
254-
void Reserve(size_t new_cap) override;
255-
256-
/// Returns the capacity of the column
257-
size_t Capacity() const override;
258-
259218
/// Makes slice of the current column.
260219
ColumnRef Slice(size_t begin, size_t len) const override;
261220
ColumnRef CloneEmpty() const override;

clickhouse/columns/decimal.cpp

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -205,36 +205,6 @@ void ColumnDecimal::SaveBody(OutputStream* output) {
205205
data_->SaveBody(output);
206206
}
207207

208-
void ColumnDecimal::SwapElements(size_t pos1, size_t pos2) {
209-
if (data_->Type()->GetCode() == Type::Int32) {
210-
data_->As<ColumnInt32>()->SwapElements(pos1, pos2);
211-
} else if (data_->Type()->GetCode() == Type::Int64) {
212-
data_->As<ColumnInt64>()->SwapElements(pos1, pos2);
213-
} else {
214-
data_->As<ColumnInt128>()->SwapElements(pos1, pos2);
215-
}
216-
}
217-
218-
bool ColumnDecimal::CompareElementsGT(size_t pos1, size_t pos2) const {
219-
if (data_->Type()->GetCode() == Type::Int32) {
220-
return data_->As<ColumnInt32>()->CompareElementsGT(pos1, pos2);
221-
} else if (data_->Type()->GetCode() == Type::Int64) {
222-
return data_->As<ColumnInt64>()->CompareElementsGT(pos1, pos2);
223-
} else {
224-
return data_->As<ColumnInt128>()->CompareElementsGT(pos1, pos2);
225-
}
226-
}
227-
228-
bool ColumnDecimal::CompareElementsLT(size_t pos1, size_t pos2) const {
229-
if (data_->Type()->GetCode() == Type::Int32) {
230-
return data_->As<ColumnInt32>()->CompareElementsLT(pos1, pos2);
231-
} else if (data_->Type()->GetCode() == Type::Int64) {
232-
return data_->As<ColumnInt64>()->CompareElementsLT(pos1, pos2);
233-
} else {
234-
return data_->As<ColumnInt128>()->CompareElementsLT(pos1, pos2);
235-
}
236-
}
237-
238208
void ColumnDecimal::Clear() {
239209
data_->Clear();
240210
}
@@ -243,14 +213,6 @@ size_t ColumnDecimal::Size() const {
243213
return data_->Size();
244214
}
245215

246-
void ColumnDecimal::Reserve(size_t new_cap) {
247-
data_->Reserve(new_cap);
248-
}
249-
250-
size_t ColumnDecimal::Capacity() const {
251-
return data_->Capacity();
252-
}
253-
254216
ColumnRef ColumnDecimal::Slice(size_t begin, size_t len) const {
255217
// coundn't use std::make_shared since this c-tor is private
256218
return ColumnRef{new ColumnDecimal(type_, data_->Slice(begin, len))};

0 commit comments

Comments
 (0)