Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/iceberg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ set(ICEBERG_SOURCES
file_writer.cc
inheritable_metadata.cc
json_internal.cc
manifest_adapter.cc
manifest_entry.cc
manifest_list.cc
manifest_reader.cc
manifest_reader_internal.cc
manifest_writer.cc
manifest/manifest_adapter.cc
manifest/manifest_entry.cc
manifest/manifest_list.cc
manifest/manifest_reader.cc
manifest/manifest_reader_internal.cc
manifest/manifest_writer.cc
manifest/v1_metadata.cc
manifest/v2_metadata.cc
manifest/v3_metadata.cc
metadata_columns.cc
name_mapping.cc
partition_field.cc
Expand Down Expand Up @@ -74,10 +77,7 @@ set(ICEBERG_SOURCES
util/temporal_util.cc
util/timepoint.cc
util/truncate_util.cc
util/uuid.cc
v1_metadata.cc
v2_metadata.cc
v3_metadata.cc)
util/uuid.cc)

set(ICEBERG_STATIC_BUILD_INTERFACE_LIBS)
set(ICEBERG_SHARED_BUILD_INTERFACE_LIBS)
Expand Down Expand Up @@ -131,6 +131,7 @@ iceberg_install_all_headers(iceberg)

add_subdirectory(catalog)
add_subdirectory(expression)
add_subdirectory(manifest)
add_subdirectory(row)
add_subdirectory(util)

Expand Down
4 changes: 2 additions & 2 deletions src/iceberg/inheritable_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

#include <iceberg/result.h>

#include "iceberg/manifest_entry.h"
#include "iceberg/manifest_list.h"
#include "iceberg/manifest/manifest_entry.h"
#include "iceberg/manifest/manifest_list.h"
#include "iceberg/snapshot.h"

