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

Filters an existing snapshot's manifest list. More...

#include <manifest_filter_manager.h>

Public Types

using PartitionSpecsById = std::unordered_map< int32_t, std::shared_ptr< PartitionSpec > >
 

Public Member Functions

 ManifestFilterManager (const ManifestFilterManager &)=delete
 
ManifestFilterManageroperator= (const ManifestFilterManager &)=delete
 
Status DeleteByRowFilter (std::shared_ptr< Expression > expr)
 Register a row-filter expression.
 
void CaseSensitive (bool case_sensitive)
 Set whether row-filter field binding is case-sensitive.
 
Status DeleteFile (std::string_view path)
 Register an exact file path for deletion.
 
Status DeleteFile (std::shared_ptr< DataFile > file)
 Register a file object for deletion.
 
const DataFileSetFilesToBeDeleted () const
 Returns the set of file objects marked for deletion by this manager.
 
const std::vector< std::shared_ptr< DataFile > > & DeletedFiles () const
 Returns content-file objects deleted by the most recent FilterManifests() call, deduplicated by content-file identity.
 
int32_t DuplicateDeletesCount () const
 Returns how many duplicate file deletes were found in the most recent FilterManifests() call.
 
Result< SnapshotSummaryBuilderBuildSummary (const std::vector< ManifestFile > &manifests, const PartitionSpecsById &specs_by_id) const
 Build a snapshot-summary fragment from filtered manifests.
 
Status DropPartition (int32_t spec_id, PartitionValues partition)
 Register a partition for dropping.
 
void FailMissingDeletePaths ()
 Set a flag that makes FilterManifests() fail if any registered delete path was not found in any manifest entry.
 
void FailAnyDelete ()
 Set a flag that makes FilterManifests() return an error if any manifest entry matches a delete condition.
 
int32_t ReplacedManifestsCount () const
 Returns the number of manifests rewritten (replaced) by the last FilterManifests() call. A manifest is replaced when it contained deleted entries and was rewritten with those entries marked DELETED.
 
bool ContainsDeletes () const
 Returns true if any delete condition has been registered.
 
Status DropDeleteFilesOlderThan (int64_t sequence_number)
 Set the minimum data sequence number for delete files to retain.
 
void RemoveDanglingDeletesFor (const DataFileSet &deleted_files)
 Register data files that have been removed so their dangling DVs can be cleaned up.
 
Result< std::vector< ManifestFile > > FilterManifests (const TableMetadata &metadata, const std::shared_ptr< Snapshot > &base_snapshot, const ManifestWriterFactory &writer_factory)
 Apply all accumulated delete conditions to the base snapshot's manifests.
 
Result< std::vector< ManifestFile > > FilterManifests (const std::shared_ptr< Schema > &schema, const TableMetadata &metadata, const std::shared_ptr< Snapshot > &base_snapshot, const ManifestWriterFactory &writer_factory)
 Apply all accumulated delete conditions using an explicit schema.
 
Result< std::vector< ManifestFile > > FilterManifests (const std::shared_ptr< Schema > &schema, const PartitionSpecsById &specs_by_id, const std::vector< const ManifestFile * > &manifests, const ManifestWriterFactory &writer_factory)
 Apply all accumulated delete conditions to the provided manifests.
 
Status CleanUncommitted (const std::unordered_set< std::string > &committed)
 Delete cached filtered manifests that were not committed and roll back replaced-manifest accounting.
 

Static Public Member Functions

static Result< std::unique_ptr< ManifestFilterManager > > Make (ManifestContent content, std::shared_ptr< FileIO > file_io, std::function< Status(const std::string &)> delete_file={})
 

Detailed Description

Filters an existing snapshot's manifest list.

The manager accumulates delete conditions incrementally, then applies them all at once in a single FilterManifests() call. Manifests that contain no deleted entries are returned unchanged (no I/O). Manifests that do contain deleted entries are rewritten with those entries marked DELETED.

TODO(Guotao): For ManifestContent::kDeletes, implement cleanup for orphan delete files and dangling deletion vectors.

Note
This class is non-copyable and non-movable.

Member Function Documentation

◆ DeleteByRowFilter()

Status iceberg::ManifestFilterManager::DeleteByRowFilter ( std::shared_ptr< Expression expr)

Register a row-filter expression.

