Skip to content

Commit

Permalink
type -> value_type
Browse files Browse the repository at this point in the history
  • Loading branch information
zanmato1984 committed Jan 15, 2025
1 parent b82ad94 commit eaa9a3c
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions cpp/src/arrow/compute/kernels/vector_swizzle_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,12 @@ void DoTestScatter(const std::shared_ptr<Array>& values,
DoTestScatterForIndicesTypes(kSignedIntegerTypes, values, indices, max_index, expected);
}

void TestScatter(const std::shared_ptr<DataType>& type, const std::string& values_str,
const std::string& indices_str, int64_t max_index,
const std::string& expected_str) {
auto values = ArrayFromJSON(type, values_str);
void TestScatter(const std::shared_ptr<DataType>& value_type,
const std::string& values_str, const std::string& indices_str,
int64_t max_index, const std::string& expected_str) {
auto values = ArrayFromJSON(value_type, values_str);
auto indices = ArrayFromJSON(int8(), indices_str);
auto expected = ArrayFromJSON(type, expected_str);
auto expected = ArrayFromJSON(value_type, expected_str);
DoTestScatter(values, indices, max_index, expected);
}

Expand Down Expand Up @@ -639,141 +639,141 @@ TEST(Scatter, Boolean) {
}

TEST(Scatter, Numeric) {
for (const auto& type : kSignedIntegerTypes) {
ARROW_SCOPED_TRACE(type->ToString());
for (const auto& value_type : kSignedIntegerTypes) {
ARROW_SCOPED_TRACE(value_type->ToString());
{
ARROW_SCOPED_TRACE("Basic");
auto values = "[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]";
auto indices = "[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]";
int64_t max_index = 9;
auto expected = "[19, 18, 17, 16, 15, 14, 13, 12, 11, 10]";
TestScatter(type, values, indices, max_index, expected);
TestScatter(value_type, values, indices, max_index, expected);
}
{
ARROW_SCOPED_TRACE("Values with nulls");
auto values = "[null, 11, null, 13, null, 15, null, 17, null, 19]";
auto indices = "[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]";
int64_t max_index = 9;
auto expected = "[19, null, 17, null, 15, null, 13, null, 11, null]";
TestScatter(type, values, indices, max_index, expected);
TestScatter(value_type, values, indices, max_index, expected);
}
{
ARROW_SCOPED_TRACE("Indices with nulls");
auto values = "[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]";
auto indices = "[9, null, 7, null, 5, null, 3, null, 1, null]";
int64_t max_index = 9;
auto expected = "[null, 18, null, 16, null, 14, null, 12, null, 10]";
TestScatter(type, values, indices, max_index, expected);
TestScatter(value_type, values, indices, max_index, expected);
}
{
ARROW_SCOPED_TRACE("Output greater than input");
auto values = "[0, 0, 0, 1, 1, 1]";
auto indices = "[0, 3, 6, 1, 4, 7]";
int64_t max_index = 8;
auto expected = "[0, 1, null, 0, 1, null, 0, 1, null]";
TestScatter(type, values, indices, max_index, expected);
TestScatter(value_type, values, indices, max_index, expected);
}
{
ARROW_SCOPED_TRACE("Values all null");
auto values = "[null, null]";
auto indices = "[0, 1]";
int64_t max_index = 1;
auto expected = "[null, null]";
TestScatter(type, values, indices, max_index, expected);
TestScatter(value_type, values, indices, max_index, expected);
}
{
ARROW_SCOPED_TRACE("Indices all null");
auto values = "[0, 1]";
auto indices = "[null, null]";
int64_t max_index = 1;
auto expected = "[null, null]";
TestScatter(type, values, indices, max_index, expected);
TestScatter(value_type, values, indices, max_index, expected);
}
{
ARROW_SCOPED_TRACE("Empty input output null");
auto values = "[]";
auto indices = "[]";
int64_t max_index = 1;
auto expected = "[null, null]";
TestScatter(type, values, indices, max_index, expected);
TestScatter(value_type, values, indices, max_index, expected);
}
{
ARROW_SCOPED_TRACE("Indices duplicated indices");
auto values = "[1, 0, null, null]";
auto indices = "[0, 1, 0, 1]";
int64_t max_index = 3;
auto expected = "[null, null, null, null]";
TestScatter(type, values, indices, max_index, expected);
TestScatter(value_type, values, indices, max_index, expected);
}
}
}

TEST(Scatter, Binary) {
for (const auto& type : kBinaryTypes) {
ARROW_SCOPED_TRACE(type->ToString());
for (const auto& value_type : kBinaryTypes) {
ARROW_SCOPED_TRACE(value_type->ToString());
{
ARROW_SCOPED_TRACE("Basic");
auto values = R"(["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"])";
auto indices = "[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]";
int64_t max_index = 9;
auto expected = R"(["j", "i", "h", "g", "f", "e", "d", "c", "b", "a"])";
TestScatter(type, values, indices, max_index, expected);
TestScatter(value_type, values, indices, max_index, expected);
}
{
ARROW_SCOPED_TRACE("Values with nulls");
auto values = R"([null, "b", null, "d", null, "f", null, "h", null, "j"])";
auto indices = "[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]";
int64_t max_index = 9;
auto expected = R"(["j", null, "h", null, "f", null, "d", null, "b", null])";
TestScatter(type, values, indices, max_index, expected);
TestScatter(value_type, values, indices, max_index, expected);
}
{
ARROW_SCOPED_TRACE("Indices with nulls");
auto values = R"(["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"])";
auto indices = "[9, null, 7, null, 5, null, 3, null, 1, null]";
int64_t max_index = 9;
auto expected = R"([null, "i", null, "g", null, "e", null, "c", null, "a"])";
TestScatter(type, values, indices, max_index, expected);
TestScatter(value_type, values, indices, max_index, expected);
}
{
ARROW_SCOPED_TRACE("Output greater than input");
auto values = R"(["a", "a", "a", "b", "b", "b"])";
auto indices = "[0, 3, 6, 1, 4, 7]";
int64_t max_index = 8;
auto expected = R"(["a", "b", null, "a", "b", null, "a", "b", null])";
TestScatter(type, values, indices, max_index, expected);
TestScatter(value_type, values, indices, max_index, expected);
}
{
ARROW_SCOPED_TRACE("Values all null");
auto values = "[null, null]";
auto indices = "[0, 1]";
int64_t max_index = 1;
auto expected = "[null, null]";
TestScatter(type, values, indices, max_index, expected);
TestScatter(value_type, values, indices, max_index, expected);
}
{
ARROW_SCOPED_TRACE("Indices all null");
auto values = R"(["a", "b"])";
auto indices = "[null, null]";
int64_t max_index = 1;
auto expected = "[null, null]";
TestScatter(type, values, indices, max_index, expected);
TestScatter(value_type, values, indices, max_index, expected);
}
{
ARROW_SCOPED_TRACE("Empty input output null");
auto values = "[]";
auto indices = "[]";
int64_t max_index = 1;
auto expected = "[null, null]";
TestScatter(type, values, indices, max_index, expected);
TestScatter(value_type, values, indices, max_index, expected);
}
{
ARROW_SCOPED_TRACE("Indices duplicated indices");
auto values = R"(["a", "b", null, null])";
auto indices = "[0, 1, 0, 1]";
int64_t max_index = 3;
auto expected = "[null, null, null, null]";
TestScatter(type, values, indices, max_index, expected);
TestScatter(value_type, values, indices, max_index, expected);
}
}
}
Expand Down

0 comments on commit eaa9a3c

Please sign in to comment.