iceberg-cpp
Loading...
Searching...
No Matches
file_io_registry.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 <string_view>
29#include <unordered_map>
30
31#include "iceberg/file_io.h"
33#include "iceberg/result.h"
34
35namespace iceberg {
36
43class ICEBERG_EXPORT FileIORegistry {
44 public:
45 static constexpr std::string_view kArrowLocalFileIO = "arrow-fs-local";
46 static constexpr std::string_view kArrowS3FileIO = "arrow-fs-s3";
47
48 using Properties = std::unordered_map<std::string, std::string>;
49
51 struct Factory {
52 using CreateFunction =
53 std::function<Result<std::unique_ptr<FileIO>>(const Properties& properties)>;
54 using AcceptsFunction = std::function<bool(std::string_view scheme)>;
55
57 CreateFunction create;
59 AcceptsFunction accepts;
60 };
61
66 static void Register(std::string name, Factory factory);
67
73 static Result<std::unique_ptr<FileIO>> Load(std::string_view name,
74 const Properties& properties);
75
79 static Result<std::string> Resolve(std::string_view scheme);
80};
81
82} // namespace iceberg
Registry for FileIO implementations.
Definition file_io_registry.h:43
static void Register(std::string name, Factory factory)
Register a FileIO factory under the given name.
static Result< std::unique_ptr< FileIO > > Load(std::string_view name, const Properties &properties)
Load a FileIO implementation by name.
static Result< std::string > Resolve(std::string_view scheme)
Returns the last registered factory accepting scheme.
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.
Factory for explicit loading and optional scheme-based routing.
Definition file_io_registry.h:51
CreateFunction create
Required for explicit loading.
Definition file_io_registry.h:57
AcceptsFunction accepts
Receives a lower-case scheme. Empty means explicit-only.
Definition file_io_registry.h:59