From 15d639618ac8a513606c3be6798cd4801ef1ee7a Mon Sep 17 00:00:00 2001 From: ivanmorozov333 <111685085+ivanmorozov333@users.noreply.github.com> Date: Tue, 6 Feb 2024 19:03:38 +0300 Subject: [PATCH] additional validation and correct case with empty array (#1627) --- ydb/core/formats/arrow/arrow_filter.cpp | 2 +- ydb/core/formats/arrow/permutations.cpp | 31 +++++++++---------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/ydb/core/formats/arrow/arrow_filter.cpp b/ydb/core/formats/arrow/arrow_filter.cpp index bdfb8d0355f1..b667d4006fd4 100644 --- a/ydb/core/formats/arrow/arrow_filter.cpp +++ b/ydb/core/formats/arrow/arrow_filter.cpp @@ -569,7 +569,7 @@ TColumnFilter TColumnFilter::CombineSequentialAnd(const TColumnFilter& extFilter ++itExt; } } - Y_ABORT_UNLESS(itSelf == Filter.end() && itExt == extFilter.Filter.cend()); + AFL_VERIFY(itSelf == Filter.end() && itExt == extFilter.Filter.cend()); TColumnFilter result = TColumnFilter::BuildAllowFilter(); std::swap(resultFilter, result.Filter); std::swap(curCurrent, result.LastValue); diff --git a/ydb/core/formats/arrow/permutations.cpp b/ydb/core/formats/arrow/permutations.cpp index 6f38f9fb0050..f1a68600bb70 100644 --- a/ydb/core/formats/arrow/permutations.cpp +++ b/ydb/core/formats/arrow/permutations.cpp @@ -15,34 +15,24 @@ namespace NKikimr::NArrow { std::shared_ptr MakePermutation(const int size, const bool reverse) { - if (size < 1) { - return {}; - } - arrow::UInt64Builder builder; - if (!builder.Reserve(size).ok()) { - return {}; - } + TStatusValidator::Validate(builder.Reserve(size)); - if (reverse) { - ui64 value = size - 1; - for (i64 i = 0; i < size; ++i, --value) { - if (!builder.Append(value).ok()) { - return {}; + if (size) { + if (reverse) { + ui64 value = size - 1; + for (i64 i = 0; i < size; ++i, --value) { + TStatusValidator::Validate(builder.Append(value)); } - } - } else { - for (i64 i = 0; i < size; ++i) { - if (!builder.Append(i).ok()) { - return {}; + } else { + for (i64 i = 0; i < size; ++i) { + TStatusValidator::Validate(builder.Append(i)); } } } std::shared_ptr out; - if (!builder.Finish(&out).ok()) { - return {}; - } + TStatusValidator::Validate(builder.Finish(&out)); return out; } @@ -287,6 +277,7 @@ std::shared_ptr TShardingSplitIndex::BuildPermutation() cons } std::shared_ptr ReverseRecords(const std::shared_ptr& batch) { + AFL_VERIFY(batch); auto permutation = NArrow::MakePermutation(batch->num_rows(), true); return NArrow::TStatusValidator::GetValid(arrow::compute::Take(batch, permutation)).record_batch(); }