iceberg-cpp
Loading...
Searching...
No Matches
manifest_group.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 <functional>
26#include <memory>
27#include <string>
28#include <unordered_map>
29#include <unordered_set>
30#include <vector>
31
36#include "iceberg/result.h"
37#include "iceberg/type_fwd.h"
40
41namespace iceberg {
42
44struct ICEBERG_EXPORT TaskContext {
45 public:
46 std::shared_ptr<PartitionSpec> spec;
47 DeleteFileIndex* deletes;
48 ResidualEvaluator* residuals;
49 bool drop_stats;
50 std::unordered_set<int32_t> columns_to_keep_stats;
51};
52
54class ICEBERG_EXPORT ManifestGroup : public ErrorCollector {
55 public:
63 std::shared_ptr<FileIO> io, std::shared_ptr<Schema> schema,
64 std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>> specs_by_id_,
65 std::vector<ManifestFile> manifests);
66
75 std::shared_ptr<FileIO> io, std::shared_ptr<Schema> schema,
76 std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>> specs_by_id,
77 std::vector<ManifestFile> data_manifests,
78 std::vector<ManifestFile> delete_manifests);
79
80 ~ManifestGroup() override;
81
82 ManifestGroup(ManifestGroup&&) noexcept;
83 ManifestGroup& operator=(ManifestGroup&&) noexcept;
84 ManifestGroup(const ManifestGroup&) = delete;
85 ManifestGroup& operator=(const ManifestGroup&) = delete;
86
88 ManifestGroup& FilterData(std::shared_ptr<Expression> filter);
89
91 ManifestGroup& FilterFiles(std::shared_ptr<Expression> filter);
92
94 ManifestGroup& FilterPartitions(std::shared_ptr<Expression> filter);
95
102 ManifestGroup& FilterManifestEntries(
103 std::function<bool(const ManifestEntry&)> predicate);
104
106 ManifestGroup& IgnoreDeleted();
107
109 ManifestGroup& IgnoreExisting();
110
112 ManifestGroup& IgnoreResiduals();
113
117 ManifestGroup& Select(std::vector<std::string> columns);
118
120 ManifestGroup& CaseSensitive(bool case_sensitive);
121
125 ManifestGroup& ColumnsToKeepStats(std::unordered_set<int32_t> column_ids);
126
131 ManifestGroup& PlanWith(OptionalExecutor executor);
132
134 ManifestGroup& WithScanMetrics(std::shared_ptr<ScanMetrics> scan_metrics);
135
137 Result<std::vector<std::shared_ptr<FileScanTask>>> PlanFiles();
138
140 Result<std::vector<ManifestEntry>> Entries();
141
142 using CreateTasksFunction =
143 std::function<Result<std::vector<std::shared_ptr<ScanTask>>>(
144 std::vector<ManifestEntry>&&, const TaskContext&)>;
145
150 Result<std::vector<std::shared_ptr<ScanTask>>> Plan(
151 const CreateTasksFunction& create_tasks);
152
153 private:
154 ManifestGroup(std::shared_ptr<FileIO> io, std::shared_ptr<Schema> schema,
155 std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>> specs_by_id,
156 std::vector<ManifestFile> data_manifests,
157 DeleteFileIndex::Builder&& delete_index_builder);
158
159 Result<std::unordered_map<int32_t, std::vector<ManifestEntry>>> ReadEntries();
160
161 Result<std::unique_ptr<ManifestReader>> MakeReader(const ManifestFile& manifest);
162
163 std::shared_ptr<FileIO> io_;
164 std::shared_ptr<Schema> schema_;
165 std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>> specs_by_id_;
166 std::vector<ManifestFile> data_manifests_;
167 DeleteFileIndex::Builder delete_index_builder_;
168 std::shared_ptr<Expression> data_filter_;
169 std::shared_ptr<Expression> file_filter_;
170 std::shared_ptr<Expression> partition_filter_;
171 std::function<bool(const ManifestEntry&)> manifest_entry_predicate_;
172 std::vector<std::string> columns_;
173 std::unordered_set<int32_t> columns_to_keep_stats_;
174 OptionalExecutor executor_;
175 bool case_sensitive_ = true;
176 bool ignore_deleted_ = false;
177 bool ignore_existing_ = false;
178 bool ignore_residuals_ = false;
179 std::shared_ptr<ScanMetrics> scan_metrics_;
180};
181
182} // namespace iceberg
An index of delete files by sequence number.
Definition delete_file_index.h:229
Base class for collecting errors in the builder pattern.
Definition error_collector.h:93
Represents a boolean expression tree.
Definition expression.h:37
Pluggable module for reading, writing, and deleting files.
Definition file_io.h:128
Task representing a data file and its corresponding delete files.
Definition table_scan.h:66
Coordinates reading manifest files and producing scan tasks.
Definition manifest_group.h:54
static Result< std::unique_ptr< ManifestGroup > > Make(std::shared_ptr< FileIO > io, std::shared_ptr< Schema > schema, std::unordered_map< int32_t, std::shared_ptr< PartitionSpec > > specs_by_id_, std::vector< ManifestFile > manifests)
Construct a ManifestGroup with a list of manifests.
static Result< std::unique_ptr< ManifestGroup > > Make(std::shared_ptr< FileIO > io, std::shared_ptr< Schema > schema, std::unordered_map< int32_t, std::shared_ptr< PartitionSpec > > specs_by_id, std::vector< ManifestFile > data_manifests, std::vector< ManifestFile > delete_manifests)
Construct a ManifestGroup with pre-separated manifests.
Read manifest entries from a manifest file.
Definition manifest_reader.h:40
A partition spec for a Table.
Definition partition_spec.h:47
Finds the residuals for an Expression using the partitions in the given PartitionSpec.
Definition residual_evaluator.h:47
Live scan metrics collected during a table scan operation.
Definition scan_report.h:94
An abstract scan task.
Definition table_scan.h:43
A schema for a Table.
Definition schema.h:51
Define task executor interfaces.
Define symbol visibility macros for core Iceberg APIs.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:33
std::expected< T, E > Result
Result alias.
Definition result.h:88
STL namespace.
Define Result, Status, and error helpers.
A manifest is an immutable Avro file that lists data files or delete files, along with each file's pa...
Definition manifest_entry.h:318
Entry in a manifest list.
Definition manifest_list.h:85
Context passed to task creation functions.
Definition manifest_group.h:44