Skip to content

Commit 8906ff3

Browse files
authored
feat: implement manifest and manifest list writer adapter (cont'd) (#216)
1 parent 0228f4e commit 8906ff3

36 files changed

+1700
-183
lines changed

src/iceberg/CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
set(ICEBERG_INCLUDES "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/src>"
1919
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>")
2020
set(ICEBERG_SOURCES
21+
arrow_c_data_guard_internal.cc
2122
catalog/memory/in_memory_catalog.cc
2223
expression/expression.cc
2324
expression/expressions.cc
@@ -28,8 +29,12 @@ set(ICEBERG_SOURCES
2829
file_writer.cc
2930
inheritable_metadata.cc
3031
json_internal.cc
32+
manifest_adapter.cc
3133
manifest_entry.cc
3234
manifest_list.cc
35+
manifest_reader.cc
36+
manifest_reader_internal.cc
37+
manifest_writer.cc
3338
metadata_columns.cc
3439
name_mapping.cc
3540
partition_field.cc
@@ -51,16 +56,15 @@ set(ICEBERG_SOURCES
5156
transform.cc
5257
transform_function.cc
5358
type.cc
54-
manifest_reader.cc
55-
manifest_reader_internal.cc
56-
manifest_writer.cc
57-
arrow_c_data_guard_internal.cc
5859
util/conversions.cc
5960
util/decimal.cc
6061
util/gzip_internal.cc
6162
util/murmurhash3_internal.cc
6263
util/timepoint.cc
63-
util/uuid.cc)
64+
util/uuid.cc
65+
v1_metadata.cc
66+
v2_metadata.cc
67+
v3_metadata.cc)
6468

6569
set(ICEBERG_STATIC_BUILD_INTERFACE_LIBS)
6670
set(ICEBERG_SHARED_BUILD_INTERFACE_LIBS)

src/iceberg/arrow/arrow_fs_file_io.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
#include <arrow/filesystem/localfs.h>
2323
#include <arrow/filesystem/mockfs.h>
2424

25-
#include "iceberg/arrow/arrow_error_transform_internal.h"
2625
#include "iceberg/arrow/arrow_file_io.h"
2726
#include "iceberg/arrow/arrow_fs_file_io_internal.h"
27+
#include "iceberg/arrow/arrow_status_internal.h"
2828

2929
namespace iceberg::arrow {
3030

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#pragma once
21+
22+
#define ICEBERG_NANOARROW_RETURN_UNEXPECTED(status) \
23+
if (status != NANOARROW_OK) [[unlikely]] { \
24+
return iceberg::InvalidArrowData("nanoarrow error: {}", status); \
25+
}
26+
27+
#define ICEBERG_NANOARROW_RETURN_UNEXPECTED_WITH_ERROR(status, error) \
28+
if (status != NANOARROW_OK) [[unlikely]] { \
29+
return iceberg::InvalidArrowData("nanoarrow error: {} msg: {}", status, \
30+
error.message); \
31+
}

src/iceberg/avro/avro_data_util.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include <avro/NodeImpl.hh>
3333
#include <avro/Types.hh>
3434

35-
#include "iceberg/arrow/arrow_error_transform_internal.h"
35+
#include "iceberg/arrow/arrow_status_internal.h"
3636
#include "iceberg/avro/avro_data_util_internal.h"
3737
#include "iceberg/avro/avro_schema_util_internal.h"
3838
#include "iceberg/schema.h"

src/iceberg/avro/avro_reader.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
#include <avro/Generic.hh>
3232
#include <avro/GenericDatum.hh>
3333

34-
#include "iceberg/arrow/arrow_error_transform_internal.h"
3534
#include "iceberg/arrow/arrow_fs_file_io_internal.h"
35+
#include "iceberg/arrow/arrow_status_internal.h"
3636
#include "iceberg/avro/avro_data_util_internal.h"
3737
#include "iceberg/avro/avro_register.h"
3838
#include "iceberg/avro/avro_schema_util_internal.h"

src/iceberg/avro/avro_writer.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
#include <avro/Generic.hh>
3030
#include <avro/GenericDatum.hh>
3131

32-
#include "iceberg/arrow/arrow_error_transform_internal.h"
3332
#include "iceberg/arrow/arrow_fs_file_io_internal.h"
33+
#include "iceberg/arrow/arrow_status_internal.h"
3434
#include "iceberg/avro/avro_data_util_internal.h"
3535
#include "iceberg/avro/avro_register.h"
3636
#include "iceberg/avro/avro_schema_util_internal.h"
@@ -75,9 +75,9 @@ class AvroWriter::Impl {
7575
return {};
7676
}
7777

78-
Status Write(ArrowArray data) {
78+
Status Write(ArrowArray* data) {
7979
ICEBERG_ARROW_ASSIGN_OR_RETURN(auto result,
80-
::arrow::ImportArray(&data, &arrow_schema_));
80+
::arrow::ImportArray(data, &arrow_schema_));
8181

8282
for (int64_t i = 0; i < result->length(); i++) {
8383
ICEBERG_RETURN_UNEXPECTED(ExtractDatumFromArray(*result, i, datum_.get()));
@@ -119,7 +119,7 @@ class AvroWriter::Impl {
119119

120120
AvroWriter::~AvroWriter() = default;
121121

122-
Status AvroWriter::Write(ArrowArray data) { return impl_->Write(data); }
122+
Status AvroWriter::Write(ArrowArray* data) { return impl_->Write(data); }
123123

124124
Status AvroWriter::Open(const WriterOptions& options) {
125125
impl_ = std::make_unique<Impl>();

src/iceberg/avro/avro_writer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ICEBERG_BUNDLE_EXPORT AvroWriter : public Writer {
3535

3636
Status Close() final;
3737

38-
Status Write(ArrowArray data) final;
38+
Status Write(ArrowArray* data) final;
3939

4040
std::optional<Metrics> metrics() final;
4141

src/iceberg/file_writer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class ICEBERG_EXPORT Writer {
6565
/// \brief Write arrow data to the file.
6666
///
6767
/// \return Status of write results.
68-
virtual Status Write(ArrowArray data) = 0;
68+
/// \note Ownership of the data is transferred to the writer.
69+
virtual Status Write(ArrowArray* data) = 0;
6970

7071
/// \brief Get the file statistics.
7172
/// Only valid after the file is closed.

0 commit comments

Comments
 (0)