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

Tracks deleted row positions using a bitmap. More...

#include <position_delete_index.h>

Public Member Functions

 PositionDeleteIndex (std::shared_ptr< DataFile > delete_file)
 
 PositionDeleteIndex (std::vector< std::shared_ptr< DataFile > > delete_files)
 
void Delete (int64_t pos)
 Mark a position as deleted.
 
void Delete (int64_t pos_start, int64_t pos_end)
 Mark a range of positions as deleted [pos_start, pos_end).
 
bool IsDeleted (int64_t pos) const
 Check if a position is deleted.
 
bool IsEmpty () const
 Check if the index is empty (no positions deleted).
 
int64_t Cardinality () const
 Get the number of deleted positions.
 
void Merge (const PositionDeleteIndex &other)
 Merge another index into this one.
 
const std::vector< std::shared_ptr< DataFile > > & delete_files () const
 The delete files whose positions were merged into this index.
 
Result< std::vector< uint8_t > > Serialize ()
 Serialize the index into a deletion-vector-v1 blob.
 

Static Public Member Functions

static Result< PositionDeleteIndexDeserialize (std::span< const uint8_t > blob, std::shared_ptr< DataFile > delete_file)
 Deserialize a deletion-vector-v1 blob into an index.
 

Friends

void ICEBERG_EXPORT ForEachPositionDelete (std::span< const int64_t > positions, PositionDeleteIndex &target, std::vector< uint32_t > &scratch)
 Apply positions to target as deletes; semantically equivalent to calling target.Delete(pos) for each entry. Out-of-range positions are silently ignored. Sorted, mostly-contiguous input is fastest.
 

Detailed Description

Tracks deleted row positions using a bitmap.

This class provides a domain-specific API for position deletes in Iceberg MOR (merge-on-read) tables. Positions are 0-based row indices within a data file.

Member Function Documentation

◆ Delete() [1/2]

void iceberg::PositionDeleteIndex::Delete ( int64_t  pos)

Mark a position as deleted.

Parameters
posThe 0-based row position to delete

◆ Delete() [2/2]

void iceberg::PositionDeleteIndex::Delete ( int64_t  pos_start,
int64_t  pos_end 
)

Mark a range of positions as deleted [pos_start, pos_end).

Parameters
pos_startStart position (inclusive)
pos_endEnd position (exclusive)

◆ delete_files()

const std::vector< std::shared_ptr< DataFile > > & iceberg::PositionDeleteIndex::delete_files ( ) const
inline

The delete files whose positions were merged into this index.

Populated by constructors and Deserialize, and preserved across Merge. Callers use these to report the delete files that were rewritten when replacing them with a new deletion vector.

◆ Deserialize()

static Result< PositionDeleteIndex > iceberg::PositionDeleteIndex::Deserialize ( std::span< const uint8_t >  blob,
std::shared_ptr< DataFile delete_file 
)
static

Deserialize a deletion-vector-v1 blob into an index.

Validates the blob framing (length prefix, magic sequence, CRC-32) and, against the source delete file, that the blob length matches content_size_in_bytes and the bitmap cardinality matches record_count. The source delete file is retained and exposed via delete_files().

◆ IsDeleted()

bool iceberg::PositionDeleteIndex::IsDeleted ( int64_t  pos) const

Check if a position is deleted.

Parameters
posThe 0-based row position to check
Returns
true if the position is deleted, false otherwise

◆ Merge()

void iceberg::PositionDeleteIndex::Merge ( const PositionDeleteIndex other)

Merge another index into this one.

Parameters
otherThe index to merge (union operation)

◆ Serialize()

Result< std::vector< uint8_t > > iceberg::PositionDeleteIndex::Serialize ( )

Serialize the index into a deletion-vector-v1 blob.

The positions are run-length encoded, then framed per the Puffin spec: https://iceberg.apache.org/puffin-spec/#deletion-vector-v1-blob-type

Friends And Related Symbol Documentation

◆ ForEachPositionDelete

void ICEBERG_EXPORT ForEachPositionDelete ( std::span< const int64_t >  positions,
PositionDeleteIndex target,
std::vector< uint32_t > &  scratch 
)
friend

Apply positions to target as deletes; semantically equivalent to calling target.Delete(pos) for each entry. Out-of-range positions are silently ignored. Sorted, mostly-contiguous input is fastest.

Parameters
scratchCaller-owned reusable buffer for the bulk dispatch path. Cleared and reused per key group; retain across calls to amortize allocations. Pass a distinct scratch per thread when calling concurrently with disjoint target.

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