2
2
3
3
#include " column.h"
4
4
#include " numeric.h"
5
+ #include " utils.h"
5
6
6
7
#include < memory>
7
8
@@ -121,13 +122,8 @@ class ColumnArrayT : public ColumnArray {
121
122
* This is a static method to make such conversion verbose.
122
123
*/
123
124
static auto Wrap (ColumnArray&& col) {
124
- if constexpr (std::is_base_of_v<ColumnArray, NestedColumnType> && !std::is_same_v<ColumnArray, NestedColumnType>) {
125
- // assuming NestedColumnType is ArrayT specialization
126
- return std::make_shared<ColumnArrayT<NestedColumnType>>(NestedColumnType::Wrap (col.GetData ()), col.offsets_ );
127
- } else {
128
- auto nested_data = col.GetData ()->template AsStrict <NestedColumnType>();
129
- return std::make_shared<ColumnArrayT<NestedColumnType>>(nested_data, col.offsets_ );
130
- }
125
+ auto nested_data = WrapColumn<NestedColumnType>(col.GetData ());
126
+ return std::make_shared<ColumnArrayT<NestedColumnType>>(nested_data, col.offsets_ );
131
127
}
132
128
133
129
static auto Wrap (Column&& col) {
@@ -146,7 +142,7 @@ class ColumnArrayT : public ColumnArray {
146
142
const size_t size_;
147
143
148
144
public:
149
- using ValueType = typename NestedColumnType::ValueType ;
145
+ using ValueType = std:: decay_t < decltype (std::declval<NestedColumnType>().At( 0 ))> ;
150
146
151
147
ArrayValueView (std::shared_ptr<NestedColumnType> data, size_t offset = 0 , size_t size = std::numeric_limits<size_t >::max())
152
148
: typed_nested_data_(data)
@@ -178,7 +174,7 @@ class ColumnArrayT : public ColumnArray {
178
174
, index_(index)
179
175
{}
180
176
181
- using ValueType = typename NestedColumnType ::ValueType;
177
+ using ValueType = typename ArrayValueView ::ValueType;
182
178
183
179
inline auto operator *() const {
184
180
return typed_nested_data_->At (offset_ + index_);
@@ -226,6 +222,22 @@ class ColumnArrayT : public ColumnArray {
226
222
inline size_t Size () const {
227
223
return size_;
228
224
}
225
+
226
+ inline bool operator ==(const ArrayValueView& other) const {
227
+ if (size () != other.size ()) {
228
+ return false ;
229
+ }
230
+ for (size_t i = 0 ; i < size_; ++i) {
231
+ if ((*this )[i] != other[i]) {
232
+ return false ;
233
+ }
234
+ }
235
+ return true ;
236
+ }
237
+
238
+ inline bool operator !=(const ArrayValueView& other) const {
239
+ return !(*this == other);
240
+ }
229
241
};
230
242
231
243
inline auto At (size_t index) const {
@@ -267,6 +279,20 @@ class ColumnArrayT : public ColumnArray {
267
279
AddOffset (counter);
268
280
}
269
281
282
+ ColumnRef Slice (size_t begin, size_t size) const override {
283
+ return Wrap (ColumnArray::Slice (begin, size));
284
+ }
285
+
286
+ ColumnRef CloneEmpty () const override {
287
+ return Wrap (ColumnArray::CloneEmpty ());
288
+ }
289
+
290
+ void Swap (Column& other) override {
291
+ auto & col = dynamic_cast <ColumnArrayT<NestedColumnType> &>(other);
292
+ typed_nested_data_.swap (col.typed_nested_data_ );
293
+ ColumnArray::Swap (other);
294
+ }
295
+
270
296
private:
271
297
// / Helper to allow wrapping a "typeless" ColumnArray
272
298
ColumnArrayT (ColumnArray&& array, std::shared_ptr<NestedColumnType> nested_data)
0 commit comments