iceberg-cpp
Loading...
Searching...
No Matches
metrics_config.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 <string>
27#include <string_view>
28#include <unordered_map>
29#include <unordered_set>
30#include <variant>
31
32#include "iceberg/iceberg_export.h"
33#include "iceberg/result.h"
34#include "iceberg/type_fwd.h"
35#include "iceberg/util/string_util.h"
36
37namespace iceberg {
38
39struct ICEBERG_EXPORT MetricsMode {
40 public:
41 enum class Kind : uint8_t {
42 kNone,
43 kCounts,
45 kFull,
46 };
47
48 static Result<MetricsMode> FromString(std::string_view mode);
49 static MetricsMode None();
50 static MetricsMode Counts();
51 static MetricsMode Full();
52
53 Kind kind;
54 std::variant<std::monostate, int32_t> length;
55};
56
58class ICEBERG_EXPORT MetricsConfig {
59 public:
61 static const std::shared_ptr<MetricsConfig>& Default();
62
64 static Result<std::shared_ptr<MetricsConfig>> Make(const Table& table);
65
67 static Result<std::unordered_set<int32_t>> LimitFieldIds(const Schema& schema,
68 int32_t limit);
69
74 static Status VerifyReferencedColumns(
75 const std::unordered_map<std::string, std::string>& updates, const Schema& schema);
76
80 MetricsMode ColumnMode(std::string_view column_name) const;
81
82 private:
83 using ColumnModeMap =
84 std::unordered_map<std::string, MetricsMode, StringHash, StringEqual>;
85
86 MetricsConfig(ColumnModeMap column_modes, MetricsMode default_mode);
87
96 static Result<std::shared_ptr<MetricsConfig>> MakeInternal(const TableProperties& props,
97 const Schema& schema,
98 const SortOrder& order);
99
100 ColumnModeMap column_modes_;
101 MetricsMode default_mode_;
102};
103
104} // namespace iceberg
Configuration for collecting column metrics for an Iceberg table.
Definition metrics_config.h:58
A schema for a Table.
Definition schema.h:49
A sort order for a table.
Definition sort_order.h:40
Table properties for Iceberg tables.
Definition table_properties.h:37
Represents an Iceberg table.
Definition table.h:38
Definition metrics_config.h:39
@ kTruncate
Value truncated to width W