Skip to content

Commit 54b0c04

Browse files
author
nullccxsy
committed
fix comments
1 parent 7223081 commit 54b0c04

File tree

4 files changed

+23
-26
lines changed

4 files changed

+23
-26
lines changed

src/iceberg/schema.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class IdToFieldVisitor {
4545
class NameToIdVisitor {
4646
public:
4747
explicit NameToIdVisitor(
48-
std::unordered_map<std::string, int32_t, string_hash, std::equal_to<>>& name_to_id,
48+
std::unordered_map<std::string, int32_t, StringHash, std::equal_to<>>& name_to_id,
4949
bool case_sensitive = true,
5050
std::function<std::string(std::string_view)> quoting_func = {});
5151
Status Visit(const ListType& type, const std::string& path,
@@ -64,9 +64,8 @@ class NameToIdVisitor {
6464

6565
private:
6666
bool case_sensitive_;
67-
std::unordered_map<std::string, int32_t, string_hash, std::equal_to<>>& name_to_id_;
68-
std::unordered_map<std::string, int32_t, string_hash, std::equal_to<>>
69-
short_name_to_id_;
67+
std::unordered_map<std::string, int32_t, StringHash, std::equal_to<>>& name_to_id_;
68+
std::unordered_map<std::string, int32_t, StringHash, std::equal_to<>> short_name_to_id_;
7069
std::function<std::string(std::string_view)> quoting_func_;
7170
};
7271

@@ -150,7 +149,7 @@ IdToFieldVisitor::IdToFieldVisitor(
150149
Status IdToFieldVisitor::Visit(const PrimitiveType& type) { return {}; }
151150

152151
Status IdToFieldVisitor::Visit(const NestedType& type) {
153-
const auto& nested = iceberg::internal::checked_cast<const NestedType&>(type);
152+
const auto& nested = internal::checked_cast<const NestedType&>(type);
154153
const auto& fields = nested.fields();
155154
for (const auto& field : fields) {
156155
auto it = id_to_field_.try_emplace(field.field_id(), std::cref(field));
@@ -163,7 +162,7 @@ Status IdToFieldVisitor::Visit(const NestedType& type) {
163162
}
164163

165164
NameToIdVisitor::NameToIdVisitor(
166-
std::unordered_map<std::string, int32_t, string_hash, std::equal_to<>>& name_to_id,
165+
std::unordered_map<std::string, int32_t, StringHash, std::equal_to<>>& name_to_id,
167166
bool case_sensitive, std::function<std::string(std::string_view)> quoting_func)
168167
: name_to_id_(name_to_id),
169168
case_sensitive_(case_sensitive),

src/iceberg/schema.h

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,28 +74,26 @@ class ICEBERG_EXPORT Schema : public StructType {
7474

7575
friend bool operator==(const Schema& lhs, const Schema& rhs) { return lhs.Equals(rhs); }
7676

77-
private:
78-
/// Mapping from field id to field.
79-
mutable std::unordered_map<int32_t, std::reference_wrapper<const SchemaField>>
80-
id_to_field_;
81-
/// Mapping from field name to field id.
82-
mutable std::unordered_map<std::string, int32_t, string_hash, std::equal_to<>>
83-
name_to_id_;
84-
/// Mapping from lowercased field name to field id
85-
mutable std::unordered_map<std::string, int32_t, string_hash, std::equal_to<>>
86-
lowercase_name_to_id_;
87-
8877
private:
8978
/// \brief Compare two schemas for equality.
9079
[[nodiscard]] bool Equals(const Schema& other) const;
9180

92-
const std::optional<int32_t> schema_id_;
93-
9481
// TODO(nullccxsy): Address potential concurrency issues in lazy initialization (e.g.,
9582
// use std::call_once)
9683
Status InitIdToFieldMap() const;
9784
Status InitNameToIdMap() const;
9885
Status InitLowerCaseNameToIdMap() const;
86+
87+
const std::optional<int32_t> schema_id_;
88+
/// Mapping from field id to field.
89+
mutable std::unordered_map<int32_t, std::reference_wrapper<const SchemaField>>
90+
id_to_field_;
91+
/// Mapping from field name to field id.
92+
mutable std::unordered_map<std::string, int32_t, StringHash, std::equal_to<>>
93+
name_to_id_;
94+
/// Mapping from lowercased field name to field id
95+
mutable std::unordered_map<std::string, int32_t, StringHash, std::equal_to<>>
96+
lowercase_name_to_id_;
9997
};
10098

10199
} // namespace iceberg

src/iceberg/util/macros.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020
#pragma once
2121

22-
#define ICEBERG_RETURN_UNEXPECTED(result) \
23-
do { \
24-
auto&& iceberg_temp_result = (result); \
25-
if (!iceberg_temp_result) [[unlikely]] { \
26-
return std::unexpected<Error>(iceberg_temp_result.error()); \
27-
} \
22+
#define ICEBERG_RETURN_UNEXPECTED(result) \
23+
do { \
24+
auto&& result_name = (result); \
25+
if (!result_name) [[unlikely]] { \
26+
return std::unexpected<Error>(result_name.error()); \
27+
} \
2828
} while (false);
2929

3030
#define ICEBERG_ASSIGN_OR_RAISE_IMPL(result_name, lhs, rexpr) \

src/iceberg/util/string_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ICEBERG_EXPORT StringUtils {
5050
///
5151
/// Enables std::unordered_map to directly accept std::string_view lookup keys
5252
/// without creating temporary std::string objects, using C++20's transparent lookup.
53-
struct ICEBERG_EXPORT string_hash {
53+
struct ICEBERG_EXPORT StringHash {
5454
using hash_type = std::hash<std::string_view>;
5555
using is_transparent = void;
5656

0 commit comments

Comments
 (0)