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 kClientRegion = "client.region";
48 static constexpr std::string_view kEndpoint = "s3.endpoint";
50 static constexpr std::string_view kPathStyleAccess = "s3.path-style-access";
52 static constexpr std::string_view kSslEnabled = "s3.ssl.enabled";
54 static constexpr std::string_view kConnectTimeoutMs = "s3.connect-timeout-ms";
56 static constexpr std::string_view kSocketTimeoutMs = "s3.socket-timeout-ms";
57};
58
65inline constexpr std::array<std::string_view, 4> kS3Schemes = {"s3", "s3a", "s3n", "oss"};
66
69inline constexpr bool EqualsIgnoreAsciiCase(std::string_view left,
70 std::string_view right) {
71 constexpr auto lower = [](char c) {
72 return (c >= 'A' && c <= 'Z') ? static_cast<char>(c - 'A' + 'a') : c;
73 };
74 return std::ranges::equal(left, right,
75 [&](char a, char b) { return lower(a) == lower(b); });
76}
77
80inline constexpr bool IsS3Scheme(std::string_view scheme) {
81 return std::ranges::any_of(kS3Schemes, [scheme](std::string_view alias) {
82 return EqualsIgnoreAsciiCase(scheme, alias);
83 });
84}
85
92inline constexpr bool IsS3CredentialPrefix(std::string_view prefix) {
93 if (prefix == S3Properties::kS3Schema) {
94 return true;
95 }
96 const auto delimiter = prefix.find("://");
97 return delimiter != std::string_view::npos && IsS3Scheme(prefix.substr(0, delimiter));
98}
99
100} // namespace iceberg::arrow
Arrow-backed IO and data conversion APIs.
Definition arrow_io_util.h:33
constexpr bool IsS3CredentialPrefix(std::string_view prefix)
Return whether a storage credential prefix belongs to S3.
Definition s3_properties.h:92
constexpr std::array< std::string_view, 4 > kS3Schemes
URI schemes served by the Arrow S3 FileIO, lower-case.
Definition s3_properties.h:65
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:69
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:80
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:56
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 MinIO)
Definition s3_properties.h:50
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:54
static constexpr std::string_view kEndpoint
Custom endpoint override (for MinIO, LocalStack, etc.)
Definition s3_properties.h:48
static constexpr std::string_view kSslEnabled
Whether SSL is enabled.
Definition s3_properties.h:52
static constexpr std::string_view kClientRegion
AWS region, standard Iceberg client property.
Definition s3_properties.h:46