iceberg-cpp
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
iceberg::ManifestWriter Class Reference

Write manifest entries to a manifest file. More...

#include <manifest_writer.h>

Public Member Functions

Status WriteEntry (const ManifestEntry &entry)
 Write the entry that all its fields are populated correctly.
 
Status WriteAddedEntry (std::shared_ptr< DataFile > file, std::optional< int64_t > data_sequence_number=std::nullopt)
 Add an added entry for a file with a specific sequence number.
 
Status WriteAddedEntry (const ManifestEntry &entry)
 Add a new entry to the manifest. The method populates the snapshot id and status fields of the entry.
 
Status WriteExistingEntry (std::shared_ptr< DataFile > file, int64_t file_snapshot_id, int64_t data_sequence_number, std::optional< int64_t > file_sequence_number=std::nullopt)
 Add an existing entry for a file.
 
Status WriteExistingEntry (const ManifestEntry &entry)
 Add an existing entry to the manifest. The method populates the status field of the entry.
 
Status WriteDeletedEntry (std::shared_ptr< DataFile > file, int64_t data_sequence_number, std::optional< int64_t > file_sequence_number=std::nullopt)
 Add a delete entry for a file.
 
Status WriteDeletedEntry (const ManifestEntry &entry)
 Add a deleted entry to the manifest. The method populates the snapshot id and status fields of the entry.
 
Status AddAll (const std::vector< ManifestEntry > &entries)
 Write manifest entries to file.
 
Status Close ()
 Close writer and flush to storage.
 
ManifestContent content () const
 Get the content of the manifest.
 
Result< Metricsmetrics () const
 Get the metrics of written manifest file.
 
Result< int64_t > length () const
 Get the current length of the manifest file in bytes.
 
Result< ManifestFileToManifestFile () const
 Get the ManifestFile object.
 

Static Public Member Functions

static Result< std::unique_ptr< ManifestWriter > > MakeWriter (int8_t format_version, std::optional< int64_t > snapshot_id, std::string_view manifest_location, std::shared_ptr< FileIO > file_io, std::shared_ptr< PartitionSpec > partition_spec, std::shared_ptr< Schema > current_schema, ManifestContent content=ManifestContent::kData, std::optional< int64_t > first_row_id=std::nullopt)
 Factory function to create a writer for a manifest file based on format version.
 

Detailed Description

Write manifest entries to a manifest file.

Member Function Documentation

◆ AddAll()

Status iceberg::ManifestWriter::AddAll ( const std::vector< ManifestEntry > &  entries)

Write manifest entries to file.

Parameters
entriesAlready populated manifest entries to write.
Returns
Status indicating success or failure

◆ length()

Result< int64_t > iceberg::ManifestWriter::length ( ) const

Get the current length of the manifest file in bytes.

Returns
The current length of the file, or an error if the operation fails.

◆ MakeWriter()

Result< std::unique_ptr< ManifestWriter > > iceberg::ManifestWriter::MakeWriter ( int8_t  format_version,
std::optional< int64_t >  snapshot_id,
std::string_view  manifest_location,
std::shared_ptr< FileIO file_io,
std::shared_ptr< PartitionSpec partition_spec,
std::shared_ptr< Schema current_schema,
ManifestContent  content = ManifestContent::kData,
std::optional< int64_t >  first_row_id = std::nullopt 
)
static

Factory function to create a writer for a manifest file based on format version.

Parameters
format_versionThe format version (1, 2, 3, etc.).
snapshot_idID of the snapshot.
manifest_locationPath to the manifest file.
file_ioFile IO implementation to use.
partition_specPartition spec for the manifest.
current_schemaSchema containing the source fields referenced by partition spec.
contentContent of the manifest (required for format_version >= 2).
first_row_idFirst row ID of the snapshot (required for format_version >= 3).
Returns
A Result containing the writer or an error.

◆ metrics()

Result< Metrics > iceberg::ManifestWriter::metrics ( ) const

Get the metrics of written manifest file.

Note
Only valid after the file is closed.

◆ ToManifestFile()

Result< ManifestFile > iceberg::ManifestWriter::ToManifestFile ( ) const

Get the ManifestFile object.

Note
Only valid after the file is closed.

◆ WriteAddedEntry()

Status iceberg::ManifestWriter::WriteAddedEntry ( std::shared_ptr< DataFile file,
std::optional< int64_t >  data_sequence_number = std::nullopt 
)

Add an added entry for a file with a specific sequence number.

Parameters
filean added data file
data_sequence_numbera data sequence number for the file
Returns
Status indicating success or failure
Note
The entry's snapshot ID will be this manifest's snapshot ID. The entry's data sequence number will be the provided data sequence number. The entry's file sequence number will be assigned at commit.

◆ WriteDeletedEntry()

Status iceberg::ManifestWriter::WriteDeletedEntry ( std::shared_ptr< DataFile file,
int64_t  data_sequence_number,
std::optional< int64_t >  file_sequence_number = std::nullopt 
)

Add a delete entry for a file.

Parameters
filea deleted data file
data_sequence_numbera data sequence number of the file (assigned when the file was added)
file_sequence_numbera file sequence number (assigned when the file was added)
Returns
Status indicating success or failure
Note
The entry's snapshot ID will be this manifest's snapshot ID. However, the original data and file sequence numbers of the file must be preserved when the file is marked as deleted.

◆ WriteEntry()

Status iceberg::ManifestWriter::WriteEntry ( const ManifestEntry entry)

Write the entry that all its fields are populated correctly.

Parameters
entryManifest entry to write.
Returns
Status indicating success or failure
Note
All other write entry variants delegate to this method after populating the necessary fields.

◆ WriteExistingEntry()

Status iceberg::ManifestWriter::WriteExistingEntry ( std::shared_ptr< DataFile file,
int64_t  file_snapshot_id,
int64_t  data_sequence_number,
std::optional< int64_t >  file_sequence_number = std::nullopt 
)

Add an existing entry for a file.

Parameters
filean existing data file
file_snapshot_idsnapshot ID when the data file was added to the table
data_sequence_numbera data sequence number of the file (assigned when the file was added)
file_sequence_numbera file sequence number (assigned when the file was added)
Returns
Status indicating success or failure
Note
The original data and file sequence numbers, snapshot ID, which were assigned at commit, must be preserved when adding an existing entry.

The documentation for this class was generated from the following files: