#include "GatherUtils.h" namespace DB { /// Creates IArraySource from ColumnArray template struct ArraySourceCreator; template struct ArraySourceCreator { static std::unique_ptr create(const ColumnArray & col, const ColumnUInt8 * null_map, bool is_const, size_t total_rows) { if (typeid_cast *>(&col.getData())) { if (null_map) { if (is_const) return std::make_unique>>>(col, *null_map, total_rows); return std::make_unique>>(col, *null_map); } if (is_const) return std::make_unique>>(col, total_rows); return std::make_unique>(col); } return ArraySourceCreator::create(col, null_map, is_const, total_rows); } }; template <> struct ArraySourceCreator<> { static std::unique_ptr create(const ColumnArray & col, const ColumnUInt8 * null_map, bool is_const, size_t total_rows) { if (null_map) { if (is_const) return std::make_unique>>(col, *null_map, total_rows); return std::make_unique>(col, *null_map); } if (is_const) return std::make_unique>(col, total_rows); return std::make_unique(col); } }; std::unique_ptr createArraySource(const ColumnArray & col, bool is_const, size_t total_rows) { using Creator = typename ApplyTypeListForClass::Type; if (auto column_nullable = typeid_cast(&col.getData())) { auto column = ColumnArray::create(column_nullable->getNestedColumnPtr(), col.getOffsetsPtr()); return Creator::create(*column, &column_nullable->getNullMapColumn(), is_const, total_rows); } return Creator::create(col, nullptr, is_const, total_rows); } }