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/table_scan.h"
38#include "iceberg/type_fwd.h"
41
42namespace iceberg {
43
45struct ICEBERG_EXPORT TaskContext {
46 public:
47 std::shared_ptr<PartitionSpec> spec;
48 DeleteFileIndex* deletes;
49 ResidualEvaluator* residuals;
50 bool drop_stats;
51 std::unordered_set<int32_t> columns_to_keep_stats;
52};
53
55class ICEBERG_EXPORT ManifestGroup : public ErrorCollector {
56 public:
64 std::shared_ptr<FileIO> io, std::shared_ptr<Schema> schema,
65 std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>> specs_by_id_,
66 std::vector<ManifestFile> manifests);
67
76 std::shared_ptr<FileIO> io, std::shared_ptr<Schema> schema,
77 std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>> specs_by_id,
78 std::vector<ManifestFile> data_manifests,
79 std::vector<ManifestFile> delete_manifests);
80
81 ~ManifestGroup() override;
82
83 ManifestGroup(ManifestGroup&&) noexcept;
84 ManifestGroup& operator=(ManifestGroup&&) noexcept;
85 ManifestGroup(const ManifestGroup&) = delete;
86 ManifestGroup& operator=(const ManifestGroup&) = delete;
87
89 ManifestGroup& FilterData(std::shared_ptr<Expression> filter);
90
92 ManifestGroup& FilterFiles(std::shared_ptr<Expression> filter);
93
95 ManifestGroup& FilterPartitions(std::shared_ptr<Expression> filter);
96
103 ManifestGroup& FilterManifestEntries(
104 std::function<bool(const ManifestEntry&)> predicate);
105
107 ManifestGroup& IgnoreDeleted();
108
110 ManifestGroup& IgnoreExisting();
111
113 ManifestGroup& IgnoreResiduals();
114
124 ManifestGroup& Select(std::vector<std::string> columns);
125
127 ManifestGroup& CaseSensitive(bool case_sensitive);
128
132 ManifestGroup& ColumnsToKeepStats(std::unordered_set<int32_t> column_ids);
133
141 ManifestGroup& PlanWith(OptionalExecutor executor);
142
144 ManifestGroup& WithScanMetrics(std::shared_ptr<ScanMetrics> scan_metrics);
145
149 Result<std::vector<std::shared_ptr<FileScanTask>>> PlanFiles() &&;
150
164 Result<FileScanTaskStreamPtr> PlanFilesStream() &&;
165
167 Result<std::vector<ManifestEntry>> Entries();
168
169 using CreateTasksFunction =
170 std::function<Result<std::vector<std::shared_ptr<ScanTask>>>(
171 std::vector<ManifestEntry>&&, const TaskContext&)>;
172
177 Result<std::vector<std::shared_ptr<ScanTask>>> Plan(
178 const CreateTasksFunction& create_tasks);
179
180 private:
181 class PlanningContext;
182 class FilePlanningStream;
183
184 struct StatsProjection {
185 std::vector<std::string> columns;
186 bool drop_stats;
187 };
188
189 ManifestGroup(std::shared_ptr<FileIO> io, std::shared_ptr<Schema> schema,
190 std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>> specs_by_id,
191 std::vector<ManifestFile> data_manifests,
192 DeleteFileIndex::Builder&& delete_index_builder);
193
195 PlanningContext& context);
196
198 const ManifestFile& manifest, const std::vector<std::string>& columns);
199
200 StatsProjection PrepareStatsProjection(bool has_equality_deletes) const;
201
202 std::shared_ptr<FileIO> io_;
203 std::shared_ptr<Schema> schema_;
204 std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>> specs_by_id_;
205 std::vector<ManifestFile> data_manifests_;
206 DeleteFileIndex::Builder delete_index_builder_;
207 std::shared_ptr<Expression> data_filter_;
208 std::shared_ptr<Expression> file_filter_;
209 std::shared_ptr<Expression> partition_filter_;
210 std::function<bool(const ManifestEntry&)> manifest_entry_predicate_;
211 std::vector<std::string> columns_;
212 std::unordered_set<int32_t> columns_to_keep_stats_;
213 OptionalExecutor executor_;
214 bool case_sensitive_ = true;
215 bool ignore_deleted_ = false;
216 bool ignore_existing_ = false;
217 bool ignore_residuals_ = false;
218 std::shared_ptr<ScanMetrics> scan_metrics_;
219};
220
221} // 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:99
Represents a boolean expression tree.
Definition expression.h:37
Task representing a data file and its corresponding delete files.
Definition table_scan.h:68
Coordinates reading manifest files and producing scan tasks.
Definition manifest_group.h:55
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.
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:45
Definition expected.h:1199
Define task executor interfaces.
Define symbol visibility macros for core Iceberg APIs.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:34
std::unique_ptr< FileScanTaskStream > FileScanTaskStreamPtr
Owning pointer to a file scan task stream.
Definition table_scan.h:142
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:319
Entry in a manifest list.
Definition manifest_list.h:86
Context passed to task creation functions.
Definition manifest_group.h:45
Define table scan APIs and scan task types.