iceberg-cpp
Loading...
Searching...
No Matches
set_snapshot.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 <cstdint>
23#include <memory>
24#include <optional>
25
26#include "iceberg/iceberg_export.h"
27#include "iceberg/result.h"
28#include "iceberg/type_fwd.h"
30
33
34namespace iceberg {
35
37class ICEBERG_EXPORT SetSnapshot : public PendingUpdate {
38 public:
39 static Result<std::shared_ptr<SetSnapshot>> Make(
40 std::shared_ptr<TransactionContext> ctx);
41
42 ~SetSnapshot() override;
43
45 SetSnapshot& SetCurrentSnapshot(int64_t snapshot_id);
46
48 SetSnapshot& RollbackToTime(int64_t timestamp_ms);
49
51 SetSnapshot& RollbackTo(int64_t snapshot_id);
52
53 Kind kind() const final { return Kind::kSetSnapshot; }
54 bool IsRetryable() const override { return true; }
55
57 Result<int64_t> Apply();
58
59 private:
60 explicit SetSnapshot(std::shared_ptr<TransactionContext> ctx);
61
66 Result<std::optional<int64_t>> FindLatestAncestorOlderThan(int64_t timestamp_ms) const;
67
68 std::optional<int64_t> target_snapshot_id_;
69 bool is_rollback_{false};
70};
71
72} // namespace iceberg
Base class for all kinds of table metadata updates.
Definition pending_update.h:41
Sets the current snapshot directly or by rolling back.
Definition set_snapshot.h:37
Kind kind() const final
Return the kind of this pending update.
Definition set_snapshot.h:53
bool IsRetryable() const override
Whether this update can be retried after a commit conflict.
Definition set_snapshot.h:54