Skip to content

Commit ff33b9a

Browse files
committed
add inline to the macro
Signed-off-by: Junwang Zhao <[email protected]>
1 parent 33d1fd7 commit ff33b9a

File tree

4 files changed

+25
-32
lines changed

4 files changed

+25
-32
lines changed

src/iceberg/json_internal.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
#include <type_traits>
2828
#include <unordered_set>
2929

30-
#include <iceberg/table.h>
31-
#include <iceberg/util/timepoint.h>
3230
#include <nlohmann/json.hpp>
3331

3432
#include "iceberg/partition_field.h"
@@ -39,11 +37,13 @@
3937
#include "iceberg/snapshot.h"
4038
#include "iceberg/sort_order.h"
4139
#include "iceberg/statistics_file.h"
40+
#include "iceberg/table.h"
4241
#include "iceberg/table_metadata.h"
4342
#include "iceberg/transform.h"
4443
#include "iceberg/type.h"
4544
#include "iceberg/util/formatter.h" // IWYU pragma: keep
4645
#include "iceberg/util/macros.h"
46+
#include "iceberg/util/timepoint.h"
4747

4848
namespace iceberg {
4949

src/iceberg/result.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ using Status = Result<void>;
6565
/// \brief Macro to define error creation functions
6666
#define DEFINE_ERROR_FUNCTION(name) \
6767
template <typename... Args> \
68-
auto name(const std::format_string<Args...> fmt, Args&&... args) \
68+
inline auto name(const std::format_string<Args...> fmt, Args&&... args) \
6969
-> unexpected<Error> { \
7070
return unexpected<Error>( \
7171
{ErrorKind::k##name, std::format(fmt, std::forward<Args>(args)...)}); \
@@ -80,6 +80,7 @@ DEFINE_ERROR_FUNCTION(IOError)
8080
DEFINE_ERROR_FUNCTION(JsonParseError)
8181
DEFINE_ERROR_FUNCTION(NoSuchNamespace)
8282
DEFINE_ERROR_FUNCTION(NoSuchTable)
83+
DEFINE_ERROR_FUNCTION(NotFound)
8384
DEFINE_ERROR_FUNCTION(NotImplemented)
8485
DEFINE_ERROR_FUNCTION(NotSupported)
8586
DEFINE_ERROR_FUNCTION(UnknownError)

src/iceberg/table_metadata.cc

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#include <ranges>
2424
#include <string>
2525

26-
#include "iceberg/expected.h"
2726
#include "iceberg/partition_spec.h"
27+
#include "iceberg/result.h"
2828
#include "iceberg/schema.h"
2929
#include "iceberg/sort_order.h"
3030
namespace iceberg {
@@ -44,10 +44,7 @@ Result<std::shared_ptr<Schema>> TableMetadata::Schema() const {
4444
return schema->schema_id() == current_schema_id;
4545
});
4646
if (iter == schemas.end()) {
47-
return unexpected<Error>({
48-
.kind = ErrorKind::kNotFound,
49-
.message = std::format("Current schema is not found"),
50-
});
47+
return NotFound("Current schema is not found");
5148
}
5249
return *iter;
5350
}
@@ -57,10 +54,7 @@ Result<std::shared_ptr<PartitionSpec>> TableMetadata::PartitionSpec() const {
5754
return spec->spec_id() == default_spec_id;
5855
});
5956
if (iter == partition_specs.end()) {
60-
return unexpected<Error>({
61-
.kind = ErrorKind::kNotFound,
62-
.message = std::format("Default partition spec is not found"),
63-
});
57+
return NotFound("Default partition spec is not found");
6458
}
6559
return *iter;
6660
}
@@ -70,10 +64,7 @@ Result<std::shared_ptr<SortOrder>> TableMetadata::SortOrder() const {
7064
return order->order_id() == default_sort_order_id;
7165
});
7266
if (iter == sort_orders.end()) {
73-
return unexpected<Error>({
74-
.kind = ErrorKind::kNotFound,
75-
.message = std::format("Default sort order is not found"),
76-
});
67+
return NotFound("Default sort order is not found");
7768
}
7869
return *iter;
7970
}

test/metadata_serde_test.cc

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -166,22 +166,23 @@ TEST_F(MetadataSerdeTest, DeserializeV2Valid) {
166166
EXPECT_EQ(metadata->current_snapshot_id, 3055729675574597004);
167167

168168
// Compare snapshots
169-
std::vector<Snapshot> expected_snapshots{{
170-
.snapshot_id = 3051729675574597004,
171-
.sequence_number = 0,
172-
.timestamp_ms = 1515100955770,
173-
.manifest_list = "s3://a/b/1.avro",
174-
.summary = {{"operation", "append"}},
175-
},
176-
{
177-
.snapshot_id = 3055729675574597004,
178-
.parent_snapshot_id = 3051729675574597004,
179-
.sequence_number = 1,
180-
.timestamp_ms = 1555100955770,
181-
.manifest_list = "s3://a/b/2.avro",
182-
.summary = {{"operation", "append"}},
183-
.schema_id = 1,
184-
}};
169+
std::vector<Snapshot> expected_snapshots{
170+
{
171+
.snapshot_id = 3051729675574597004,
172+
.sequence_number = 0,
173+
.timestamp_ms = TimePointMsFromUnixMs(1515100955770).value(),
174+
.manifest_list = "s3://a/b/1.avro",
175+
.summary = {{"operation", "append"}},
176+
},
177+
{
178+
.snapshot_id = 3055729675574597004,
179+
.parent_snapshot_id = 3051729675574597004,
180+
.sequence_number = 1,
181+
.timestamp_ms = TimePointMsFromUnixMs(1555100955770).value(),
182+
.manifest_list = "s3://a/b/2.avro",
183+
.summary = {{"operation", "append"}},
184+
.schema_id = 1,
185+
}};
185186
EXPECT_EQ(metadata->snapshots.size(), expected_snapshots.size());
186187
for (size_t i = 0; i < expected_snapshots.size(); ++i) {
187188
EXPECT_EQ(*metadata->snapshots[i], expected_snapshots[i]);

0 commit comments

Comments
 (0)