51 int64_t
alive_count()
const {
return static_cast<int64_t
>(indices.size()); }
53 bool empty()
const {
return indices.empty(); }
59 void Increment(int64_t count = 1) {
60 count_.fetch_add(count, std::memory_order_relaxed);
62 int64_t Get()
const {
return count_.load(std::memory_order_relaxed); }
65 std::atomic<int64_t> count_{0};
83 using FieldLookup = std::function<Result<std::optional<FieldLookupResult>>(int32_t)>;
91 std::shared_ptr<Schema> table_schema,
92 std::span<
const std::shared_ptr<Schema>> schemas = {});
97 std::shared_ptr<TableMetadata> table_metadata);
110 std::string file_path, std::span<
const std::shared_ptr<DataFile>> delete_files,
111 std::shared_ptr<Schema> table_schema, std::shared_ptr<Schema> requested_schema,
112 std::shared_ptr<FileIO> io,
bool need_row_pos_col =
true,
113 std::shared_ptr<DeleteCounter> counter =
nullptr);
117 std::string file_path, std::span<
const std::shared_ptr<DataFile>> delete_files,
118 std::shared_ptr<TableMetadata> table_metadata,
119 std::shared_ptr<Schema> requested_schema, std::shared_ptr<FileIO> io,
120 bool need_row_pos_col =
true, std::shared_ptr<DeleteCounter> counter =
nullptr);
124 std::string file_path, std::span<
const std::shared_ptr<DataFile>> delete_files,
125 std::shared_ptr<Schema> table_schema, std::shared_ptr<Schema> requested_schema,
126 std::shared_ptr<FileIO> io, std::span<
const std::shared_ptr<Schema>> schemas,
127 bool need_row_pos_col =
true, std::shared_ptr<DeleteCounter> counter =
nullptr);
131 std::string file_path, std::span<
const std::shared_ptr<DataFile>> delete_files,
132 std::shared_ptr<Schema> requested_schema, std::shared_ptr<FileIO> io,
133 FieldLookup field_lookup,
bool need_row_pos_col =
true,
134 std::shared_ptr<DeleteCounter> counter =
nullptr);
183 bool HasPositionDeletes()
const;
184 bool HasEqualityDeletes()
const;
190 struct EqDeleteGroup;
192 DeleteFilter(std::string file_path, std::shared_ptr<Schema> requested_schema,
193 std::shared_ptr<FileIO> io,
FieldLookup field_lookup,
194 bool need_row_pos_col, std::shared_ptr<DeleteCounter> counter);
196 Status Init(std::span<
const std::shared_ptr<DataFile>> delete_files);
198 Status EnsurePositionDeletesLoaded()
const;
199 Status EnsureEqualityDeletesLoaded()
const;
201 const std::string file_path_;
202 std::vector<std::shared_ptr<DataFile>> pos_deletes_;
203 std::vector<std::shared_ptr<DataFile>> eq_deletes_;
205 std::shared_ptr<Schema> requested_schema_;
206 std::shared_ptr<Schema> required_schema_;
209 const bool need_row_pos_col_;
211 std::optional<size_t> pos_field_position_;
212 std::shared_ptr<DeleteCounter> counter_;
219 mutable std::mutex pos_mutex_;
220 mutable bool pos_loaded_ =
false;
223 mutable std::mutex eq_mutex_;
224 mutable bool eq_loaded_ =
false;
225 mutable std::vector<std::unique_ptr<EqDeleteGroup>> eq_groups_;
226 mutable std::function<Result<bool>(
const StructLike&)> eq_deleted_row_filter_cache_;
Counts rows removed by delete filters.
Definition delete_filter.h:57
Concrete batch-oriented delete filter for merge-on-read data batches.
Definition delete_filter.h:69
Result< std::function< Result< bool >(const StructLike &)> > EqDeletedRowFilter() const
Returns a predicate that is true for rows NOT matched by any equality delete.
const std::shared_ptr< Schema > & ExpectedSchema() const
The original schema requested by the caller, before delete columns were added.
const std::shared_ptr< Schema > & RequiredSchema() const
Schema required from the underlying data file reader.
static Result< std::unique_ptr< DeleteFilter > > Make(std::string file_path, std::span< const std::shared_ptr< DataFile > > delete_files, std::shared_ptr< Schema > table_schema, std::shared_ptr< Schema > requested_schema, std::shared_ptr< FileIO > io, std::span< const std::shared_ptr< Schema > > schemas, bool need_row_pos_col=true, std::shared_ptr< DeleteCounter > counter=nullptr)
Create a DeleteFilter with table schemas for dropped equality fields.
Result< AliveRowSelection > ComputeAliveRows(const ArrowSchema &batch_schema, const ArrowArray &batch) const
Compute alive rows relative to the supplied Arrow C Data batch.
static Result< FieldLookup > MakeFieldLookup(std::shared_ptr< TableMetadata > table_metadata)
Build a lookup from table metadata which uses the current schema first, then table metadata schemas a...
void IncrementDeleteCount(int64_t count=1)
Increment the delete counter by the given count.
static Result< std::unique_ptr< DeleteFilter > > Make(std::string file_path, std::span< const std::shared_ptr< DataFile > > delete_files, std::shared_ptr< Schema > requested_schema, std::shared_ptr< FileIO > io, FieldLookup field_lookup, bool need_row_pos_col=true, std::shared_ptr< DeleteCounter > counter=nullptr)
Create a DeleteFilter with a custom field lookup.
Result< std::function< Result< bool >(const StructLike &)> > FindEqualityDeleteRows() const
Returns a predicate that is true for rows matched by any equality delete.
std::function< Result< std::optional< FieldLookupResult > >(int32_t)> FieldLookup
Lookup a field by ID, including fields from table schema fallbacks.
Definition delete_filter.h:83
Result< const PositionDeleteIndex * > DeletedRowPositions() const
Expose the loaded position delete index for external use.
static Result< FieldLookup > MakeFieldLookup(std::shared_ptr< Schema > table_schema, std::span< const std::shared_ptr< Schema > > schemas={})
Build a lookup from the current schema and optional table schemas.
static Result< std::unique_ptr< DeleteFilter > > Make(std::string file_path, std::span< const std::shared_ptr< DataFile > > delete_files, std::shared_ptr< TableMetadata > table_metadata, std::shared_ptr< Schema > requested_schema, std::shared_ptr< FileIO > io, bool need_row_pos_col=true, std::shared_ptr< DeleteCounter > counter=nullptr)
Create a DeleteFilter using table metadata for schema-aware field lookup.
static Result< std::unique_ptr< DeleteFilter > > Make(std::string file_path, std::span< const std::shared_ptr< DataFile > > delete_files, std::shared_ptr< Schema > table_schema, std::shared_ptr< Schema > requested_schema, std::shared_ptr< FileIO > io, bool need_row_pos_col=true, std::shared_ptr< DeleteCounter > counter=nullptr)
Create a DeleteFilter with current schema only field lookup.
Loads delete files and constructs in-memory delete indexes.
Definition delete_loader.h:36
Tracks deleted row positions using a bitmap.
Definition position_delete_index.h:42
A type combined with a name.
Definition schema_field.h:39
An immutable struct-like wrapper.
Definition struct_like.h:62
Define symbol visibility macros for data APIs.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:33
std::expected< T, E > Result
Result alias.
Definition result.h:88
Define Result, Status, and error helpers.
Definition arrow_c_data.h:57
Definition arrow_c_data.h:41
Result of ComputeAliveRows: indices of rows not matched by any delete.
Definition delete_filter.h:46
int64_t alive_count() const
Number of alive rows (convenience accessor to avoid size_t casts).
Definition delete_filter.h:51
std::vector< int32_t > indices
Zero-based row indices within the batch that are alive (not deleted).
Definition delete_filter.h:48
Field lookup output for current or fallback equality-delete fields.
Definition delete_filter.h:77