Any manifest entry whose column metrics indicate the file may satisfy the expression will be marked DELETED.

Parameters
exprThe expression to match files against

◆ DeleteFile() [1/2]

Status iceberg::ManifestFilterManager::DeleteFile ( std::shared_ptr< DataFile file)

Register a file object for deletion.

Any manifest entry whose file_path matches file->file_path will be marked DELETED. Duplicate registrations (same path) are silently ignored.

Parameters
fileThe data/delete file to delete (must not be null)

◆ DeleteFile() [2/2]

Status iceberg::ManifestFilterManager::DeleteFile ( std::string_view  path)

Register an exact file path for deletion.

Any manifest entry whose file_path matches this path will be marked DELETED.

Parameters
pathThe exact file path to delete

◆ DropDeleteFilesOlderThan()

Status iceberg::ManifestFilterManager::DropDeleteFilesOlderThan ( int64_t  sequence_number)

Set the minimum data sequence number for delete files to retain.

Only valid for ManifestContent::kDeletes managers. Delete entries whose data_sequence_number is positive and less than sequence_number will be marked DELETED. This continuously removes delete files that cannot match any remaining data rows (i.e. all data written before that sequence number has itself been deleted).

Parameters
sequence_numberthe inclusive lower bound; delete files older than this value are dropped

◆ DropPartition()

Status iceberg::ManifestFilterManager::DropPartition ( int32_t  spec_id,
PartitionValues  partition 
)

Register a partition for dropping.

Any manifest entry whose (spec_id, partition) pair matches will be marked DELETED.

Parameters
spec_idThe partition spec ID
partitionThe partition values to drop

◆ FilesToBeDeleted()

const DataFileSet & iceberg::ManifestFilterManager::FilesToBeDeleted ( ) const

Returns the set of file objects marked for deletion by this manager.

Includes file objects explicitly registered for deletion plus files deleted while filtering manifests.

◆ FilterManifests() [1/3]

Result< std::vector< ManifestFile > > iceberg::ManifestFilterManager::FilterManifests ( const std::shared_ptr< Schema > &  schema,
const PartitionSpecsById &  specs_by_id,
const std::vector< const ManifestFile * > &  manifests,
const ManifestWriterFactory writer_factory 
)

Apply all accumulated delete conditions to the provided manifests.

This overload accepts only the context needed for filtering. It is intended for callers that already have the active schema, partition specs, and manifest list.

Parameters
schemaActive schema to bind row-filter expressions and metrics evaluators
specs_by_idAll partition specs keyed by spec ID
manifestsManifest descriptors to filter
writer_factoryFactory to create new ManifestWriter instances
Returns
The filtered manifest list, or an error

◆ FilterManifests() [2/3]

Result< std::vector< ManifestFile > > iceberg::ManifestFilterManager::FilterManifests ( const std::shared_ptr< Schema > &  schema,
const TableMetadata metadata,
const std::shared_ptr< Snapshot > &  base_snapshot,
const ManifestWriterFactory writer_factory 
)

Apply all accumulated delete conditions using an explicit schema.

This overload is used when callers need row-filter evaluation bound against a schema other than metadata.Schema(), such as the schema at a branch head.

◆ FilterManifests() [3/3]

Result< std::vector< ManifestFile > > iceberg::ManifestFilterManager::FilterManifests ( const TableMetadata metadata,
const std::shared_ptr< Snapshot > &  base_snapshot,
const ManifestWriterFactory writer_factory 
)

Apply all accumulated delete conditions to the base snapshot's manifests.

Manifests that cannot possibly contain deleted files are returned unchanged. Manifests that do contain deleted files are rewritten using writer_factory.

Parameters
metadataTable metadata (provides specs and schema for evaluators)
base_snapshotThe snapshot whose manifests to filter (may be null)
writer_factoryFactory to create new ManifestWriter instances
Returns
The filtered manifest list, or an error

◆ RemoveDanglingDeletesFor()

void iceberg::ManifestFilterManager::RemoveDanglingDeletesFor ( const DataFileSet deleted_files)

Register data files that have been removed so their dangling DVs can be cleaned up.

Only valid for ManifestContent::kDeletes managers. For each DV whose referenced_data_file path appears in deleted_files, the DV entry is marked DELETED because the data file it targets no longer exists.

Parameters
deleted_filesset of data files that have been marked for deletion

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