iceberg-cpp
Loading...
Searching...
No Matches
commit_report.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
24
25#include <memory>
26#include <optional>
27#include <string>
28#include <unordered_map>
29
30#include "iceberg/constants.h"
35
36namespace iceberg {
37
38// Forward declaration: CommitMetrics is defined later in this header.
39class CommitMetrics;
40
45struct ICEBERG_EXPORT CommitMetricsResult {
47 std::optional<TimerResult> total_duration;
49 std::optional<CounterResult> attempts;
51 std::optional<CounterResult> added_data_files;
53 std::optional<CounterResult> removed_data_files;
55 std::optional<CounterResult> total_data_files;
57 std::optional<CounterResult> added_delete_files;
59 std::optional<CounterResult> added_equality_delete_files;
61 std::optional<CounterResult> added_positional_delete_files;
63 std::optional<CounterResult> added_dvs;
65 std::optional<CounterResult> removed_delete_files;
67 std::optional<CounterResult> removed_positional_delete_files;
69 std::optional<CounterResult> removed_dvs;
71 std::optional<CounterResult> removed_equality_delete_files;
73 std::optional<CounterResult> total_delete_files;
75 std::optional<CounterResult> added_records;
77 std::optional<CounterResult> removed_records;
79 std::optional<CounterResult> total_records;
81 std::optional<CounterResult> added_files_size_bytes;
83 std::optional<CounterResult> removed_files_size_bytes;
85 std::optional<CounterResult> total_files_size_bytes;
87 std::optional<CounterResult> added_positional_deletes;
89 std::optional<CounterResult> removed_positional_deletes;
91 std::optional<CounterResult> total_positional_deletes;
93 std::optional<CounterResult> added_equality_deletes;
95 std::optional<CounterResult> removed_equality_deletes;
97 std::optional<CounterResult> total_equality_deletes;
99 std::optional<CounterResult> kept_manifest_count;
101 std::optional<CounterResult> created_manifest_count;
103 std::optional<CounterResult> replaced_manifest_count;
105 std::optional<CounterResult> processed_manifest_entries_count;
106
107 bool operator==(const CommitMetricsResult&) const = default;
108
114 const CommitMetrics& live_metrics,
115 const std::unordered_map<std::string, std::string>& snapshot_summary);
116};
117
123class ICEBERG_EXPORT CommitMetrics {
124 public:
126 static std::unique_ptr<CommitMetrics> Make(MetricsContext& context);
127
129 static std::unique_ptr<CommitMetrics> Noop();
130
133
135 std::shared_ptr<Timer> total_duration;
136
138 std::shared_ptr<Counter> attempts;
139
140 private:
141 CommitMetrics() = default;
142};
143
147struct ICEBERG_EXPORT CommitReport {
149 std::string table_name;
151 int64_t snapshot_id = kInvalidSnapshotId;
153 int64_t sequence_number = kInvalidSequenceNumber;
155 std::string operation;
159 std::unordered_map<std::string, std::string> metadata;
160};
161
162} // namespace iceberg
Live commit metrics collected during a table commit operation.
Definition commit_report.h:123
static std::unique_ptr< CommitMetrics > Noop()
Create a CommitMetrics instance with all-noop timer and counter.
static std::unique_ptr< CommitMetrics > Make(MetricsContext &context)
Create a CommitMetrics instance backed by the given MetricsContext.
std::shared_ptr< Counter > attempts
Counter for the number of commit attempts (including retries).
Definition commit_report.h:138
CommitMetricsResult ToResult() const
Snapshot current timer and counter values into a CommitMetricsResult.
std::shared_ptr< Timer > total_duration
Timer measuring total wall-clock time of the commit call.
Definition commit_report.h:135
Factory for creating named Counter and Timer instances.
Definition metrics_context.h:35
Define symbol visibility macros for core Iceberg APIs.
Factory interface for creating named Counter and Timer instances.
Serialisable snapshot types shared across scan and commit metrics.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:33
Immutable snapshot of commit metrics for use in CommitReport.
Definition commit_report.h:45
std::optional< CounterResult > added_equality_delete_files
Equality delete files added.
Definition commit_report.h:59
std::optional< CounterResult > added_positional_deletes
Positional delete records added.
Definition commit_report.h:87
std::optional< CounterResult > added_dvs
Deletion vectors added.
Definition commit_report.h:63
std::optional< CounterResult > total_delete_files
Total live delete files after this commit.
Definition commit_report.h:73
std::optional< CounterResult > removed_equality_deletes
Equality delete records removed.
Definition commit_report.h:95
std::optional< CounterResult > removed_files_size_bytes
Total byte size of files removed.
Definition commit_report.h:83
std::optional< CounterResult > added_delete_files
Number of delete files added in this commit.
Definition commit_report.h:57
static CommitMetricsResult From(const CommitMetrics &live_metrics, const std::unordered_map< std::string, std::string > &snapshot_summary)
Build a CommitMetricsResult from live metrics and a snapshot summary map.
std::optional< CounterResult > added_data_files
Number of data files added in this commit.
Definition commit_report.h:51
std::optional< CounterResult > processed_manifest_entries_count
Manifest entries processed in this commit.
Definition commit_report.h:105
std::optional< CounterResult > created_manifest_count
Manifest files created in this commit.
Definition commit_report.h:101
std::optional< CounterResult > removed_dvs
Deletion vectors removed.
Definition commit_report.h:69
std::optional< CounterResult > removed_equality_delete_files
Equality delete files removed.
Definition commit_report.h:71
std::optional< CounterResult > total_positional_deletes
Total positional delete records after this commit.
Definition commit_report.h:91
std::optional< CounterResult > replaced_manifest_count
Manifest files replaced in this commit.
Definition commit_report.h:103
std::optional< CounterResult > total_equality_deletes
Total equality delete records after this commit.
Definition commit_report.h:97
std::optional< CounterResult > total_files_size_bytes
Total byte size of all live files after this commit.
Definition commit_report.h:85
std::optional< CounterResult > added_files_size_bytes
Total byte size of files added.
Definition commit_report.h:81
std::optional< CounterResult > attempts
Number of commit attempts (1 on success without retries).
Definition commit_report.h:49
std::optional< CounterResult > total_records
Total live records after this commit.
Definition commit_report.h:79
std::optional< CounterResult > removed_positional_delete_files
Positional delete files removed.
Definition commit_report.h:67
std::optional< CounterResult > kept_manifest_count
Manifest files kept unchanged in this commit.
Definition commit_report.h:99
std::optional< CounterResult > added_records
Number of records added in this commit.
Definition commit_report.h:75
std::optional< CounterResult > added_positional_delete_files
Positional delete files added.
Definition commit_report.h:61
std::optional< CounterResult > added_equality_deletes
Equality delete records added.
Definition commit_report.h:93
std::optional< TimerResult > total_duration
Total wall-clock duration of the commit attempt.
Definition commit_report.h:47
std::optional< CounterResult > removed_delete_files
Number of delete files removed in this commit.
Definition commit_report.h:65
std::optional< CounterResult > removed_data_files
Number of data files removed in this commit.
Definition commit_report.h:53
std::optional< CounterResult > removed_positional_deletes
Positional delete records removed.
Definition commit_report.h:89
std::optional< CounterResult > total_data_files
Total live data files after this commit.
Definition commit_report.h:55
std::optional< CounterResult > removed_records
Number of records removed in this commit.
Definition commit_report.h:77
Report generated after a commit operation.
Definition commit_report.h:147
std::string operation
The operation that was performed (write, delete, etc.).
Definition commit_report.h:155
CommitMetricsResult commit_metrics
Metrics collected during the commit operation.
Definition commit_report.h:157
std::string table_name
The fully qualified name of the table that was modified.
Definition commit_report.h:149
std::unordered_map< std::string, std::string > metadata
Additional key-value metadata.
Definition commit_report.h:159
Define metrics timers.