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
31#include "iceberg/iceberg_export.h"
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
115 RowDelta& ValidateDeletedFiles();
116
124 RowDelta& ConflictDetectionFilter(std::shared_ptr<Expression> filter);
125
142 RowDelta& ValidateNoConflictingDataFiles();
143
155 RowDelta& ValidateNoConflictingDeleteFiles();
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:69
API for encoding row-level changes to a table.
Definition row_delta.h:47
Represents the metadata for an Iceberg table.
Definition table_metadata.h:73