iceberg-cpp
Loading...
Searching...
No Matches
snapshot_manager.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
22#include <memory>
23#include <string>
24
25#include "iceberg/iceberg_export.h"
26#include "iceberg/result.h"
27#include "iceberg/type_fwd.h"
29
32
33namespace iceberg {
34
50class ICEBERG_EXPORT SnapshotManager : public ErrorCollector {
51 public:
53 static Result<std::shared_ptr<SnapshotManager>> Make(std::shared_ptr<Table> table);
54
58 static Result<std::shared_ptr<SnapshotManager>> Make(
59 std::shared_ptr<Transaction> transaction);
60
61 ~SnapshotManager() override;
62
68 SnapshotManager& Cherrypick(int64_t snapshot_id);
69
74 SnapshotManager& SetCurrentSnapshot(int64_t snapshot_id);
75
80 SnapshotManager& RollbackToTime(int64_t timestamp_ms);
81
87 SnapshotManager& RollbackTo(int64_t snapshot_id);
88
95 SnapshotManager& CreateBranch(const std::string& name);
96
102 SnapshotManager& CreateBranch(const std::string& name, int64_t snapshot_id);
103
109 SnapshotManager& CreateTag(const std::string& name, int64_t snapshot_id);
110
115 SnapshotManager& RemoveBranch(const std::string& name);
116
121 SnapshotManager& RemoveTag(const std::string& name);
122
128 SnapshotManager& ReplaceTag(const std::string& name, int64_t snapshot_id);
129
135 SnapshotManager& ReplaceBranch(const std::string& name, int64_t snapshot_id);
136
144 SnapshotManager& ReplaceBranch(const std::string& from, const std::string& to);
145
154 SnapshotManager& FastForwardBranch(const std::string& from, const std::string& to);
155
161 SnapshotManager& RenameBranch(const std::string& name, const std::string& new_name);
162
168 SnapshotManager& SetMinSnapshotsToKeep(const std::string& branch_name,
169 int32_t min_snapshots_to_keep);
170
176 SnapshotManager& SetMaxSnapshotAgeMs(const std::string& branch_name,
177 int64_t max_snapshot_age_ms);
178
184 SnapshotManager& SetMaxRefAgeMs(const std::string& name, int64_t max_ref_age_ms);
185
187 Status Commit();
188
189 private:
190 SnapshotManager(std::shared_ptr<Transaction> transaction, bool is_external_transaction);
191
193 Result<std::shared_ptr<UpdateSnapshotReference>> UpdateSnapshotReferencesOperation();
194
196 Status CommitIfRefUpdatesExist();
197
198 std::shared_ptr<Transaction> transaction_;
199 const bool is_external_transaction_;
200 std::shared_ptr<UpdateSnapshotReference> update_snap_refs_;
201};
202
203} // namespace iceberg
Base class for collecting errors in the builder pattern.
Definition error_collector.h:93
API for managing snapshots.
Definition snapshot_manager.h:50