iceberg-cpp
Loading...
Searching...
No Matches
fast_append.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 <memory>
25#include <string>
26#include <unordered_map>
27#include <vector>
28
29#include "iceberg/iceberg_export.h"
30#include "iceberg/result.h"
31#include "iceberg/type_fwd.h"
32#include "iceberg/update/snapshot_update.h"
34
35namespace iceberg {
36
42class ICEBERG_EXPORT FastAppend : public SnapshotUpdate {
43 public:
49 static Result<std::unique_ptr<FastAppend>> Make(
50 std::string table_name, std::shared_ptr<TransactionContext> ctx);
51
56 FastAppend& AppendFile(const std::shared_ptr<DataFile>& file);
57
67 FastAppend& AppendManifest(const ManifestFile& manifest);
68
69 std::string operation() override;
70
71 Result<std::vector<ManifestFile>> Apply(
72 const TableMetadata& metadata_to_update,
73 const std::shared_ptr<Snapshot>& snapshot) override;
74 std::unordered_map<std::string, std::string> Summary() override;
75 void CleanUncommitted(const std::unordered_set<std::string>& committed) override;
76 bool CleanupAfterCommit() const override;
77
78 private:
79 explicit FastAppend(std::string table_name, std::shared_ptr<TransactionContext> ctx);
80
82 Result<std::shared_ptr<PartitionSpec>> Spec(int32_t spec_id);
83
88 Result<ManifestFile> CopyManifest(const ManifestFile& manifest);
89
93 Result<std::vector<ManifestFile>> WriteNewManifests();
94
95 private:
96 std::string table_name_;
97 std::unordered_map<int32_t, DataFileSet> new_data_files_by_spec_;
98 std::vector<ManifestFile> append_manifests_;
99 std::vector<ManifestFile> rewritten_append_manifests_;
100 std::vector<ManifestFile> new_manifests_;
101 bool has_new_files_{false};
102};
103
104} // namespace iceberg
Appending new files in a table.
Definition fast_append.h:42
Base class for operations that produce snapshots.
Definition snapshot_update.h:43
Entry in a manifest list.
Definition manifest_list.h:85
Represents the metadata for an Iceberg table.
Definition table_metadata.h:72