iceberg-cpp
Loading...
Searching...
No Matches
metadata_table.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 <concepts>
26#include <cstdint>
27#include <memory>
28#include <utility>
29
31#include "iceberg/result.h"
32#include "iceberg/type_fwd.h"
33
34namespace iceberg {
35namespace internal {
36struct MetadataScanContext;
37} // namespace internal
38
40enum class MetadataTableKind : uint8_t {
41 kEntries,
42 kFiles,
43 kDataFiles,
44 kDeleteFiles,
45 kHistory,
46 kMetadataLogEntries,
47 kSnapshots,
48 kRefs,
49 kManifests,
50 kPartitions,
51 kPositionDeletes,
52 kAllEntries,
53 kAllFiles,
54 kAllDataFiles,
55 kAllDeleteFiles,
56 kAllManifests,
57};
58
60class ICEBERG_EXPORT MetadataTable {
61 public:
62 using Kind = MetadataTableKind;
63
65 static Result<std::unique_ptr<MetadataTable>> Make(std::shared_ptr<const Table> table,
66 Kind kind);
67
69 template <typename MetadataTableType>
70 requires std::derived_from<MetadataTableType, MetadataTable>
72 std::shared_ptr<const Table> table) {
73 return MetadataTableType::Make(std::move(table));
74 }
75
76 virtual ~MetadataTable();
77
79 virtual Kind kind() const noexcept = 0;
80
82 virtual const std::shared_ptr<Schema>& schema() const = 0;
83
85 const std::shared_ptr<const Table>& source_table() const;
86
91 virtual Result<std::unique_ptr<MetadataScanBuilder>> NewScan() const;
92
93 protected:
94 explicit MetadataTable(std::shared_ptr<const Table> source_table);
95
97 virtual Result<std::unique_ptr<MetadataScan>> MakeScan(
98 internal::MetadataScanContext context) const = 0;
99
100 private:
101 friend class MetadataScanBuilder;
102
103 const std::shared_ptr<const Table> source_table_;
104};
105
106} // namespace iceberg
Configure a scan over captured metadata; the metadata table must outlive it.
Definition metadata_scan.h:60
A metadata scan that plans tasks or reads all of them as Arrow batches.
Definition metadata_scan.h:107
A metadata table backed by a source Iceberg table.
Definition metadata_table.h:60
static Result< std::unique_ptr< MetadataTable > > Make(std::shared_ptr< const Table > table, Kind kind)
Create a metadata table; unsupported kinds return NotImplemented.
virtual Kind kind() const noexcept=0
Return this metadata table's kind.
static Result< std::unique_ptr< MetadataTableType > > Make(std::shared_ptr< const Table > table)
Create a specific metadata table from its concrete class.
Definition metadata_table.h:71
A schema for a Table.
Definition schema.h:51
Represents an Iceberg table.
Definition table.h:45
Definition expected.h:1199
Define symbol visibility macros for core Iceberg APIs.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:34
MetadataTableKind
Iceberg metadata tables exposed by Table::Inspect().
Definition metadata_table.h:40
STL namespace.
Define Result, Status, and error helpers.