1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#include "contrib/libs/apache/arrow_next/cpp/src/arrow/config.h"
#include <cstdint>
#include "contrib/libs/apache/arrow_next/src/arrow/util/config.h"
#include "contrib/libs/apache/arrow_next/src/arrow/util/config_internal.h"
#include "contrib/libs/apache/arrow_next/cpp/src/arrow/util/cpu_info.h"
#include "contrib/libs/apache/arrow_next/cpp/src/arrow/vendored/datetime.h"
namespace arrow20 {
using internal::CpuInfo;
namespace {
const BuildInfo kBuildInfo = {
// clang-format off
ARROW_VERSION,
ARROW_VERSION_MAJOR,
ARROW_VERSION_MINOR,
ARROW_VERSION_PATCH,
ARROW_VERSION_STRING,
ARROW_SO_VERSION,
ARROW_FULL_SO_VERSION,
ARROW_CXX_COMPILER_ID,
ARROW_CXX_COMPILER_VERSION,
ARROW_CXX_COMPILER_FLAGS,
ARROW_GIT_ID,
ARROW_GIT_DESCRIPTION,
ARROW_PACKAGE_KIND,
ARROW_BUILD_TYPE,
// clang-format on
};
template <typename QueryFlagFunction>
std::string MakeSimdLevelString(QueryFlagFunction&& query_flag) {
if (query_flag(CpuInfo::AVX512)) {
return "avx512";
} else if (query_flag(CpuInfo::AVX2)) {
return "avx2";
} else if (query_flag(CpuInfo::AVX)) {
return "avx";
} else if (query_flag(CpuInfo::SSE4_2)) {
return "sse4_2";
} else {
return "none";
}
}
std::optional<std::string> timezone_db_path;
}; // namespace
const BuildInfo& GetBuildInfo() { return kBuildInfo; }
RuntimeInfo GetRuntimeInfo() {
RuntimeInfo info;
auto cpu_info = CpuInfo::GetInstance();
info.simd_level =
MakeSimdLevelString([&](int64_t flags) { return cpu_info->IsSupported(flags); });
info.detected_simd_level =
MakeSimdLevelString([&](int64_t flags) { return cpu_info->IsDetected(flags); });
info.using_os_timezone_db = USE_OS_TZDB;
#if !USE_OS_TZDB
info.timezone_db_path = timezone_db_path;
#else
info.timezone_db_path = std::optional<std::string>();
#endif
return info;
}
Status Initialize(const GlobalOptions& options) noexcept {
if (options.timezone_db_path.has_value()) {
#if !USE_OS_TZDB
try {
arrow20_vendored::date::set_install(options.timezone_db_path.value());
arrow20_vendored::date::reload_tzdb();
} catch (const std::runtime_error& e) {
return Status::IOError(e.what());
}
timezone_db_path = options.timezone_db_path.value();
#else
return Status::Invalid(
"Arrow was set to use OS timezone database at compile time, "
"so a downloaded database cannot be provided at runtime.");
#endif // !USE_OS_TZDB
}
return Status::OK();
}
} // namespace arrow20
|