iceberg-cpp
Loading...
Searching...
No Matches
pending_update.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
24
25#include <memory>
26
28#include "iceberg/result.h"
29#include "iceberg/type_fwd.h"
31
32namespace iceberg {
33
47class ICEBERG_EXPORT PendingUpdate : public ErrorCollector,
48 public std::enable_shared_from_this<PendingUpdate> {
49 public:
50 enum class Kind : uint8_t {
51 kExpireSnapshots,
52 kSetSnapshot,
53 kUpdateLocation,
54 kUpdatePartitionSpec,
55 kUpdatePartitionStatistics,
56 kUpdateProperties,
57 kUpdateSchema,
58 kUpdateSnapshot,
59 kUpdateSnapshotReference,
60 kUpdateSortOrder,
61 kUpdateStatistics,
62 };
63
65 virtual Kind kind() const = 0;
66
68 virtual bool IsRetryable() const = 0;
69
78 virtual Status Commit();
79
80 PendingUpdate(const PendingUpdate&) = delete;
81 PendingUpdate& operator=(const PendingUpdate&) = delete;
82 PendingUpdate(PendingUpdate&&) = delete;
83 PendingUpdate& operator=(PendingUpdate&&) = delete;
84
85 ~PendingUpdate() override;
86
87 protected:
88 explicit PendingUpdate(std::shared_ptr<TransactionContext> ctx);
89
90 const TableMetadata& base() const;
91
92 Status CheckCommitAllowed() const;
93
95 virtual Status CleanStaged() { return {}; }
98 virtual Status Finalize(const TableMetadata& committed);
99
100 std::shared_ptr<TransactionContext> ctx_;
101
102 private:
103 friend class Transaction;
104
105 bool commit_called_ = false;
106};
107
108} // namespace iceberg
Base class for collecting errors in the builder pattern.
Definition error_collector.h:99
Base class for all kinds of table metadata updates.
Definition pending_update.h:48
virtual Kind kind() const =0
Return the kind of this pending update.
virtual Status CleanStaged()
Discard this generation's staging, retaining applied operation intent.
Definition pending_update.h:95
virtual Status Finalize(const TableMetadata &committed)
Complete a known successful commit. Called only by Transaction with the final committed table metadat...
virtual bool IsRetryable() const =0
Whether this update can be retried after a commit conflict.
virtual Status Commit()
Apply the pending changes and commit.
A transaction for performing multiple updates to a table.
Definition transaction.h:53
Definition expected.h:1199
Define symbol visibility macros for core Iceberg APIs.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:34
Define Result, Status, and error helpers.
Represents the metadata for an Iceberg table.
Definition table_metadata.h:73