Skip to content
Draft
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
1 change: 1 addition & 0 deletions src/iceberg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ set(ICEBERG_SOURCES
transform_function.cc
type.cc
update/pending_update.cc
update/snapshot_update.cc
update/update_properties.cc
util/bucket_util.cc
util/conversions.cc
Expand Down
19 changes: 19 additions & 0 deletions src/iceberg/manifest/manifest_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,23 @@ Result<std::unique_ptr<ManifestListWriter>> ManifestListWriter::MakeV3Writer(
new ManifestListWriter(std::move(writer), std::move(adapter)));
}

Result<std::unique_ptr<ManifestListWriter>> ManifestListWriter::Make(
int8_t format_version, int64_t snapshot_id, std::optional<int64_t> parent_snapshot_id,
std::string_view manifest_list_location, std::shared_ptr<FileIO> file_io,
int64_t sequence_number, int64_t first_row_id) {
switch (format_version) {
case 1:
return MakeV1Writer(snapshot_id, parent_snapshot_id, manifest_list_location,
file_io);
case 2:
return MakeV2Writer(snapshot_id, parent_snapshot_id, sequence_number,
manifest_list_location, file_io);
case 3:
return MakeV3Writer(snapshot_id, parent_snapshot_id, sequence_number, first_row_id,
manifest_list_location, file_io);
default:
std::unreachable();
}
}

} // namespace iceberg
15 changes: 15 additions & 0 deletions src/iceberg/manifest/manifest_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,21 @@ class ICEBERG_EXPORT ManifestListWriter {
int64_t sequence_number, int64_t first_row_id,
std::string_view manifest_list_location, std::shared_ptr<FileIO> file_io);

/// \brief Creates a writer for the manifest list based on the format version.
/// \param format_version Format version of the manifest list.
/// \param snapshot_id ID of the snapshot.
/// \param parent_snapshot_id ID of the parent snapshot.
/// \param manifest_list_location Path to the manifest list file.
/// \param file_io File IO implementation to use.
/// \param sequence_number Sequence number of the snapshot.
/// \param first_row_id First row ID of the snapshot.
/// \return A Result containing the writer or an error.
static Result<std::unique_ptr<ManifestListWriter>> Make(
int8_t format_version, int64_t snapshot_id,
std::optional<int64_t> parent_snapshot_id, std::string_view manifest_list_location,
std::shared_ptr<FileIO> file_io, int64_t sequence_number = 0,
int64_t first_row_id = 0);

private:
// Private constructor for internal use only, use the static Make*Writer methods
// instead.
Expand Down
20 changes: 10 additions & 10 deletions src/iceberg/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ICEBERG_EXPORT Table : public std::enable_shared_from_this<Table> {

virtual ~Table();

/// \brief Return the identifier of this table
/// \brief Returns the identifier of this table
const TableIdentifier& name() const { return identifier_; }

/// \brief Returns the UUID of the table
Expand All @@ -59,40 +59,40 @@ class ICEBERG_EXPORT Table : public std::enable_shared_from_this<Table> {
/// \brief Return the schema for this table, return NotFoundError if not found
Result<std::shared_ptr<Schema>> schema() const;

/// \brief Return a map of schema for this table
/// \brief Returns a map of schema for this table
Result<
std::reference_wrapper<const std::unordered_map<int32_t, std::shared_ptr<Schema>>>>
schemas() const;

/// \brief Return the partition spec for this table, return NotFoundError if not found
/// \brief Returns the partition spec for this table, return NotFoundError if not found
Result<std::shared_ptr<PartitionSpec>> spec() const;

/// \brief Return a map of partition specs for this table
/// \brief Returns a map of partition specs for this table
Result<std::reference_wrapper<
const std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>>>>
specs() const;

/// \brief Return the sort order for this table, return NotFoundError if not found
/// \brief Returns the sort order for this table, return NotFoundError if not found
Result<std::shared_ptr<SortOrder>> sort_order() const;

/// \brief Return a map of sort order IDs to sort orders for this table
/// \brief Returns a map of sort order IDs to sort orders for this table
Result<std::reference_wrapper<
const std::unordered_map<int32_t, std::shared_ptr<SortOrder>>>>
sort_orders() const;

/// \brief Return a map of string properties for this table
/// \brief Returns the properties of this table
const TableProperties& properties() const;

/// \brief Return the table's metadata file location
/// \brief Returns the table's metadata file location
std::string_view metadata_file_location() const;

/// \brief Return the table's base location
/// \brief Returns the table's base location
std::string_view location() const;

/// \brief Returns the time when this table was last updated
TimePointMs last_updated_ms() const;

/// \brief Return the table's current snapshot, return NotFoundError if not found
/// \brief Returns the table's current snapshot, return NotFoundError if not found
Result<std::shared_ptr<Snapshot>> current_snapshot() const;

/// \brief Get the snapshot of this table with the given id
Expand Down
3 changes: 3 additions & 0 deletions src/iceberg/table_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ class ICEBERG_EXPORT TableProperties : public ConfigBase<TableProperties> {
inline static Entry<int64_t> kDeleteTargetFileSizeBytes{
"write.delete.target-file-size-bytes", int64_t{64} * 1024 * 1024}; // 64 MB

inline static Entry<bool> kSnapshotIdInheritanceEnabled{
"compatibility.snapshot-id-inheritance.enabled", false};

// Garbage collection properties

inline static Entry<bool> kGcEnabled{"gc.enabled", true};
Expand Down
5 changes: 4 additions & 1 deletion src/iceberg/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ class ICEBERG_EXPORT Transaction : public std::enable_shared_from_this<Transacti
/// \brief Apply the pending changes to current table.
Status Apply(std::vector<std::unique_ptr<TableUpdate>> updates);

friend class PendingUpdate; // Need to access the Apply method.
/// \brief Friends to access the Apply method.
friend class PendingUpdate;
template <typename T>
friend class SnapshotUpdate;

private:
// The table that this transaction will update.
Expand Down
2 changes: 2 additions & 0 deletions src/iceberg/type_fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ class Transaction;
/// \brief Update family.
class PendingUpdate;
class UpdateProperties;
template <typename T>
class SnapshotUpdate;

/// ----------------------------------------------------------------------------
/// TODO: Forward declarations below are not added yet.
Expand Down
2 changes: 1 addition & 1 deletion src/iceberg/update/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
# under the License.

install_headers(
['pending_update.h', 'update_properties.h'],
['pending_update.h', 'update_properties.h', 'snapshot_update.h'],
subdir: 'iceberg/update',
)
Loading
Loading