Skip to content

Commit 4aad42c

Browse files
committed
fix windows linking error
Signed-off-by: Junwang Zhao <[email protected]>
1 parent 12ae034 commit 4aad42c

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

src/iceberg/arrow/arrow_error_transform_internal.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ inline ErrorKind ToErrorKind(const ::arrow::Status& status) {
3939
#define ICEBERG_INTERNAL_ASSIGN_OR_RETURN_IMPL(result_name, lhs, rexpr, error_transform) \
4040
auto&& result_name = (rexpr); \
4141
if (!result_name.ok()) { \
42-
return unexpected( \
43-
Error(error_transform(result_name.status()), result_name.status().ToString())); \
42+
return unexpected<Error>{{.kind = error_transform(result_name.status()), \
43+
.message = result_name.status().ToString()}}; \
4444
} \
4545
lhs = std::move(result_name).ValueOrDie();
4646

@@ -53,7 +53,8 @@ inline ErrorKind ToErrorKind(const ::arrow::Status& status) {
5353
do { \
5454
auto&& _status = (expr); \
5555
if (!_status.ok()) { \
56-
return unexpected(Error(internal::ToErrorKind(_status), _status.ToString())); \
56+
return unexpected<Error>{ \
57+
{.kind = internal::ToErrorKind(_status), .message = _status.ToString()}}; \
5758
} \
5859
} while (0)
5960

src/iceberg/demo.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "iceberg/avro.h" // include to export symbols
2323
#include "iceberg/catalog.h"
24+
#include "iceberg/file_io.h"
2425
#include "iceberg/location_provider.h"
2526
#include "iceberg/table.h"
2627
#include "iceberg/transaction.h"

src/iceberg/error.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,14 @@ enum class ErrorKind {
3535
kCommitStateUnknown,
3636
kInvalidArgument,
3737
kIOError,
38+
kNotImplemented,
3839
kUnknownError,
3940
};
4041

4142
/// \brief Error with a kind and a message.
4243
struct ICEBERG_EXPORT [[nodiscard]] Error {
4344
ErrorKind kind;
4445
std::string message;
45-
46-
explicit Error(ErrorKind kind, std::string message)
47-
: kind(kind), message(std::move(message)) {};
4846
};
4947

5048
} // namespace iceberg

src/iceberg/file_io.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ class ICEBERG_EXPORT FileIO {
4747
/// \return The content of the file if the read succeeded, an error code if the read
4848
/// failed.
4949
virtual expected<std::string, Error> ReadFile(const std::string& file_location,
50-
std::optional<size_t> length) = 0;
50+
std::optional<size_t> length) {
51+
// The following line is to avoid Windows linker error LNK2019.
52+
// If this function is defined as pure virtual function, the `unexpected<Error>` will
53+
// not be instantiated and exported in libiceberg.
54+
return unexpected<Error>{
55+
{.kind = ErrorKind::kNotImplemented, .message = "ReadFile not implemented"}};
56+
}
5157

5258
/// \brief Write the given content to the file at the given location.
5359
///
@@ -57,7 +63,13 @@ class ICEBERG_EXPORT FileIO {
5763
/// file exists.
5864
/// \return void if the write succeeded, an error code if the write failed.
5965
virtual expected<void, Error> WriteFile(const std::string& file_location,
60-
std::string_view content, bool overwrite) = 0;
66+
std::string_view content, bool overwrite) {
67+
// The following line is to avoid Windows linker error LNK2019.
68+
// If this function is defined as pure virtual function, the `unexpected<Error>` will
69+
// not be instantiated and exported in libiceberg.
70+
return unexpected<Error>{
71+
{.kind = ErrorKind::kNotImplemented, .message = "WriteFile not implemented"}};
72+
}
6173

6274
/// \brief Delete a file at the given location.
6375
///

0 commit comments

Comments
 (0)