Skip to content

Commit

Permalink
additional validation and correct case with empty array (ydb-platform…
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmorozov333 committed Apr 16, 2024
1 parent 48e0cbf commit 15d6396
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
2 changes: 1 addition & 1 deletion ydb/core/formats/arrow/arrow_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
31 changes: 11 additions & 20 deletions ydb/core/formats/arrow/permutations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,24 @@
namespace NKikimr::NArrow {

std::shared_ptr<arrow::UInt64Array> 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<arrow::UInt64Array> out;
if (!builder.Finish(&out).ok()) {
return {};
}
TStatusValidator::Validate(builder.Finish(&out));
return out;
}

Expand Down Expand Up @@ -287,6 +277,7 @@ std::shared_ptr<arrow::UInt64Array> TShardingSplitIndex::BuildPermutation() cons
}

std::shared_ptr<arrow::RecordBatch> ReverseRecords(const std::shared_ptr<arrow::RecordBatch>& batch) {
AFL_VERIFY(batch);
auto permutation = NArrow::MakePermutation(batch->num_rows(), true);
return NArrow::TStatusValidator::GetValid(arrow::compute::Take(batch, permutation)).record_batch();
}
Expand Down

0 comments on commit 15d6396

Please sign in to comment.