From 19bd6f5d255d6226be057c14ae8451ad37870d21 Mon Sep 17 00:00:00 2001 From: ivanmorozov333 Date: Wed, 8 Jan 2025 10:04:28 +0300 Subject: [PATCH] corrections --- ydb/core/formats/arrow/process_columns.h | 93 ++++++++++--------- .../operations/slice_builder/pack_builder.cpp | 2 +- 2 files changed, 48 insertions(+), 47 deletions(-) diff --git a/ydb/core/formats/arrow/process_columns.h b/ydb/core/formats/arrow/process_columns.h index 1d05ba16f822..f6e6f3912890 100644 --- a/ydb/core/formats/arrow/process_columns.h +++ b/ydb/core/formats/arrow/process_columns.h @@ -20,53 +20,12 @@ class TOrderedColumnIndexesImpl { public: TOrderedColumnIndexesImpl() = default; - TOrderedColumnIndexesImpl(const ui32 columnsCount); - TOrderedColumnIndexesImpl(const std::vector& columnIndexes); - TOrderedColumnIndexesImpl(std::vector&& columnIndexes); -}; + explicit TOrderedColumnIndexesImpl(const ui32 columnsCount); + explicit TOrderedColumnIndexesImpl(const std::vector& columnIndexes); + explicit TOrderedColumnIndexesImpl(std::vector&& columnIndexes); -template -class TContainerWithIndexes: public TOrderedColumnIndexesImpl { -private: - using TBase = TOrderedColumnIndexesImpl; - YDB_ACCESSOR_DEF(std::shared_ptr, Container); - -public: - TContainerWithIndexes() = default; - - TContainerWithIndexes(const std::vector& columnIndexes, const std::shared_ptr& container) - : TBase(columnIndexes) - , Container(container) { - if (Container) { - Y_ABORT_UNLESS((ui32)Container->num_columns() == columnIndexes.size()); - } else { - Y_ABORT_UNLESS(!columnIndexes.size()); - } - } - - TContainerWithIndexes(const std::shared_ptr& container) - : TBase(TSimpleValidator::CheckNotNull(container)->num_columns()) - , Container(container) { - } - - TContainerWithIndexes BuildWithAnotherContainer(const std::shared_ptr& container) const { - return TContainerWithIndexes(GetColumnIndexes(), container); - } - - bool operator!() const { - return !HasContainer(); - } - - bool HasContainer() const { - return !!Container; - } - - const TDataContainer* operator->() const { - return Container.get(); - } - - template - static std::vector MergeColumnIdxs(const std::vector>& sources) { + template + static std::vector MergeColumnIdxs(const std::vector& sources) { class TIterator { private: std::vector::const_iterator ItCurrent; @@ -119,6 +78,48 @@ class TContainerWithIndexes: public TOrderedColumnIndexesImpl { } }; +template +class TContainerWithIndexes: public TOrderedColumnIndexesImpl { +private: + using TBase = TOrderedColumnIndexesImpl; + YDB_ACCESSOR_DEF(std::shared_ptr, Container); + +public: + TContainerWithIndexes() = default; + + TContainerWithIndexes(const std::vector& columnIndexes, const std::shared_ptr& container) + : TBase(columnIndexes) + , Container(container) { + if (Container) { + Y_ABORT_UNLESS((ui32)Container->num_columns() == columnIndexes.size()); + } else { + Y_ABORT_UNLESS(!columnIndexes.size()); + } + } + + explicit TContainerWithIndexes(const std::shared_ptr& container) + : TBase(TSimpleValidator::CheckNotNull(container)->num_columns()) + , Container(container) { + } + + TContainerWithIndexes BuildWithAnotherContainer(const std::shared_ptr& container) const { + return TContainerWithIndexes(GetColumnIndexes(), container); + } + + bool operator!() const { + return !HasContainer(); + } + + bool HasContainer() const { + return !!Container; + } + + const TDataContainer* operator->() const { + return Container.get(); + } + +}; + class TColumnOperator { public: enum class EAbsentFieldPolicy { diff --git a/ydb/core/tx/columnshard/operations/slice_builder/pack_builder.cpp b/ydb/core/tx/columnshard/operations/slice_builder/pack_builder.cpp index c76b703731cc..e335268253a8 100644 --- a/ydb/core/tx/columnshard/operations/slice_builder/pack_builder.cpp +++ b/ydb/core/tx/columnshard/operations/slice_builder/pack_builder.cpp @@ -101,7 +101,7 @@ class TSliceToMerge { ui32 idx = 0; std::vector> containers; ui32 recordsCountSum = 0; - auto indexes = NArrow::TContainerWithIndexes::MergeColumnIdxs(Batches); + auto indexes = NArrow::TOrderedColumnIndexesImpl::MergeColumnIdxs(Batches); std::shared_ptr dataSchema; const auto& indexInfo = context.GetActualSchema()->GetIndexInfo(); for (auto&& i : Batches) {