iceberg-cpp
Loading...
Searching...
No Matches
rest_table_scan.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
22#include <cstdint>
23#include <functional>
24#include <memory>
25#include <optional>
26#include <string>
27#include <unordered_map>
28#include <unordered_set>
29#include <vector>
30
36#include "iceberg/result.h"
38#include "iceberg/table_scan.h"
39#include "iceberg/type_fwd.h"
40
43
44namespace iceberg::rest {
45
47struct ICEBERG_REST_EXPORT RestScanContext {
48 std::shared_ptr<HttpClient> client;
49 std::shared_ptr<ResourcePaths> paths;
50 std::shared_ptr<auth::AuthSession> session;
51 std::unordered_set<Endpoint> supported_endpoints;
52 TableIdentifier identifier;
55 std::unordered_map<std::string, std::string> catalog_config;
57 std::unordered_map<std::string, std::string> table_config;
60 std::function<Result<std::shared_ptr<StorageCredentialProvider>>(
61 const std::string& plan_id)>
62 credential_provider_factory;
63};
64
68class ICEBERG_REST_EXPORT RestTableScan : public DataTableScan {
69 public:
70 ~RestTableScan() override = default;
71
75 std::shared_ptr<TableMetadata> metadata, std::shared_ptr<Schema> schema,
76 std::shared_ptr<FileIO> io, internal::TableScanContext context,
77 std::shared_ptr<const RestScanContext> rest_context);
78
83
88 const std::shared_ptr<FileIO>& io() const override;
89
90 private:
91 RestTableScan(std::shared_ptr<TableMetadata> metadata, std::shared_ptr<Schema> schema,
92 std::shared_ptr<FileIO> io, internal::TableScanContext context,
93 std::shared_ptr<const RestScanContext> rest_context);
94
95 std::shared_ptr<const RestScanContext> rest_context_;
96 mutable std::shared_ptr<FileIO> scan_io_;
97};
98
100class ICEBERG_REST_EXPORT RestTableScanBuilder : public DataTableScanBuilder {
101 public:
102 RestTableScanBuilder(std::shared_ptr<TableMetadata> metadata,
103 std::shared_ptr<FileIO> io, std::string table_name,
104 std::shared_ptr<MetricsReporter> metrics_reporter,
105 std::shared_ptr<const RestScanContext> rest_context);
106
109
110 private:
111 std::shared_ptr<const RestScanContext> rest_context_;
112};
113
123class ICEBERG_REST_EXPORT RestIncrementalAppendScan : public IncrementalAppendScan {
124 public:
125 ~RestIncrementalAppendScan() override = default;
126
128 std::shared_ptr<TableMetadata> metadata, std::shared_ptr<Schema> schema,
129 std::shared_ptr<FileIO> io, internal::TableScanContext context,
130 std::shared_ptr<const RestScanContext> rest_context);
131
132 using IncrementalAppendScan::PlanFiles;
133
136 const std::shared_ptr<FileIO>& io() const override;
137
138 protected:
143 std::optional<int64_t> from_snapshot_id_exclusive,
144 int64_t to_snapshot_id_inclusive) const override;
145
146 private:
147 RestIncrementalAppendScan(std::shared_ptr<TableMetadata> metadata,
148 std::shared_ptr<Schema> schema, std::shared_ptr<FileIO> io,
150 std::shared_ptr<const RestScanContext> rest_context);
151
152 std::shared_ptr<const RestScanContext> rest_context_;
153 mutable std::shared_ptr<FileIO> scan_io_;
154};
155
157class ICEBERG_REST_EXPORT RestIncrementalAppendScanBuilder
159 public:
160 RestIncrementalAppendScanBuilder(std::shared_ptr<TableMetadata> metadata,
161 std::shared_ptr<FileIO> io, std::string table_name,
162 std::shared_ptr<MetricsReporter> metrics_reporter,
163 std::shared_ptr<const RestScanContext> rest_context);
164
166
167 private:
168 std::shared_ptr<const RestScanContext> rest_context_;
169};
170
171} // namespace iceberg::rest
A scan that reads data files and applies delete files to filter rows.
Definition data_table_scan.h:36
A scan that reads data files added between snapshots (incremental appends).
Definition incremental_append_scan.h:38
Builder class for creating TableScan instances.
Definition table_scan.h:293
Definition expected.h:1199
Builder that produces a RestIncrementalAppendScan.
Definition rest_table_scan.h:158
Result< std::unique_ptr< IncrementalAppendScan > > Build() override
Builds and returns a TableScan instance.
An IncrementalAppendScan that delegates PlanFiles() to the REST catalog server.
Definition rest_table_scan.h:123
const std::shared_ptr< FileIO > & io() const override
Returns the FileIO with vended credentials if the server returned any during planning; otherwise retu...
Result< std::vector< std::shared_ptr< FileScanTask > > > PlanFiles(std::optional< int64_t > from_snapshot_id_exclusive, int64_t to_snapshot_id_inclusive) const override
Plans files via the REST scan planning endpoints.
Builder that produces a RestTableScan with the REST HTTP context injected.
Definition rest_table_scan.h:100
Result< std::unique_ptr< DataTableScan > > Build() override
Resolves schema/context via parent logic then creates a RestTableScan.
A DataTableScan that delegates PlanFilesStream() to the REST catalog server via the scan planning end...
Definition rest_table_scan.h:68
const std::shared_ptr< FileIO > & io() const override
Returns the effective FileIO for reading scan results.
static Result< std::unique_ptr< DataTableScan > > Make(std::shared_ptr< TableMetadata > metadata, std::shared_ptr< Schema > schema, std::shared_ptr< FileIO > io, internal::TableScanContext context, std::shared_ptr< const RestScanContext > rest_context)
Create a point-in-time scan. Incremental ranges must use RestIncrementalAppendScan.
Result< FileScanTaskStreamPtr > PlanFilesStream() const override
Plans files lazily via the REST scan planning endpoints.
Scan that reads the data files of a table snapshot.
Define symbol visibility macros for the REST catalog library.
Scan that reads the data files appended between snapshots.
REST catalog APIs.
Definition auth_manager.h:34
Define Result, Status, and error helpers.
Identifies a table in iceberg catalog.
Definition table_identifier.h:46
Definition table_scan.h:260
REST table context shared by its builders, scans and task streams.
Definition rest_table_scan.h:47
std::unordered_map< std::string, std::string > catalog_config
Definition rest_table_scan.h:55
std::unordered_map< std::string, std::string > table_config
Table-level config merged with catalog_config for scan-scoped FileIO creation.
Definition rest_table_scan.h:57
Define table scan APIs and scan task types.