You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "llama90 (via GitHub)" <gi...@apache.org> on 2024/05/07 15:01:14 UTC
[PR] GH-41558: Move and update fixed_width_test_util.h [arrow]
llama90 opened a new pull request, #41575:
URL: https://github.com/apache/arrow/pull/41575
<!--
Thanks for opening a pull request!
If this is your first pull request you can find detailed information on how
to contribute here:
* [New Contributor's Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
* [Contributing Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
If this is not a [minor PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose
Opening GitHub issues ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
Then could you also rename the pull request title in the following format?
GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
or
MINOR: [${COMPONENT}] ${SUMMARY}
In the case of PARQUET issues on JIRA the title also supports:
PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
-->
### Rationale for this change
Move the `fixed_width_test_util.h` and remove unused headers.
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
### What changes are included in this PR?
- Move the `fixed_width_test_util.h` to `arrow/testing`
- Remove unused headers
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
### Are these changes tested?
Yes
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
### Are there any user-facing changes?
No
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please uncomment the line below and explain which changes are breaking.
-->
<!-- **This PR includes breaking changes to public APIs.** -->
<!--
Please uncomment the line below (and provide explanation) if the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld). We use this to highlight fixes to issues that may affect users without their knowledge. For this reason, fixing bugs that cause errors don't count, since those are usually obvious.
-->
<!-- **This PR contains a "Critical Fix".** -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41558: [C++] Improve fixed_width_test_util.h [arrow]
Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #41575:
URL: https://github.com/apache/arrow/pull/41575#issuecomment-2118619912
After merging your PR, Conbench analyzed the 7 benchmarking runs that have been run so far on merge-commit 7aff9d572d57c3e29702db9b1511c00f04926007.
There was 1 benchmark result indicating a performance regression:
- Commit Run on `ursa-i9-9960x` at [2024-05-18 00:39:03Z](https://conbench.ursa.dev/compare/runs/1263cea74fd44ad7ac297adc5188ba81...bc0622dcf5ed4efbb55d79784e7a2706/)
- [`dataset-selectivity` (Python) with dataset=nyctaxi_multi_ipc_s3, selectivity=100%](https://conbench.ursa.dev/compare/benchmarks/06647dac59237f52800007651ff4b2f8...0664802b30817bcd8000e9a5e9da3974)
The [full Conbench report](https://github.com/apache/arrow/runs/25126392892) has more details. It also includes information about 2 possible false positives for unstable benchmarks that are known to sometimes produce them.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41558: [C++] Move and update fixed_width_test_util.h [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 commented on code in PR #41575:
URL: https://github.com/apache/arrow/pull/41575#discussion_r1593351811
##########
cpp/src/arrow/testing/fixed_width_test_util.h:
##########
@@ -17,16 +17,6 @@
#pragma once
-#include <cstddef>
-#include <cstdint>
-#include <memory>
-#include <vector>
-
-#include "arrow/array/builder_primitive.h"
-#include "arrow/builder.h"
-#include "arrow/type.h"
-#include "arrow/util/checked_cast.h"
-
Review Comment:
Ah, so I need to organize the code according to C++ conventions. I should include only the declarations in the .h file and put the implementations in the .cc file.
I will refer to the code you shared, organize it accordingly, and then upload it.
Thank you for your guidance.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41558: [C++] Improve fixed_width_test_util.h [arrow]
Posted by "felipecrv (via GitHub)" <gi...@apache.org>.
felipecrv commented on code in PR #41575:
URL: https://github.com/apache/arrow/pull/41575#discussion_r1604226688
##########
cpp/src/arrow/testing/fixed_width_test_util.cc:
##########
@@ -0,0 +1,176 @@
+// 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 "fixed_width_test_util.h"
+
+namespace arrow::util::internal {
+
+namespace {
+template <typename ArrowType>
+inline Status AppendNumeric(ArrayBuilder* builder, int64_t* next_value) {
+ using NumericBuilder = ::arrow::NumericBuilder<ArrowType>;
+ using value_type = typename NumericBuilder::value_type;
+ auto* numeric_builder = ::arrow::internal::checked_cast<NumericBuilder*>(builder);
+ auto cast_next_value =
+ static_cast<value_type>(*next_value % std::numeric_limits<value_type>::max());
+ RETURN_NOT_OK(numeric_builder->Append(cast_next_value));
+ *next_value += 1;
+ return Status::OK();
+}
+
+template Status AppendNumeric<Int8Type>(ArrayBuilder* builder, int64_t* next_value);
+template Status AppendNumeric<Int16Type>(ArrayBuilder* builder, int64_t* next_value);
+template Status AppendNumeric<Int32Type>(ArrayBuilder* builder, int64_t* next_value);
+template Status AppendNumeric<Int64Type>(ArrayBuilder* builder, int64_t* next_value);
Review Comment:
You don't need these (in this context) because since this template is in an anon namespace the compiler will only instantiate the 4 instances that are referred to in this compilation unit.
##########
cpp/src/arrow/testing/fixed_width_test_util.h:
##########
@@ -0,0 +1,72 @@
+// 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.
+
+#pragma once
+
+#include <vector>
+
+#include "arrow/builder.h"
+#include "arrow/testing/visibility.h"
Review Comment:
We should try to "include what you use" [1] as much as possible. Even when headers that we need are already included by other headers.
- `<memory>`
- `<functional>`
- `<cstdint>`
- `"arrow/type.h"` for `DataType` (complete type is needed for the pointers and vector declarations)
- `"arrow/type_fwd.h"` forward-declares `ArrayBuilder` (which we don't need to be a complete type in the header because we only pointers/references to it in this header)
With these included, you should be able to remove `"arrow/builder.h"` which is a very expensive header.
[1] https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md
##########
cpp/src/arrow/testing/fixed_width_test_util.cc:
##########
@@ -0,0 +1,176 @@
+// 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 "fixed_width_test_util.h"
Review Comment:
With the removal of include bloat in the header, you should also add all the includes for things referred from this file:
- `"arrow/array/builder_primitive.h"` for `NumericBuilder` and `ArrowBuilder`
- `"arrow/array/builder_base.h"` for `MakeBuilder` [1]
- `<cstdint>`
- `<limits>`
- `<vector>`
- `<functional>`
- `"arrow/type.h"`
[1] my header had an include to `arrow/builder.h`, but that was unnecessary now that I thought more about it
##########
cpp/src/arrow/testing/fixed_width_test_util.cc:
##########
@@ -0,0 +1,176 @@
+// 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 "fixed_width_test_util.h"
Review Comment:
The linter is complaining about this line because includes should be fully qualified based on the `cpp/src/` root, so this should be `"arrow/testing/fixed_width_test_util.h"`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41558: [C++] Improve fixed_width_test_util.h [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 commented on PR #41575:
URL: https://github.com/apache/arrow/pull/41575#issuecomment-2117660449
@felipecrv I applied your suggestions
Thank you for review :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41558: [C++] Improve fixed_width_test_util.h [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 commented on PR #41575:
URL: https://github.com/apache/arrow/pull/41575#issuecomment-2114822303
I think I applied everything you suggested:
- Converted the template function to a regular function.
- Modified to not include relative paths in the Makefile (this was a problem due to a missing macro as `ARROW_TESTING_EXPORT`).
Additionally, I want to express my gratitude for your patience and thorough review. It has been instrumental in completing this PR.
Thank you! cc @felipecrv
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41558: [C++] Improve fixed_width_test_util.h [arrow]
Posted by "felipecrv (via GitHub)" <gi...@apache.org>.
felipecrv merged PR #41575:
URL: https://github.com/apache/arrow/pull/41575
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41558: Move and update fixed_width_test_util.h [arrow]
Posted by "felipecrv (via GitHub)" <gi...@apache.org>.
felipecrv commented on code in PR #41575:
URL: https://github.com/apache/arrow/pull/41575#discussion_r1592919261
##########
cpp/src/arrow/testing/fixed_width_test_util.h:
##########
@@ -17,16 +17,6 @@
#pragma once
-#include <cstddef>
-#include <cstdint>
-#include <memory>
-#include <vector>
-
-#include "arrow/array/builder_primitive.h"
-#include "arrow/builder.h"
-#include "arrow/type.h"
-#include "arrow/util/checked_cast.h"
-
Review Comment:
I meant reducing the code in the header. We should keep the necessary includes.
The class should only declare the public function members here and all the private members and template code can be defined in the `.cc` file (to be created) outside of the class.
See how `chunk_resolver.h/cc` does it reducing the bloat in the header: https://github.com/apache/arrow/blob/51689a040cbe3dee8702cd899a33fa62e0616bf1/cpp/src/arrow/chunk_resolver.cc#L44-L45
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41558: Move and update fixed_width_test_util.h [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 commented on PR #41575:
URL: https://github.com/apache/arrow/pull/41575#issuecomment-2098646688
@felipecrv Hello.
Is this what you were thinking?
I would appreciate it if you could review it when you have time. Thank you.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41558: [C++] Improve fixed_width_test_util.h [arrow]
Posted by "felipecrv (via GitHub)" <gi...@apache.org>.
felipecrv commented on code in PR #41575:
URL: https://github.com/apache/arrow/pull/41575#discussion_r1600636364
##########
cpp/src/arrow/testing/fixed_width_test_util.h:
##########
@@ -120,84 +170,6 @@ class NestedListGenerator {
}
return nested_builder->Finish();
}
-
Review Comment:
You should have the definition of `NestedListArray` in the `.cc` as well.
##########
cpp/src/arrow/testing/fixed_width_test_util.h:
##########
@@ -35,24 +29,80 @@ class NestedListGenerator {
///
/// \return `fixed_size_list(fixed_size_list(..., sizes[1]), sizes[0])`
static std::shared_ptr<DataType> NestedFSLType(
- const std::shared_ptr<DataType>& inner_type, const std::vector<int>& sizes) {
- auto type = inner_type;
- for (auto it = sizes.rbegin(); it != sizes.rend(); it++) {
- type = fixed_size_list(std::move(type), *it);
- }
- return type;
- }
+ const std::shared_ptr<DataType>& inner_type, const std::vector<int>& sizes);
/// \brief Create a nested FixedListType.
Review Comment:
You should move these template functions to an anonymous namespace in the `.cc` file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41558: [C++] Improve fixed_width_test_util.h [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #41575:
URL: https://github.com/apache/arrow/pull/41575#issuecomment-2106211948
:warning: GitHub issue #41558 **has been automatically assigned in GitHub** to PR creator.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41558: [C++] Improve fixed_width_test_util.h [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 commented on PR #41575:
URL: https://github.com/apache/arrow/pull/41575#issuecomment-2112355452
@felipecrv Hello, and thank you for your review.
I have applied the changes as advised, but I am a bit unsure about one aspect, particularly because I am not very familiar with template functions.
Should the `VisitAllNestedListConfigurations` template function also be moved to an anonymous namespace? It is directly called from the test function (`vector_selection_test.cc`), so I have kept it as it currently is.
Additionally, I made modifications to the `Makefile` to accommodate the Windows CI process. Could you please confirm if this approach is correct?
I would greatly appreciate your advice on these matters.
Thank you!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41558: [C++] Move and update fixed_width_test_util.h [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #41575:
URL: https://github.com/apache/arrow/pull/41575#issuecomment-2099282362
:warning: GitHub issue #41558 **has been automatically assigned in GitHub** to PR creator.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41558: Move and update fixed_width_test_util.h [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #41575:
URL: https://github.com/apache/arrow/pull/41575#issuecomment-2098628299
:warning: GitHub issue #41558 **has been automatically assigned in GitHub** to PR creator.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41558: [C++] Improve fixed_width_test_util.h [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #41575:
URL: https://github.com/apache/arrow/pull/41575#issuecomment-2106216656
:warning: GitHub issue #41558 **has been automatically assigned in GitHub** to PR creator.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41558: [C++] Improve fixed_width_test_util.h [arrow]
Posted by "felipecrv (via GitHub)" <gi...@apache.org>.
felipecrv commented on PR #41575:
URL: https://github.com/apache/arrow/pull/41575#issuecomment-2112704249
> Should the `VisitAllNestedListConfigurations` template function also be moved to an anonymous namespace? It is directly called from the test function (`vector_selection_test.cc`), so I have kept it as it currently is.
Sorry, I missed that it was called from others. We can make it a non-template by using `std::function<...>` instead of inlining the lambda expression. This is not performance-critical code, so it's not gonna be a problem:
```diff
- /// \tparam Visit a function type with signature
- /// void(const std::shared_ptr<DataType>& inner_type,
- /// const std::vector<int>& list_sizes)
template <class Visit>
static void VisitAllNestedListConfigurations(
- const std::vector<std::shared_ptr<DataType>>& inner_value_types, Visit&& visit,
+ const std::vector<std::shared_ptr<DataType>>& inner_value_types,
+ const std::function<void(const std::shared_ptr<DataType>& inner_type,
+ const std::vector<int>& list_sizes)> &visit,
int max_depth = 3, int max_power_of_2_size = 32) {
```
> Additionally, I made modifications to the `Makefile` to accommodate the Windows CI process. Could you please confirm if this approach is correct?
We avoid relative paths in CMakeLists.txt because that gets very confusing very quickly. You should list this new `.cc` file in
https://github.com/apache/arrow/blob/2ca9ad2861387a08244427eb1a2457c32a8ed31a/cpp/src/arrow/CMakeLists.txt#L637-L643
The trick to find where to list new `.cc` files is to grep for `.cc` files in the same directory as yours. Things could be more complicated than that, but it usually works.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org