Skip to content

Commit ab2befb

Browse files
author
nullccxsy
committed
fix comments
1 parent b7e3d05 commit ab2befb

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/iceberg/avro/avro_stream_internal.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ void AvroOutputStream::flush() {
145145
}
146146
}
147147

148-
std::shared_ptr<::arrow::io::OutputStream> AvroOutputStream::get_output_stream() const {
148+
const std::shared_ptr<::arrow::io::OutputStream>& AvroOutputStream::arrow_output_stream()
149+
const {
149150
return output_stream_;
150151
}
151152

src/iceberg/avro/avro_stream_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class AvroOutputStream : public ::avro::OutputStream {
8787
/// store, if any.
8888
void flush() override;
8989

90-
std::shared_ptr<::arrow::io::OutputStream> get_output_stream() const;
90+
const std::shared_ptr<::arrow::io::OutputStream>& arrow_output_stream() const;
9191

9292
private:
9393
std::shared_ptr<::arrow::io::OutputStream> output_stream_;

src/iceberg/avro/avro_writer.cc

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ Result<std::unique_ptr<AvroOutputStream>> CreateOutputStream(const WriterOptions
5353

5454
} // namespace
5555

56-
// A stateful context to keep track of the writing progress.
57-
struct WriteContext {};
58-
5956
class AvroWriter::Impl {
6057
public:
6158
Status Open(const WriterOptions& options) {
@@ -70,7 +67,7 @@ class AvroWriter::Impl {
7067
constexpr int64_t kDefaultBufferSize = 1024 * 1024;
7168
ICEBERG_ASSIGN_OR_RAISE(auto output_stream,
7269
CreateOutputStream(options, kDefaultBufferSize));
73-
arrow_output_stream_ = output_stream->get_output_stream();
70+
arrow_output_stream_ = output_stream->arrow_output_stream();
7471
writer_ = std::make_unique<::avro::DataFileWriter<::avro::GenericDatum>>(
7572
std::move(output_stream), *avro_schema_);
7673
datum_ = std::make_unique<::avro::GenericDatum>(*avro_schema_);
@@ -105,19 +102,19 @@ class AvroWriter::Impl {
105102
int64_t length() { return total_bytes_; }
106103

107104
private:
108-
int64_t total_bytes_ = 0;
109105
// The schema to write.
110106
std::shared_ptr<::iceberg::Schema> write_schema_;
111107
// The avro schema to write.
112108
std::shared_ptr<::avro::ValidSchema> avro_schema_;
109+
// Arrow output stream of the Avro file to write
110+
std::shared_ptr<::arrow::io::OutputStream> arrow_output_stream_;
113111
// The avro writer to write the data into a datum.
114112
std::unique_ptr<::avro::DataFileWriter<::avro::GenericDatum>> writer_;
115-
// Arrow schema for data conversion (C API format)
116-
ArrowSchema arrow_schema_;
117-
// Reusable Avro datum for writing individual records
113+
// Reusable Avro datum for writing individual records.
118114
std::unique_ptr<::avro::GenericDatum> datum_;
119-
// Arrow output stream for writing data to filesystem
120-
std::shared_ptr<::arrow::io::OutputStream> arrow_output_stream_;
115+
// Arrow schema to write data.
116+
ArrowSchema arrow_schema_;
117+
int64_t total_bytes_ = 0;
121118
};
122119

123120
AvroWriter::~AvroWriter() = default;

test/avro_test.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,11 @@ class AvroReaderTest : public TempFileTestBase {
135135
ASSERT_TRUE(file_info_result.ok());
136136
ASSERT_EQ(file_info_result->size(), writer->length().value());
137137

138-
auto reader_result = ReaderFactoryRegistry::Open(
139-
FileFormatType::kAvro,
140-
{.path = temp_avro_file_, .io = file_io_, .projection = schema});
138+
auto reader_result = ReaderFactoryRegistry::Open(FileFormatType::kAvro,
139+
{.path = temp_avro_file_,
140+
.length = file_info_result->size(),
141+
.io = file_io_,
142+
.projection = schema});
141143
ASSERT_THAT(reader_result, IsOk());
142144
auto reader = std::move(reader_result.value());
143145
ASSERT_NO_FATAL_FAILURE(VerifyNextBatch(*reader, expected_string));

0 commit comments

Comments
 (0)