iceberg-cpp
Loading...
Searching...
No Matches
s3_properties.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 <algorithm>
26#include <array>
27#include <string_view>
28
29namespace iceberg::arrow {
30
38 static constexpr std::string_view kS3Schema = "s3";
40 static constexpr std::string_view kAccessKeyId = "s3.access-key-id";
42 static constexpr std::string_view kSecretAccessKey = "s3.secret-access-key";
44 static constexpr std::string_view kSessionToken = "s3.session-token";
46 static constexpr std::string_view kSessionTokenExpiresAtMs =
47 "s3.session-token-expires-at-ms";
49 static constexpr std::string_view kClientRegion = "client.region";
51 static constexpr std::string_view kEndpoint = "s3.endpoint";
53 static constexpr std::string_view kPathStyleAccess = "s3.path-style-access";
55 static constexpr std::string_view kSslEnabled = "s3.ssl.enabled";
57 static constexpr std::string_view kConnectTimeoutMs = "s3.connect-timeout-ms";
59 static constexpr std::string_view kSocketTimeoutMs = "s3.socket-timeout-ms";
61 static constexpr std::string_view kDeleteNumThreads = "s3.delete.num-threads";
62};
63
72inline constexpr std::array<std::string_view, 4> kS3Schemes = {"s3", "s3a", "s3n", "oss"};
73
76inline constexpr bool EqualsIgnoreAsciiCase(std::string_view left,
77 std::string_view right) {
78 constexpr auto lower = [](char c) {
79 return (c >= 'A' && c <= 'Z') ? static_cast<char>(c - 'A' + 'a') : c;
80 };
81 return std::ranges::equal(left, right,
82 [&](char a, char b) { return lower(a) == lower(b); });
83}
84
87inline constexpr bool IsS3Scheme(std::string_view scheme) {
88 return std::ranges::any_of(kS3Schemes, [scheme](std::string_view alias) {
89 return EqualsIgnoreAsciiCase(scheme, alias);
90 });
91}
92
99inline constexpr bool IsS3CredentialPrefix(std::string_view prefix) {
100 if (prefix == S3Properties::kS3Schema) {
101 return true;
102 }
103 const auto delimiter = prefix.find("://");
104 return delimiter != std::string_view::npos && IsS3Scheme(prefix.substr(0, delimiter));
105}
106
107} // namespace iceberg::arrow
Arrow-backed IO and data conversion APIs.
Definition arrow_io_util.h:34
constexpr bool IsS3CredentialPrefix(std::string_view prefix)
Return whether a storage credential prefix belongs to S3.
Definition s3_properties.h:99
constexpr std::array< std::string_view, 4 > kS3Schemes
URI schemes served by the Arrow S3 FileIO, lower-case. These schemes share the S3 client implementati...
Definition s3_properties.h:72
constexpr bool EqualsIgnoreAsciiCase(std::string_view left, std::string_view right)
ASCII-only case-insensitive comparison: schemes are ASCII (RFC 3986), and <cctype> is locale-sensitiv...
Definition s3_properties.h:76
constexpr bool IsS3Scheme(std::string_view scheme)
Return whether a URI scheme is S3-compatible; case-insensitive, because scheme routing is.
Definition s3_properties.h:87
S3 configuration property keys for ArrowS3FileIO.
Definition s3_properties.h:36
static constexpr std::string_view kSecretAccessKey
AWS secret access key.
Definition s3_properties.h:42
static constexpr std::string_view kS3Schema
S3 URI scheme.
Definition s3_properties.h:38
static constexpr std::string_view kSocketTimeoutMs
Socket timeout in milliseconds.
Definition s3_properties.h:59
static constexpr std::string_view kDeleteNumThreads
Maximum workers per DeleteFiles call; defaults to the hardware thread count.
Definition s3_properties.h:61
static constexpr std::string_view kSessionToken
AWS session token (for temporary credentials)
Definition s3_properties.h:44
static constexpr std::string_view kPathStyleAccess
Whether to use path-style access (needed for some S3-compatible object stores)
Definition s3_properties.h:53
static constexpr std::string_view kAccessKeyId
AWS access key ID.
Definition s3_properties.h:40
static constexpr std::string_view kConnectTimeoutMs
Connection timeout in milliseconds.
Definition s3_properties.h:57
static constexpr std::string_view kEndpoint
Custom endpoint override (for S3-compatible object stores)
Definition s3_properties.h:51
static constexpr std::string_view kSslEnabled
Whether SSL is enabled.
Definition s3_properties.h:55
static constexpr std::string_view kClientRegion
AWS region, standard Iceberg client property.
Definition s3_properties.h:49
static constexpr std::string_view kSessionTokenExpiresAtMs
Epoch milliseconds at which a vended session token stops being valid.
Definition s3_properties.h:46