iceberg-cpp
Loading...
Searching...
No Matches
resolving_file_io.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 <memory>
26#include <shared_mutex>
27#include <string>
28#include <string_view>
29#include <unordered_map>
30#include <vector>
31
32#include "iceberg/file_io.h"
34#include "iceberg/result.h"
37
38namespace iceberg {
39
41class ICEBERG_EXPORT ResolvingFileIO final : public FileIO,
43 public:
44 explicit ResolvingFileIO(std::unordered_map<std::string, std::string> properties);
45 ~ResolvingFileIO() override;
46
47 Result<std::unique_ptr<InputFile>> NewInputFile(std::string file_location) override;
48
50 size_t length) override;
51
52 Result<std::unique_ptr<OutputFile>> NewOutputFile(std::string file_location) override;
53
54 Status DeleteFile(const std::string& file_location) override;
55
56 Status DeleteFiles(const std::vector<std::string>& file_locations) override;
57
59 const std::vector<StorageCredential>& storage_credentials) override;
60
61 const std::vector<StorageCredential>& credentials() const override;
62
64
65 private:
67 Result<std::shared_ptr<FileIO>> FileIOForPath(std::string_view location);
68
69 std::unordered_map<std::string, std::string> properties_;
70 // Guards lazy resolution and credential refresh.
71 std::shared_mutex mutex_;
72 std::vector<StorageCredential> storage_credentials_;
73 std::unordered_map<std::string, std::shared_ptr<FileIO>, StringHash, StringEqual>
74 io_by_name_;
75};
76
77} // namespace iceberg
Pluggable module for reading, writing, and deleting files.
Definition file_io.h:128
FileIO that resolves and caches implementations by registry name.
Definition resolving_file_io.h:42
Result< std::unique_ptr< OutputFile > > NewOutputFile(std::string file_location) override
Create an output file handle for the given location.
Result< std::unique_ptr< InputFile > > NewInputFile(std::string file_location, size_t length) override
Create an input file handle for the given location with a known length.
SupportsStorageCredentials * AsSupportsStorageCredentials() override
Return storage-credential support when implemented by this FileIO.
Definition resolving_file_io.h:63
Status DeleteFile(const std::string &file_location) override
Delete a file at the given location.
Status DeleteFiles(const std::vector< std::string > &file_locations) override
Delete files at the given locations.
Result< std::unique_ptr< InputFile > > NewInputFile(std::string file_location) override
Create an input file handle for the given location.
const std::vector< StorageCredential > & credentials() const override
Return currently installed storage credentials.
Status SetStorageCredentials(const std::vector< StorageCredential > &storage_credentials) override
Install vended storage credentials.
Mix-in for FileIO implementations that route object paths to per-prefix file systems built from vende...
Definition file_io.h:188
Define the FileIO abstraction and file stream 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
Define Result, Status, and error helpers.
Define storage credential metadata.
Provide string utility helpers.
Transparent equality function that supports std::string_view as lookup key.
Definition string_util.h:220
Transparent hash function that supports std::string_view as lookup key.
Definition string_util.h:210