-
Notifications
You must be signed in to change notification settings - Fork 4.2k
GH-50508: [C++] Support scalar values in AppendScalars #50584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1de420f
41745a9
cc8e4fd
64df561
304478c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -366,6 +366,59 @@ TEST_P(TestRunEndEncodedArray, Builder) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TEST_P(TestRunEndEncodedArray, BuilderAppendScalarsPrimitiveScalar) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto value_type = float32(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto ree_type = run_end_encoded(run_end_type, value_type); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK_AND_ASSIGN(std::shared_ptr<ArrayBuilder> builder, MakeBuilder(ree_type)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK_AND_ASSIGN(auto v1, MakeScalar(float32(), 1.0f)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK_AND_ASSIGN(auto v2, MakeScalar(float32(), 1.0f)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK_AND_ASSIGN(auto v3, MakeScalar(float32(), 2.0f)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK_AND_ASSIGN(auto v4, MakeScalar(float32(), 2.0f)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK_AND_ASSIGN(auto v5, MakeScalar(float32(), 3.0f)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ScalarVector scalars = {v1, v2, v3, v4, v5}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK(builder->AppendScalars(scalars)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_EQ(builder->length(), 5); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK_AND_ASSIGN(auto array, builder->Finish()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's also validate the result:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK(array->ValidateFull()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto ree_array = std::dynamic_pointer_cast<RunEndEncodedArray>(array); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_NE(ree_array, NULLPTR); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto expected_run_ends = ArrayFromJSON(run_end_type, "[2,4,5]"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto expected_values = ArrayFromJSON(float32(), "[1,2,3]"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_ARRAYS_EQUAL(*expected_run_ends, *ree_array->run_ends()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_ARRAYS_EQUAL(*expected_values, *ree_array->values()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+381
to
+393
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: remove superfluous empty lines
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TEST_P(TestRunEndEncodedArray, BuilderAppendScalarsRunEndEncodedScalar) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto value_type = float32(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto ree_type = run_end_encoded(run_end_type, value_type); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK_AND_ASSIGN(std::shared_ptr<ArrayBuilder> builder, MakeBuilder(ree_type)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK_AND_ASSIGN(auto s1, MakeScalar(ree_type, *MakeScalar(float32(), 1.0f))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK_AND_ASSIGN(auto s2, MakeScalar(ree_type, *MakeScalar(float32(), 1.0f))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK_AND_ASSIGN(auto s3, MakeScalar(ree_type, *MakeScalar(float32(), 2.0f))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK_AND_ASSIGN(auto s4, MakeScalar(ree_type, *MakeScalar(float32(), 2.0f))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK_AND_ASSIGN(auto s5, MakeScalar(ree_type, *MakeScalar(float32(), 3.0f))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ScalarVector scalars = {s1, s2, s3, s4, s5}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK(builder->AppendScalars(scalars)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_EQ(builder->length(), 5); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK_AND_ASSIGN(auto array, builder->Finish()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_OK(array->ValidateFull()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto ree_array = std::dynamic_pointer_cast<RunEndEncodedArray>(array); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_NE(ree_array, NULLPTR); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto expected_run_ends = ArrayFromJSON(run_end_type, "[2,4,5]"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto expected_values = ArrayFromJSON(float32(), "[1,2,3]"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_ARRAYS_EQUAL(*expected_run_ends, *ree_array->run_ends()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ASSERT_ARRAYS_EQUAL(*expected_values, *ree_array->values()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+408
to
+420
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: remove superfluous empty lines
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Done. I addressed the review comments and pushed the changes. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TEST_P(TestRunEndEncodedArray, BuilderReuseAfterFinish) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // GH-45532: RunEndEncodedBuilder should clear dimensions after a Finish() call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to add an empty line after each individual statement, can we compact this a bit and only keep empty lines to distinguish between logically different sequences?