22
33#include " column.h"
44#include " numeric.h"
5+ #include " utils.h"
56
67#include < memory>
78
@@ -121,13 +122,8 @@ class ColumnArrayT : public ColumnArray {
121122 * This is a static method to make such conversion verbose.
122123 */
123124 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_ );
131127 }
132128
133129 static auto Wrap (Column&& col) {
@@ -146,7 +142,7 @@ class ColumnArrayT : public ColumnArray {
146142 const size_t size_;
147143
148144 public:
149- using ValueType = typename NestedColumnType::ValueType ;
145+ using ValueType = std:: decay_t < decltype (std::declval<NestedColumnType>().At( 0 ))> ;
150146
151147 ArrayValueView (std::shared_ptr<NestedColumnType> data, size_t offset = 0 , size_t size = std::numeric_limits<size_t >::max())
152148 : typed_nested_data_(data)
@@ -178,7 +174,7 @@ class ColumnArrayT : public ColumnArray {
178174 , index_(index)
179175 {}
180176
181- using ValueType = typename NestedColumnType ::ValueType;
177+ using ValueType = typename ArrayValueView ::ValueType;
182178
183179 inline auto operator *() const {
184180 return typed_nested_data_->At (offset_ + index_);
@@ -226,6 +222,22 @@ class ColumnArrayT : public ColumnArray {
226222 inline size_t Size () const {
227223 return size_;
228224 }
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+ }
229241 };
230242
231243 inline auto At (size_t index) const {
@@ -267,6 +279,20 @@ class ColumnArrayT : public ColumnArray {
267279 AddOffset (counter);
268280 }
269281
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+
270296private:
271297 // / Helper to allow wrapping a "typeless" ColumnArray
272298 ColumnArrayT (ColumnArray&& array, std::shared_ptr<NestedColumnType> nested_data)
0 commit comments