This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 63a7e41e176 [chore](be) Add default timezone files (#25097) (#26255)
63a7e41e176 is described below
commit 63a7e41e1768ecf5f531321ad6a564e9b27150a1
Author: zclllyybb <[email protected]>
AuthorDate: Thu Nov 2 14:08:08 2023 +0800
[chore](be) Add default timezone files (#25097) (#26255)
---
.gitignore | 1 +
be/src/common/config.cpp | 3 +++
be/src/common/config.h | 3 +++
be/src/util/timezone_utils.cpp | 15 ++++++++++-----
build.sh | 7 +++++++
resource/zoneinfo.tar.gz | Bin 0 -> 671860 bytes
6 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/.gitignore b/.gitignore
index d180a0cd9a0..e5cb6303adb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -92,6 +92,7 @@ be/tags
be/test/olap/test_data/tablet_meta_test.hdr
be/.devcontainer/
be/src/apache-orc/
+zoneinfo/
## tools
tools/ssb-tools/ssb-data/
diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp
index 0a7d92f5da7..6d65569fd28 100644
--- a/be/src/common/config.cpp
+++ b/be/src/common/config.cpp
@@ -1088,6 +1088,9 @@ DEFINE_Bool(exit_on_exception, "false");
DEFINE_Bool(ignore_always_true_predicate_for_segment, "true");
+// Dir of default timezone files
+DEFINE_String(default_tzfiles_path, "${DORIS_HOME}/zoneinfo");
+
// clang-format off
#ifdef BE_TEST
// test s3
diff --git a/be/src/common/config.h b/be/src/common/config.h
index d04fdbe9ed0..8ed78b64962 100644
--- a/be/src/common/config.h
+++ b/be/src/common/config.h
@@ -1145,6 +1145,9 @@ DECLARE_mBool(exit_on_exception);
// Remove predicate that is always true for a segment.
DECLARE_Bool(ignore_always_true_predicate_for_segment);
+// Dir of default timezone files
+DECLARE_String(default_tzfiles_path);
+
#ifdef BE_TEST
// test s3
DECLARE_String(test_s3_resource);
diff --git a/be/src/util/timezone_utils.cpp b/be/src/util/timezone_utils.cpp
index a90f30820a3..d3f6ff9af4c 100644
--- a/be/src/util/timezone_utils.cpp
+++ b/be/src/util/timezone_utils.cpp
@@ -36,6 +36,7 @@
#include <shared_mutex>
#include <string>
+#include "common/config.h"
#include "common/exception.h"
#include "common/logging.h"
@@ -77,8 +78,10 @@ void TimezoneUtils::load_timezone_names() {
path += '/';
if (!std::filesystem::exists(path)) {
- LOG_WARNING("Cannot find system tzfile. Abandon to preload timezone
name cache.");
- return;
+ LOG_WARNING("Cannot find system tzfile. Use default instead.");
+ path = config::default_tzfiles_path + '/';
+ CHECK(std::filesystem::exists(path))
+ << "Can't find system tzfiles or default tzfiles neither.";
}
auto path_prefix_len = path.size();
@@ -236,10 +239,12 @@ void TimezoneUtils::load_timezones_to_cache() {
base_str += tzdir;
base_str += '/';
- const auto root_path = std::filesystem::path {base_str};
+ auto root_path = std::filesystem::path {base_str};
if (!std::filesystem::exists(root_path)) {
- LOG_WARNING("Cannot find system tzfile. Abandon to preload timezone
cache.");
- return;
+ LOG_WARNING("Cannot find system tzfile. Use default instead.");
+ root_path = config::default_tzfiles_path + '/';
+ CHECK(std::filesystem::exists(root_path))
+ << "Can't find system tzfiles or default tzfiles neither.";
}
std::set<std::string> ignore_paths = {"posix", "right"}; // duplications
diff --git a/build.sh b/build.sh
index d76717b383f..f5bd47eb9a5 100755
--- a/build.sh
+++ b/build.sh
@@ -95,6 +95,7 @@ clean_be() {
rm -rf "${CMAKE_BUILD_DIR}"
rm -rf "${DORIS_HOME}/be/output"
+ rm -rf "${DORIS_HOME}/zoneinfo"
popd
}
@@ -627,6 +628,12 @@ if [[ "${OUTPUT_BE_BINARY}" -eq 1 ]]; then
cp -r -p "${DORIS_HOME}/be/output/bin"/* "${DORIS_OUTPUT}/be/bin"/
cp -r -p "${DORIS_HOME}/be/output/conf"/* "${DORIS_OUTPUT}/be/conf"/
cp -r -p "${DORIS_HOME}/be/output/dict" "${DORIS_OUTPUT}/be/"
+ if [[ ! -r "${DORIS_HOME}/zoneinfo/Africa/Abidjan" ]]; then
+ rm -rf "${DORIS_HOME}/zoneinfo"
+ echo "Generating zoneinfo files"
+ tar -xzf "${DORIS_HOME}/resource/zoneinfo.tar.gz" -C "${DORIS_HOME}"/
+ fi
+ cp -r -p "${DORIS_HOME}/zoneinfo" "${DORIS_OUTPUT}/be/"
if [[ -d "${DORIS_THIRDPARTY}/installed/lib/hadoop_hdfs/" ]]; then
cp -r -p "${DORIS_THIRDPARTY}/installed/lib/hadoop_hdfs/"
"${DORIS_OUTPUT}/be/lib/"
diff --git a/resource/zoneinfo.tar.gz b/resource/zoneinfo.tar.gz
new file mode 100644
index 00000000000..db010ccce99
Binary files /dev/null and b/resource/zoneinfo.tar.gz differ
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]