You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ap...@apache.org on 2023/06/22 10:42:28 UTC
[arrow] branch main updated: GH-36214: [C++] Specify `FieldPath::Hash` as template parameter where possible (#36222)
This is an automated email from the ASF dual-hosted git repository.
apitrou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new c875da82e0 GH-36214: [C++] Specify `FieldPath::Hash` as template parameter where possible (#36222)
c875da82e0 is described below
commit c875da82e0531303e335af02f5aee097f23c7d55
Author: Ben Harkins <60...@users.noreply.github.com>
AuthorDate: Thu Jun 22 06:42:21 2023 -0400
GH-36214: [C++] Specify `FieldPath::Hash` as template parameter where possible (#36222)
### Rationale for this change
Internal specializations of `std::hash<FieldPath>` have caused multiple-definition errors with unity builds.
### What changes are included in this PR?
To avoid exposing a global specialization of `std::hash` (which must be declared in the `std` namespace), this specifies the `FieldPath::Hash` helper as a template parameter to hashable containers instead.
### Are these changes tested?
Yes (covered by existing tests)
### Are there any user-facing changes?
No
* Closes: #36214
Authored-by: benibus <bp...@gmx.com>
Signed-off-by: Antoine Pitrou <an...@python.org>
---
cpp/src/arrow/compute/kernels/vector_sort.cc | 5 +----
cpp/src/arrow/ipc/dictionary.cc | 9 +--------
2 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/cpp/src/arrow/compute/kernels/vector_sort.cc b/cpp/src/arrow/compute/kernels/vector_sort.cc
index b58244ad6e..8ddcbb9905 100644
--- a/cpp/src/arrow/compute/kernels/vector_sort.cc
+++ b/cpp/src/arrow/compute/kernels/vector_sort.cc
@@ -20,9 +20,6 @@
#include "arrow/compute/kernels/vector_sort_internal.h"
#include "arrow/compute/registry.h"
-template <>
-struct std::hash<arrow::FieldPath> : public arrow::FieldPath::Hash {};
-
namespace arrow {
using internal::checked_cast;
@@ -1095,7 +1092,7 @@ struct SortFieldPopulator {
}
std::vector<SortField> sort_fields_;
- std::unordered_set<FieldPath> seen_;
+ std::unordered_set<FieldPath, FieldPath::Hash> seen_;
std::vector<int> tmp_indices_;
};
diff --git a/cpp/src/arrow/ipc/dictionary.cc b/cpp/src/arrow/ipc/dictionary.cc
index 82fec31fda..4e14b3350b 100644
--- a/cpp/src/arrow/ipc/dictionary.cc
+++ b/cpp/src/arrow/ipc/dictionary.cc
@@ -35,13 +35,6 @@
#include "arrow/util/checked_cast.h"
#include "arrow/util/logging.h"
-namespace std {
-template <>
-struct hash<arrow::FieldPath> {
- size_t operator()(const arrow::FieldPath& path) const { return path.hash(); }
-};
-} // namespace std
-
namespace arrow {
using internal::checked_cast;
@@ -54,7 +47,7 @@ using internal::FieldPosition;
// DictionaryFieldMapper implementation
struct DictionaryFieldMapper::Impl {
- using FieldPathMap = std::unordered_map<FieldPath, int64_t>;
+ using FieldPathMap = std::unordered_map<FieldPath, int64_t, FieldPath::Hash>;
FieldPathMap field_path_to_id;