Skip to content

Commit f5ff4c2

Browse files
author
xiao.dong
committed
fix comments
1 parent 6244509 commit f5ff4c2

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

src/iceberg/avro/avro_register.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,18 @@
1919

2020
#include "avro_register.h"
2121

22+
#include "iceberg/avro/avro_schema_util_internal.h"
23+
2224
namespace iceberg::avro {
2325

2426
void RegisterLogicalTypes() {
25-
::avro::CustomLogicalTypeRegistry::instance().registerType(
26-
"map", [](const std::string&) { return std::make_shared<MapLogicalType>(); });
27+
static std::once_flag flag{};
28+
std::call_once(flag, []() {
29+
// Register the map logical type with the avro custom logical type registry.
30+
// See https://github.com/apache/avro/pull/3326 for details.
31+
::avro::CustomLogicalTypeRegistry::instance().registerType(
32+
"map", [](const std::string&) { return std::make_shared<MapLogicalType>(); });
33+
});
2734
}
2835

2936
} // namespace iceberg::avro

src/iceberg/avro/avro_register.h

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

2020
#pragma once
2121

22-
#include <avro/LogicalType.hh>
22+
#include "iceberg/iceberg_bundle_export.h"
2323

2424
namespace iceberg::avro {
2525

26-
struct MapLogicalType : public ::avro::CustomLogicalType {
27-
MapLogicalType() : ::avro::CustomLogicalType("map") {}
28-
};
29-
30-
void RegisterLogicalTypes();
26+
ICEBERG_BUNDLE_EXPORT void RegisterLogicalTypes();
3127

3228
} // namespace iceberg::avro

src/iceberg/avro/avro_schema_util.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,7 @@ constexpr std::string_view kElementIdProp = "element-id";
5050
constexpr std::string_view kAdjustToUtcProp = "adjust-to-utc";
5151

5252
::avro::LogicalType GetMapLogicalType() {
53-
static std::once_flag flag{};
54-
std::call_once(flag, []() {
55-
// Register the map logical type with the avro custom logical type registry.
56-
// See https://github.com/apache/avro/pull/3326 for details.
57-
RegisterLogicalTypes();
58-
});
53+
RegisterLogicalTypes();
5954
return ::avro::LogicalType(std::make_shared<MapLogicalType>());
6055
}
6156

src/iceberg/avro/avro_schema_util_internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ class ValidSchema;
3434

3535
namespace iceberg::avro {
3636

37+
struct MapLogicalType : public ::avro::CustomLogicalType {
38+
MapLogicalType() : ::avro::CustomLogicalType("map") {}
39+
};
40+
3741
/// \brief A visitor that converts an Iceberg type to an Avro node.
3842
class ToAvroNodeVisitor {
3943
public:

0 commit comments

Comments
 (0)