iceberg-cpp
Loading...
Searching...
No Matches
cherry_pick_operation.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 <string>
28
30#include "iceberg/result.h"
31#include "iceberg/type_fwd.h"
34
35namespace iceberg {
36
41class ICEBERG_EXPORT CherryPickOperation : public MergingSnapshotUpdate {
42 public:
49 std::string table_name, std::shared_ptr<TransactionContext> ctx);
50
55 CherryPickOperation& Cherrypick(int64_t snapshot_id);
56
57 protected:
59
60 std::string operation() override;
61
63 const std::shared_ptr<Snapshot>& snapshot) override;
64
65 private:
66 explicit CherryPickOperation(std::string table_name,
67 std::shared_ptr<TransactionContext> ctx);
68
70 bool IsFastForward(const TableMetadata& base) const;
71
74 Status ValidateNonAncestor(const TableMetadata& meta, int64_t snapshot_id) const;
75
78 Status ValidateReplacedPartitions(const TableMetadata& meta) const;
79
80 std::shared_ptr<Snapshot> cherrypick_snapshot_;
81 bool require_fast_forward_ = false;
82 std::optional<PartitionSet> replaced_partitions_;
83};
84
85} // namespace iceberg
Cherry-picks or fast-forwards the current state to a snapshot.
Definition cherry_pick_operation.h:41
Result< ApplyResult > Apply() override
Build snapshot state for the transaction's current metadata.
CherryPickOperation & Cherrypick(int64_t snapshot_id)
Cherry-pick the changes of the given snapshot, or fast-forward to it.
std::string operation() override
A string that describes the action that produced the new snapshot.
Status Validate(const TableMetadata &base, const std::shared_ptr< Snapshot > &snapshot) override
Validate the current metadata.
static Result< std::unique_ptr< CherryPickOperation > > Make(std::string table_name, std::shared_ptr< TransactionContext > ctx)
Create a new CherryPickOperation instance.
Abstract base class for merge-based snapshot write operations.
Definition merging_snapshot_update.h:63
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