iceberg-cpp
Loading...
Searching...
No Matches
manifest_reader.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 <cstdint>
26#include <memory>
27#include <optional>
28#include <string>
29#include <unordered_map>
30#include <vector>
31
35#include "iceberg/result.h"
36#include "iceberg/type_fwd.h"
37#include "iceberg/util/stream.h"
38
39namespace iceberg {
40
43
45using ManifestEntryStreamPtr = std::unique_ptr<ManifestEntryStream>;
46
52class ICEBERG_EXPORT ManifestReader {
53 public:
54 virtual ~ManifestReader() = default;
55
60
65
71
77
84 virtual ManifestReader& Select(const std::vector<std::string>& columns) = 0;
85
90 virtual ManifestReader& FilterPartitions(std::shared_ptr<Expression> expr) = 0;
91
94 std::shared_ptr<class PartitionSet> partition_set) = 0;
95
100 virtual ManifestReader& FilterRows(std::shared_ptr<Expression> expr) = 0;
101
103 virtual ManifestReader& CaseSensitive(bool case_sensitive) = 0;
104
107
109 virtual ManifestReader& SkipCounter(std::shared_ptr<Counter> counter) = 0;
110
115 static bool ShouldDropStats(const std::vector<std::string>& columns);
116
125 std::shared_ptr<FileIO> file_io,
126 std::shared_ptr<Schema> schema,
127 std::shared_ptr<PartitionSpec> spec,
128 bool is_committed = true);
129
138 const ManifestFile& manifest, std::shared_ptr<FileIO> file_io,
139 std::shared_ptr<Schema> schema,
140 const std::unordered_map<int32_t, std::shared_ptr<PartitionSpec>>& specs_by_id,
141 bool is_committed = true);
142
154 std::string_view manifest_location, std::optional<int64_t> manifest_length,
155 std::shared_ptr<FileIO> file_io, std::shared_ptr<Schema> schema,
156 std::shared_ptr<PartitionSpec> spec,
157 std::unique_ptr<InheritableMetadata> inheritable_metadata,
158 std::optional<int64_t> first_row_id = std::nullopt, bool is_committed = true);
159
161 static std::vector<std::string> WithStatsColumns(
162 const std::vector<std::string>& columns);
163};
164
166class ICEBERG_EXPORT ManifestListReader {
167 public:
168 virtual ~ManifestListReader() = default;
169
172
175
181 std::string_view manifest_list_location, std::shared_ptr<FileIO> file_io);
182};
183
184} // namespace iceberg
Read manifest files from a manifest list file.
Definition manifest_reader.h:166
static Result< std::unique_ptr< ManifestListReader > > Make(std::string_view manifest_list_location, std::shared_ptr< FileIO > file_io)
Creates a reader for the manifest list.
virtual Result< std::unordered_map< std::string, std::string > > Metadata() const =0
Get the metadata of the manifest list file.
virtual Result< std::vector< ManifestFile > > Files() const =0
Read all manifest files in the manifest list file.
Read manifest entries from a manifest file.
Definition manifest_reader.h:52
virtual ManifestReader & SkipCounter(std::shared_ptr< Counter > counter)=0
Set a counter to increment for each entry skipped by per-entry filters.
static bool ShouldDropStats(const std::vector< std::string > &columns)
Determine whether stats should be dropped based on selected columns.
static Result< std::unique_ptr< ManifestReader > > Make(std::string_view manifest_location, std::optional< int64_t > manifest_length, std::shared_ptr< FileIO > file_io, std::shared_ptr< Schema > schema, std::shared_ptr< PartitionSpec > spec, std::unique_ptr< InheritableMetadata > inheritable_metadata, std::optional< int64_t > first_row_id=std::nullopt, bool is_committed=true)
Creates a reader for a manifest file.
virtual ManifestReader & FilterRows(std::shared_ptr< Expression > expr)=0
Filter manifest entries by row-level filter.
virtual Result< ManifestEntryStreamPtr > LiveEntriesStream()=0
Lazily read only live (non-deleted) manifest entries.
virtual ManifestReader & Select(const std::vector< std::string > &columns)=0
Select specific columns of data file to read from the manifest entries.
static Result< std::unique_ptr< ManifestReader > > Make(const ManifestFile &manifest, std::shared_ptr< FileIO > file_io, std::shared_ptr< Schema > schema, const std::unordered_map< int32_t, std::shared_ptr< PartitionSpec > > &specs_by_id, bool is_committed=true)
Creates a reader for a manifest file using specs keyed by ID.
virtual ManifestReader & FilterPartitions(std::shared_ptr< Expression > expr)=0
Filter manifest entries by partition filter.
static std::vector< std::string > WithStatsColumns(const std::vector< std::string > &columns)
Add stats columns to the column list if needed.
virtual ManifestReader & FilterPartitions(std::shared_ptr< class PartitionSet > partition_set)=0
Filter manifest entries to a specific set of partitions.
virtual ManifestReader & CaseSensitive(bool case_sensitive)=0
Set case sensitivity for column name matching.
virtual Result< ManifestEntryStreamPtr > EntriesStream()=0
Lazily read manifest entries.
virtual ManifestReader & TryDropStats()=0
Try to drop stats from returned DataFile objects.
Result< std::vector< ManifestEntry > > Entries()
Read all manifest entries in the manifest file.
static Result< std::unique_ptr< ManifestReader > > Make(const ManifestFile &manifest, std::shared_ptr< FileIO > file_io, std::shared_ptr< Schema > schema, std::shared_ptr< PartitionSpec > spec, bool is_committed=true)
Creates a reader for a manifest file.
Result< std::vector< ManifestEntry > > LiveEntries()
Read only live (non-deleted) manifest entries.
A pull-based stream whose reads may fail.
Definition stream.h:47
Definition expected.h:1199
Define metrics counters.
Define symbol visibility macros for core Iceberg APIs.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:34
std::unique_ptr< ManifestEntryStream > ManifestEntryStreamPtr
Owning pointer to a manifest entry stream.
Definition manifest_reader.h:45
Define Result, Status, and error helpers.
Pull-based stream interface for fallible, lazily produced values.
Entry in a manifest list.
Definition manifest_list.h:86