iceberg-cpp
Loading...
Searching...
No Matches
row_delta.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
23
24#include <cstdint>
25#include <memory>
26#include <optional>
27#include <span>
28#include <string>
29#include <unordered_set>
30
32#include "iceberg/result.h"
33#include "iceberg/type_fwd.h"
36
37namespace iceberg {
38
47class ICEBERG_EXPORT RowDelta : public MergingSnapshotUpdate {
48 public:
50 static Result<std::unique_ptr<RowDelta>> Make(std::string table_name,
51 std::shared_ptr<TransactionContext> ctx);
52
57 RowDelta& AddRows(const std::shared_ptr<DataFile>& inserts);
58
63 RowDelta& AddDeletes(const std::shared_ptr<DataFile>& deletes);
64
69 RowDelta& RemoveRows(const std::shared_ptr<DataFile>& file);
70
75 RowDelta& RemoveDeletes(const std::shared_ptr<DataFile>& deletes);
76
85 RowDelta& ValidateFromSnapshot(int64_t snapshot_id);
86
91 RowDelta& CaseSensitive(bool case_sensitive);
92
104 RowDelta& ValidateDataFilesExist(std::span<const std::string> referenced_files);
105
116
124 RowDelta& ConflictDetectionFilter(std::shared_ptr<Expression> filter);
125
143
156
157 std::string operation() override;
158
159 protected:
160 Status Validate(const TableMetadata& current_metadata,
161 const std::shared_ptr<Snapshot>& snapshot) override;
162
163 private:
164 explicit RowDelta(std::string table_name, std::shared_ptr<TransactionContext> ctx);
165
166 Status ValidateNoConflictingFileAndPositionDeletes() const;
167
168 std::optional<int64_t> starting_snapshot_id_;
169 std::unordered_set<std::string> referenced_data_files_;
170 DataFileSet removed_data_files_;
171 bool validate_deletes_ = false;
172 std::shared_ptr<Expression> conflict_detection_filter_;
173 bool validate_new_data_files_ = false;
174 bool validate_new_delete_files_ = false;
175};
176
177} // namespace iceberg
A set of DataFile pointers with insertion order preserved and deduplicated by file path.
Definition data_file_set.h:44
Abstract base class for merge-based snapshot write operations.
Definition merging_snapshot_update.h:63
API for encoding row-level changes to a table.
Definition row_delta.h:47
RowDelta & ValidateFromSnapshot(int64_t snapshot_id)
Set the snapshot ID used in any reads for this operation.
RowDelta & RemoveRows(const std::shared_ptr< DataFile > &file)
Remove a DataFile from the table.
RowDelta & ValidateNoConflictingDeleteFiles()
Enable validation that concurrent delete files do not conflict.
RowDelta & ValidateDataFilesExist(std::span< const std::string > referenced_files)
Add data file paths that must not be removed by conflicting commits.
RowDelta & AddRows(const std::shared_ptr< DataFile > &inserts)
Add a DataFile to the table.
RowDelta & ValidateDeletedFiles()
Enable validation that referenced data files were not deleted.
RowDelta & ValidateNoConflictingDataFiles()
Enable validation that concurrent data files do not conflict.
static Result< std::unique_ptr< RowDelta > > Make(std::string table_name, std::shared_ptr< TransactionContext > ctx)
Create a new RowDelta instance.
std::string operation() override
A string that describes the action that produced the new snapshot.
Status Validate(const TableMetadata &current_metadata, const std::shared_ptr< Snapshot > &snapshot) override
Validate the current metadata.
RowDelta & RemoveDeletes(const std::shared_ptr< DataFile > &deletes)
Remove a rewritten DeleteFile from the table.
RowDelta & ConflictDetectionFilter(std::shared_ptr< Expression > filter)
Set a conflict detection filter used to validate concurrently added data and delete files.
RowDelta & CaseSensitive(bool case_sensitive)
Enable or disable case-sensitive expression binding for validations.
RowDelta & AddDeletes(const std::shared_ptr< DataFile > &deletes)
Add a DeleteFile to the table.
Define symbol visibility macros for core Iceberg 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.
Represents the metadata for an Iceberg table.
Definition table_metadata.h:73