forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apacheGH-40997: [C++] Get null_bit_id according to are_cols_in_encodi…
…ng_order in NullUpdateColumnToRow_avx2 (apache#40998) ### Rationale for this change Recently, we find that the compare internal's avx2 function NullUpdateColumnToRowImp_avx2 lost the are_cols_in_encoding_order check when get null_bit_id. It may cause grouper's compare result wrong(are_cols_in_encoding_order = true in grouper). ### What changes are included in this PR? Get `null_bit_id` according to `are_cols_in_encoding_order` in NullUpdateColumnToRow_avx2. ### Are there any user-facing changes? No Co-authored-by laotan332 <qinpengxiang@ outlook.com> Co-authored-by ZhangHuiGui <2689496754@ qq.com> * GitHub Issue: apache#40997 Lead-authored-by: ZhangHuiGui <[email protected]> Co-authored-by: ZhangHuiGui <[email protected]> Signed-off-by: Antoine Pitrou <[email protected]>
- Loading branch information
Showing
6 changed files
with
116 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
#include <numeric> | ||
|
||
#include "arrow/compute/exec.h" | ||
#include "arrow/compute/row/grouper.h" | ||
#include "arrow/testing/gtest_util.h" | ||
#include "arrow/testing/random.h" | ||
|
||
namespace arrow { | ||
namespace compute { | ||
|
||
// Specialized case for GH-40997 | ||
TEST(Grouper, ResortedColumnsWithLargeNullRows) { | ||
const uint64_t num_rows = 1024; | ||
|
||
// construct random array with plenty of null values | ||
const int32_t kSeed = 42; | ||
const int32_t min = 0; | ||
const int32_t max = 100; | ||
const double null_probability = 0.3; | ||
const double true_probability = 0.5; | ||
auto rng = random::RandomArrayGenerator(kSeed); | ||
auto b_arr = rng.Boolean(num_rows, true_probability, null_probability); | ||
auto i32_arr = rng.Int32(num_rows, min, max, null_probability); | ||
auto i64_arr = rng.Int64(num_rows, min, max * 10, null_probability); | ||
|
||
// construct batches with columns which will be resorted in the grouper make | ||
std::vector<ExecBatch> exec_batches = {ExecBatch({i64_arr, i32_arr, b_arr}, num_rows), | ||
ExecBatch({i32_arr, i64_arr, b_arr}, num_rows), | ||
ExecBatch({i64_arr, b_arr, i32_arr}, num_rows), | ||
ExecBatch({i32_arr, b_arr, i64_arr}, num_rows), | ||
ExecBatch({b_arr, i32_arr, i64_arr}, num_rows), | ||
ExecBatch({b_arr, i64_arr, i32_arr}, num_rows)}; | ||
|
||
const int num_batches = static_cast<int>(exec_batches.size()); | ||
std::vector<uint32_t> group_num_vec; | ||
group_num_vec.reserve(num_batches); | ||
|
||
for (const auto& exec_batch : exec_batches) { | ||
ExecSpan span(exec_batch); | ||
ASSERT_OK_AND_ASSIGN(auto grouper, Grouper::Make(span.GetTypes())); | ||
ASSERT_OK_AND_ASSIGN(Datum group_ids, grouper->Consume(span)); | ||
group_num_vec.emplace_back(grouper->num_groups()); | ||
} | ||
|
||
for (int i = 1; i < num_batches; i++) { | ||
ASSERT_EQ(group_num_vec[i - 1], group_num_vec[i]); | ||
} | ||
} | ||
|
||
} // namespace compute | ||
} // namespace arrow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters