Skip to content

Commit 74f61ae

Browse files
author
xiao.dong
committed
fix comment
1 parent 6a6011b commit 74f61ae

File tree

5 files changed

+15
-24
lines changed

5 files changed

+15
-24
lines changed

src/iceberg/avro/avro_reader.cc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <avro/Generic.hh>
3232
#include <avro/GenericDatum.hh>
3333

34+
#include "iceberg/arrow/arrow_error_transform_internal.h"
3435
#include "iceberg/arrow/arrow_fs_file_io_internal.h"
3536
#include "iceberg/avro/avro_data_util_internal.h"
3637
#include "iceberg/avro/avro_schema_util_internal.h"
@@ -51,13 +52,8 @@ Result<std::unique_ptr<AvroInputStream>> CreateInputStream(const ReaderOptions&
5152
}
5253

5354
auto io = internal::checked_pointer_cast<arrow::ArrowFileSystemFileIO>(options.io);
54-
auto result = io->fs()->OpenInputFile(file_info);
55-
if (!result.ok()) {
56-
return IOError("Failed to open file {} for {}", options.path,
57-
result.status().message());
58-
}
59-
60-
return std::make_unique<AvroInputStream>(result.MoveValueUnsafe(), buffer_size);
55+
ICEBERG_ARROW_ASSIGN_OR_RETURN(auto file, io->fs()->OpenInputFile(file_info));
56+
return std::make_unique<AvroInputStream>(file, buffer_size);
6157
}
6258

6359
} // namespace

src/iceberg/avro/avro_writer.cc

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#include <arrow/result.h>
2828
#include <avro/DataFile.hh>
2929
#include <avro/GenericDatum.hh>
30-
#include <avro/NodeImpl.hh>
3130

31+
#include "iceberg/arrow/arrow_error_transform_internal.h"
3232
#include "iceberg/arrow/arrow_fs_file_io_internal.h"
3333
#include "iceberg/avro/avro_schema_util_internal.h"
3434
#include "iceberg/avro/avro_stream_internal.h"
@@ -43,12 +43,8 @@ namespace {
4343
Result<std::unique_ptr<AvroOutputStream>> CreateOutputStream(const WriterOptions& options,
4444
int64_t buffer_size) {
4545
auto io = internal::checked_pointer_cast<arrow::ArrowFileSystemFileIO>(options.io);
46-
auto result = io->fs()->OpenOutputStream(options.path);
47-
if (!result.ok()) {
48-
return IOError("Failed to open file {} for {}", options.path,
49-
result.status().message());
50-
}
51-
return std::make_unique<AvroOutputStream>(result.MoveValueUnsafe(), buffer_size);
46+
ICEBERG_ARROW_ASSIGN_OR_RETURN(auto output, io->fs()->OpenOutputStream(options.path));
47+
return std::make_unique<AvroOutputStream>(output, buffer_size);
5248
}
5349

5450
} // namespace
@@ -120,19 +116,19 @@ Status AvroWriter::Close() {
120116
return {};
121117
}
122118

123-
Metrics AvroWriter::metrics() {
119+
std::optional<Metrics> AvroWriter::metrics() {
124120
if (impl_->Closed()) {
125121
// TODO(xiao.dong) implement metrics
126122
return {};
127123
}
128-
return {};
124+
return std::nullopt;
129125
}
130126

131-
int64_t AvroWriter::length() {
127+
std::optional<int64_t> AvroWriter::length() {
132128
if (impl_->Closed()) {
133129
return impl_->length();
134130
}
135-
return 0;
131+
return std::nullopt;
136132
}
137133

138134
std::vector<int64_t> AvroWriter::split_offsets() { return {}; }

src/iceberg/avro/avro_writer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ class ICEBERG_BUNDLE_EXPORT AvroWriter : public Writer {
3737

3838
Status Write(ArrowArray data) final;
3939

40-
Metrics metrics() final;
40+
std::optional<Metrics> metrics() final;
4141

42-
int64_t length() final;
42+
std::optional<int64_t> length() final;
4343

4444
std::vector<int64_t> split_offsets() final;
4545

src/iceberg/file_writer.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "iceberg/file_format.h"
3131
#include "iceberg/metrics.h"
3232
#include "iceberg/result.h"
33-
#include "iceberg/schema.h"
3433
#include "iceberg/type_fwd.h"
3534

3635
namespace iceberg {
@@ -70,11 +69,11 @@ class ICEBERG_EXPORT Writer {
7069

7170
/// \brief Get the file statistics.
7271
/// Only valid after the file is closed.
73-
virtual Metrics metrics() = 0;
72+
virtual std::optional<Metrics> metrics() = 0;
7473

7574
/// \brief Get the file length.
7675
/// Only valid after the file is closed.
77-
virtual int64_t length() = 0;
76+
virtual std::optional<int64_t> length() = 0;
7877

7978
/// \brief Returns a list of recommended split locations, if applicable, empty
8079
/// otherwise. When available, this information is used for planning scan tasks whose

src/iceberg/metrics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace iceberg {
3131

3232
/// \brief Iceberg file format metrics
3333
struct ICEBERG_EXPORT Metrics {
34-
int64_t row_count_ = 0;
34+
int64_t row_count = 0;
3535
std::unordered_map<int64_t, int64_t> column_sizes;
3636
std::unordered_map<int64_t, int64_t> value_counts;
3737
std::unordered_map<int64_t, int64_t> null_value_counts;

0 commit comments

Comments
 (0)