iceberg-cpp
Loading...
Searching...
No Matches
scan_report.h
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 <memory>
23#include <optional>
24#include <string>
25#include <unordered_map>
26#include <vector>
27
28#include "iceberg/constants.h"
30#include "iceberg/iceberg_export.h"
33#include "iceberg/metrics/timer.h"
34
35namespace iceberg {
36
37// Forward declaration: ScanMetrics is defined later in this header.
38class ScanMetrics;
39
43struct ICEBERG_EXPORT ScanMetricsResult {
45 std::optional<TimerResult> total_planning_duration;
47 std::optional<CounterResult> result_data_files;
49 std::optional<CounterResult> result_delete_files;
51 std::optional<CounterResult> scanned_data_manifests;
53 std::optional<CounterResult> scanned_delete_manifests;
55 std::optional<CounterResult> total_data_manifests;
57 std::optional<CounterResult> total_delete_manifests;
59 std::optional<CounterResult> total_file_size_in_bytes;
61 std::optional<CounterResult> total_delete_file_size_in_bytes;
63 std::optional<CounterResult> skipped_data_manifests;
65 std::optional<CounterResult> skipped_delete_manifests;
67 std::optional<CounterResult> skipped_data_files;
69 std::optional<CounterResult> skipped_delete_files;
71 std::optional<CounterResult> indexed_delete_files;
73 std::optional<CounterResult> equality_delete_files;
75 std::optional<CounterResult> positional_delete_files;
77 std::optional<CounterResult> dvs;
78
79 bool operator==(const ScanMetricsResult&) const = default;
80
82 static ScanMetricsResult From(const ScanMetrics& scan_metrics);
83};
84
91class ICEBERG_EXPORT ScanMetrics {
92 public:
94 static std::unique_ptr<ScanMetrics> Make(MetricsContext& context);
95
97 static std::unique_ptr<ScanMetrics> Noop();
98
100 ScanMetricsResult ToResult() const;
101
102 std::shared_ptr<Timer> total_planning_duration;
103 std::shared_ptr<Counter> result_data_files;
104 std::shared_ptr<Counter> result_delete_files;
105 std::shared_ptr<Counter> scanned_data_manifests;
106 std::shared_ptr<Counter> scanned_delete_manifests;
107 std::shared_ptr<Counter> total_data_manifests;
108 std::shared_ptr<Counter> total_delete_manifests;
109 std::shared_ptr<Counter> total_file_size_in_bytes;
110 std::shared_ptr<Counter> total_delete_file_size_in_bytes;
111 std::shared_ptr<Counter> skipped_data_manifests;
112 std::shared_ptr<Counter> skipped_delete_manifests;
113 std::shared_ptr<Counter> skipped_data_files;
114 std::shared_ptr<Counter> skipped_delete_files;
115 std::shared_ptr<Counter> indexed_delete_files;
116 std::shared_ptr<Counter> equality_delete_files;
117 std::shared_ptr<Counter> positional_delete_files;
118 std::shared_ptr<Counter> dvs;
119
120 private:
121 ScanMetrics() = default;
122};
123
128struct ICEBERG_EXPORT ScanReport {
130 std::string table_name;
132 int64_t snapshot_id = kInvalidSnapshotId;
134 std::shared_ptr<Expression> filter;
136 int32_t schema_id = kInvalidSchemaId;
138 std::vector<int32_t> projected_field_ids;
140 std::vector<std::string> projected_field_names;
144 std::unordered_map<std::string, std::string> metadata;
145};
146
147} // namespace iceberg
Factory for creating named Counter and Timer instances.
Definition metrics_context.h:35
Live scan metrics collected during a table scan operation.
Definition scan_report.h:91
Factory interface for creating named Counter and Timer instances.
Serialisable snapshot types shared across scan and commit metrics.
Immutable snapshot of scan metrics for use in ScanReport.
Definition scan_report.h:43
std::optional< TimerResult > total_planning_duration
Total planning duration (count of recordings + accumulated nanoseconds).
Definition scan_report.h:45
std::optional< CounterResult > skipped_data_files
Number of individual data files skipped by stats pruning.
Definition scan_report.h:67
std::optional< CounterResult > total_data_manifests
Total number of data manifests in the snapshot.
Definition scan_report.h:55
std::optional< CounterResult > skipped_delete_files
Number of individual delete files skipped by stats pruning.
Definition scan_report.h:69
std::optional< CounterResult > total_file_size_in_bytes
Total byte size of all result data files.
Definition scan_report.h:59
std::optional< CounterResult > positional_delete_files
Number of positional delete files in the result.
Definition scan_report.h:75
std::optional< CounterResult > total_delete_manifests
Total number of delete manifests in the snapshot.
Definition scan_report.h:57
std::optional< CounterResult > total_delete_file_size_in_bytes
Total byte size of all result delete files.
Definition scan_report.h:61
std::optional< CounterResult > skipped_delete_manifests
Number of delete manifests skipped by partition/stats pruning.
Definition scan_report.h:65
std::optional< CounterResult > equality_delete_files
Number of equality delete files in the result.
Definition scan_report.h:73
std::optional< CounterResult > result_data_files
Number of data files included in the scan result.
Definition scan_report.h:47
std::optional< CounterResult > scanned_data_manifests
Number of data manifests whose files were read (not skipped).
Definition scan_report.h:51
std::optional< CounterResult > dvs
Number of deletion vectors in the result.
Definition scan_report.h:77
std::optional< CounterResult > result_delete_files
Number of delete files included in the scan result.
Definition scan_report.h:49
std::optional< CounterResult > skipped_data_manifests
Number of data manifests skipped by partition/stats pruning.
Definition scan_report.h:63
std::optional< CounterResult > indexed_delete_files
Number of indexed delete files (positional or DV) in the result.
Definition scan_report.h:71
std::optional< CounterResult > scanned_delete_manifests
Number of delete manifests whose files were read (not skipped).
Definition scan_report.h:53
Report generated after a table scan operation.
Definition scan_report.h:128
std::vector< int32_t > projected_field_ids
Projected field IDs from the scan schema.
Definition scan_report.h:138
std::vector< std::string > projected_field_names
Projected field names from the scan schema.
Definition scan_report.h:140
std::string table_name
The fully qualified name of the table that was scanned.
Definition scan_report.h:130
std::unordered_map< std::string, std::string > metadata
Additional key-value metadata.
Definition scan_report.h:144
std::shared_ptr< Expression > filter
Filter expression used in the scan, if any.
Definition scan_report.h:134
ScanMetricsResult scan_metrics
Metrics collected during the scan operation.
Definition scan_report.h:142