namespace iceberg {
Expand Down
18 changes: 18 additions & 0 deletions src/iceberg/manifest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

iceberg_install_all_headers(iceberg/manifest)
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@
* under the License.
*/

#include "iceberg/manifest_adapter.h"

#include <memory>
#include <utility>

#include <nanoarrow/nanoarrow.h>

#include "iceberg/arrow/nanoarrow_status_internal.h"
#include "iceberg/manifest_entry.h"
#include "iceberg/manifest_list.h"
#include "iceberg/manifest/manifest_adapter_internal.h"
#include "iceberg/manifest/manifest_entry.h"
#include "iceberg/manifest/manifest_list.h"
#include "iceberg/result.h"
#include "iceberg/schema.h"
#include "iceberg/util/checked_cast.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#pragma once

/// \file iceberg/manifest_adapter.h
/// \file iceberg/manifest/manifest_adapter_internal.h
/// Base class for adapters handling v1/v2/v3/v4 manifest metadata.

#include <memory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

#include "iceberg/manifest_entry.h"
#include "iceberg/manifest/manifest_entry.h"

#include <memory>
#include <vector>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#pragma once

/// \file iceberg/manifest/manifest_entry.h

#include <cstdint>
#include <map>
#include <memory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

#include "iceberg/manifest_list.h"
#include "iceberg/manifest/manifest_list.h"

#include "iceberg/schema.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#pragma once

/// \file iceberg/manifest_list.h
/// \file iceberg/manifest/manifest_list.h

#include <cstdint>
#include <optional>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
* under the License.
*/

#include "iceberg/manifest_reader.h"
#include "iceberg/manifest/manifest_reader.h"

#include "iceberg/manifest_entry.h"
#include "iceberg/manifest_list.h"
#include "iceberg/manifest_reader_internal.h"
#include "iceberg/manifest/manifest_entry.h"
#include "iceberg/manifest/manifest_list.h"
#include "iceberg/manifest/manifest_reader_internal.h"
#include "iceberg/schema.h"
#include "iceberg/schema_internal.h"
#include "iceberg/type.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#pragma once

/// \file iceberg/manifest_reader.h
/// \file iceberg/manifest/manifest_reader.h
/// Data reader interface for manifest files.

#include <memory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include "iceberg/arrow/nanoarrow_status_internal.h"
#include "iceberg/arrow_c_data_guard_internal.h"
#include "iceberg/file_format.h"
#include "iceberg/manifest_entry.h"
#include "iceberg/manifest_list.h"
#include "iceberg/manifest/manifest_entry.h"
#include "iceberg/manifest/manifest_list.h"
#include "iceberg/schema.h"
#include "iceberg/type.h"
#include "iceberg/util/checked_cast.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

#pragma once

/// \file iceberg/internal/manifest_reader_internal.h
/// \file iceberg/manifest/manifest_reader_internal.h
/// Reader implementation for manifest list files and manifest files.

#include "iceberg/file_reader.h"
#include "iceberg/inheritable_metadata.h"
#include "iceberg/manifest_reader.h"
#include "iceberg/manifest/manifest_reader.h"

namespace iceberg {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
* under the License.
*/

#include "iceberg/manifest_writer.h"
#include "iceberg/manifest/manifest_writer.h"

#include <optional>

#include "iceberg/manifest_entry.h"
#include "iceberg/manifest_list.h"
#include "iceberg/manifest/manifest_entry.h"
#include "iceberg/manifest/manifest_list.h"
#include "iceberg/manifest/v1_metadata_internal.h"
#include "iceberg/manifest/v2_metadata_internal.h"
#include "iceberg/manifest/v3_metadata_internal.h"
#include "iceberg/partition_summary_internal.h"
#include "iceberg/result.h"
#include "iceberg/schema.h"
#include "iceberg/table_metadata.h"
#include "iceberg/util/macros.h"
#include "iceberg/v1_metadata.h"
#include "iceberg/v2_metadata.h"
#include "iceberg/v3_metadata.h"

namespace iceberg {

Expand Down Expand Up @@ -294,8 +294,8 @@ Result<std::unique_ptr<ManifestWriter>> ManifestWriter::MakeV1Writer(
auto writer,
OpenFileWriter(manifest_location, std::move(schema), std::move(file_io),
adapter->metadata(), "manifest_entry"));
return std::make_unique<ManifestWriter>(std::move(writer), std::move(adapter),
manifest_location, std::nullopt);
return std::unique_ptr<ManifestWriter>(new ManifestWriter(
std::move(writer), std::move(adapter), manifest_location, std::nullopt));
}

Result<std::unique_ptr<ManifestWriter>> ManifestWriter::MakeV2Writer(
Expand Down Expand Up @@ -324,8 +324,8 @@ Result<std::unique_ptr<ManifestWriter>> ManifestWriter::MakeV2Writer(
auto writer,
OpenFileWriter(manifest_location, std::move(schema), std::move(file_io),
adapter->metadata(), "manifest_entry"));
return std::make_unique<ManifestWriter>(std::move(writer), std::move(adapter),
manifest_location, std::nullopt);
return std::unique_ptr<ManifestWriter>(new ManifestWriter(
std::move(writer), std::move(adapter), manifest_location, std::nullopt));
}

Result<std::unique_ptr<ManifestWriter>> ManifestWriter::MakeV3Writer(
Expand Down Expand Up @@ -356,10 +356,16 @@ Result<std::unique_ptr<ManifestWriter>> ManifestWriter::MakeV3Writer(
auto writer,
OpenFileWriter(manifest_location, std::move(schema), std::move(file_io),
adapter->metadata(), "manifest_entry"));
return std::make_unique<ManifestWriter>(std::move(writer), std::move(adapter),
manifest_location, first_row_id);
return std::unique_ptr<ManifestWriter>(new ManifestWriter(
std::move(writer), std::move(adapter), manifest_location, first_row_id));
}

ManifestListWriter::ManifestListWriter(std::unique_ptr<Writer> writer,
std::unique_ptr<ManifestFileAdapter> adapter)
: writer_(std::move(writer)), adapter_(std::move(adapter)) {}

ManifestListWriter::~ManifestListWriter() = default;

Status ManifestListWriter::Add(const ManifestFile& file) {
if (adapter_->size() >= kBatchSize) {
ICEBERG_ASSIGN_OR_RAISE(auto array, adapter_->FinishAppending());
Expand Down Expand Up @@ -400,7 +406,8 @@ Result<std::unique_ptr<ManifestListWriter>> ManifestListWriter::MakeV1Writer(
auto writer,
OpenFileWriter(manifest_list_location, std::move(schema), std::move(file_io),
adapter->metadata(), "manifest_file"));
return std::make_unique<ManifestListWriter>(std::move(writer), std::move(adapter));
return std::unique_ptr<ManifestListWriter>(
new ManifestListWriter(std::move(writer), std::move(adapter)));
}

Result<std::unique_ptr<ManifestListWriter>> ManifestListWriter::MakeV2Writer(
Expand All @@ -418,7 +425,8 @@ Result<std::unique_ptr<ManifestListWriter>> ManifestListWriter::MakeV2Writer(
OpenFileWriter(manifest_list_location, std::move(schema), std::move(file_io),
adapter->metadata(), "manifest_file"));

return std::make_unique<ManifestListWriter>(std::move(writer), std::move(adapter));
return std::unique_ptr<ManifestListWriter>(
new ManifestListWriter(std::move(writer), std::move(adapter)));
}

Result<std::unique_ptr<ManifestListWriter>> ManifestListWriter::MakeV3Writer(
Expand All @@ -435,7 +443,8 @@ Result<std::unique_ptr<ManifestListWriter>> ManifestListWriter::MakeV3Writer(
auto writer,
OpenFileWriter(manifest_list_location, std::move(schema), std::move(file_io),
adapter->metadata(), "manifest_file"));
return std::make_unique<ManifestListWriter>(std::move(writer), std::move(adapter));
return std::unique_ptr<ManifestListWriter>(
new ManifestListWriter(std::move(writer), std::move(adapter)));
}

} // namespace iceberg
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#pragma once

/// \file iceberg/manifest_writer.h
/// \file iceberg/manifest/manifest_writer.h
/// Data writer interface for manifest files and manifest list files.

#include <memory>
Expand All @@ -28,7 +28,6 @@

#include "iceberg/file_writer.h"
#include "iceberg/iceberg_export.h"
#include "iceberg/manifest_adapter.h"
#include "iceberg/metrics.h"
#include "iceberg/result.h"
#include "iceberg/type_fwd.h"
Expand All @@ -38,10 +37,6 @@ namespace iceberg {
/// \brief Write manifest entries to a manifest file.
class ICEBERG_EXPORT ManifestWriter {
public:
ManifestWriter(std::unique_ptr<Writer> writer,
std::unique_ptr<ManifestEntryAdapter> adapter,
std::string_view manifest_location, std::optional<int64_t> first_row_id);

~ManifestWriter();

/// \brief Write the entry that all its fields are populated correctly.
Expand Down Expand Up @@ -160,11 +155,17 @@ class ICEBERG_EXPORT ManifestWriter {
std::shared_ptr<Schema> current_schema, ManifestContent content);

private:
// Private constructor for internal use only, use the static Make*Writer methods
// instead.
ManifestWriter(std::unique_ptr<Writer> writer,
std::unique_ptr<class ManifestEntryAdapter> adapter,
std::string_view manifest_location, std::optional<int64_t> first_row_id);

Status CheckDataFile(const DataFile& file) const;

static constexpr int64_t kBatchSize = 1024;
std::unique_ptr<Writer> writer_;
std::unique_ptr<ManifestEntryAdapter> adapter_;
std::unique_ptr<class ManifestEntryAdapter> adapter_;
bool closed_{false};
std::string manifest_location_;
std::optional<int64_t> first_row_id_;
Expand All @@ -182,11 +183,7 @@ class ICEBERG_EXPORT ManifestWriter {
/// \brief Write manifest files to a manifest list file.
class ICEBERG_EXPORT ManifestListWriter {
public:
ManifestListWriter(std::unique_ptr<Writer> writer,
std::unique_ptr<ManifestFileAdapter> adapter)
: writer_(std::move(writer)), adapter_(std::move(adapter)) {}

~ManifestListWriter() = default;
~ManifestListWriter();

/// \brief Write manifest file to manifest list file.
/// \param file Manifest file to write.
Expand Down Expand Up @@ -240,9 +237,14 @@ class ICEBERG_EXPORT ManifestListWriter {
std::string_view manifest_list_location, std::shared_ptr<FileIO> file_io);

private:
// Private constructor for internal use only, use the static Make*Writer methods
// instead.
ManifestListWriter(std::unique_ptr<Writer> writer,
std::unique_ptr<class ManifestFileAdapter> adapter);

static constexpr int64_t kBatchSize = 1024;
std::unique_ptr<Writer> writer_;
std::unique_ptr<ManifestFileAdapter> adapter_;
std::unique_ptr<class ManifestFileAdapter> adapter_;
};

} // namespace iceberg
26 changes: 26 additions & 0 deletions src/iceberg/manifest/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

install_headers(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to be consistent with CMakeLists.txt?

[
'manifest_entry.h',
'manifest_list.h',
'manifest_reader.h',
'manifest_writer.h',
],
subdir: 'iceberg/manifest',
)
Loading
Loading