iceberg-cpp
Loading...
Searching...
No Matches
update_statistics.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 <unordered_map>
25#include <utility>
26#include <vector>
27
28#include "iceberg/iceberg_export.h"
29#include "iceberg/result.h"
30#include "iceberg/type_fwd.h"
32
35
36namespace iceberg {
37
39class ICEBERG_EXPORT UpdateStatistics : public PendingUpdate {
40 public:
41 static Result<std::shared_ptr<UpdateStatistics>> Make(
42 std::shared_ptr<TransactionContext> ctx);
43
44 ~UpdateStatistics() override;
45
53 UpdateStatistics& SetStatistics(std::shared_ptr<StatisticsFile> statistics_file);
54
61 UpdateStatistics& RemoveStatistics(int64_t snapshot_id);
62
63 Kind kind() const final { return Kind::kUpdateStatistics; }
64
69 bool IsRetryable() const override { return true; }
70
71 struct ApplyResult {
72 std::vector<std::pair<int64_t, std::shared_ptr<StatisticsFile>>> to_set;
73 std::vector<int64_t> to_remove;
74 };
75
76 Result<ApplyResult> Apply();
77
78 private:
79 explicit UpdateStatistics(std::shared_ptr<TransactionContext> ctx);
80
81 std::unordered_map<int64_t, std::shared_ptr<StatisticsFile>> statistics_to_set_;
82};
83
84} // namespace iceberg
Base class for all kinds of table metadata updates.
Definition pending_update.h:41
Updates table statistics.
Definition update_statistics.h:39
Kind kind() const final
Return the kind of this pending update.
Definition update_statistics.h:63
bool IsRetryable() const override
Statistics updates are retryable.
Definition update_statistics.h:69
Definition update_statistics.h:71