[
https://issues.apache.org/jira/browse/ORC-218?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16113019#comment-16113019
]
ASF GitHub Bot commented on ORC-218:
------------------------------------
Github user grundprinzip commented on a diff in the pull request:
https://github.com/apache/orc/pull/142#discussion_r131188652
--- Diff: c++/src/CMakeLists.txt ---
@@ -125,6 +125,83 @@ include_directories (
${LZ4_INCLUDE_DIRS}
)
+# To avoid reading the Timezone database from disk, we load the file
during the
+# build and inject them as binary into the library. This can increase the
size
+# of library but avoids doing system calls at runtime. The behavior can be
+# disabled by using the CMake flag NO_EMBEDDED_TZ_DB
+if (NOT DEFINED EMBEDDED_TZ_DB)
+ set(EMBEDDED_TZ_DB ON)
+endif()
+if (EMBEDDED_TZ_DB)
+ message(STATUS "Caching of timezone data enabled.")
+ set(DEFAULT_TIMEZONE_DIR "/usr/share/zoneinfo")
+
+ # Check if zone1970.tab is present, otherwise select zone.tab
+ # Parse zone tab to extract all availble zones
+ execute_process(COMMAND find ${DEFAULT_TIMEZONE_DIR} -type f
+ COMMAND grep -v "posix"
+ COMMAND grep -v "right"
+ COMMAND grep -v "tab"
+ RESULT_VARIABLE TZ_LIST_RC
+ OUTPUT_VARIABLE TZ_LIST_OUTPUT
+ ERROR_VARIABLE TZ_ERROR)
+
+ if (TZ_LIST_RC)
+ message(FATAL_ERROR "Could not parse Timezone database.")
+ endif()
+
+ set(FILE2ARRAY "${CMAKE_CURRENT_SOURCE_DIR}/../file2array.sh")
+
+ # For each zone generate a target
+ # Add each target to dependency on Timezone.cc
+ set(TZ_DEPS "")
--- End diff --
Done
> [C++] Cache timezone information in the library.
> ------------------------------------------------
>
> Key: ORC-218
> URL: https://issues.apache.org/jira/browse/ORC-218
> Project: ORC
> Issue Type: Improvement
> Reporter: Martin Grund
>
> Right now, for every lookup of a timezone, the library will go to disk and
> parse the timezone file. While the results are cached, doing these system
> calls should be avoided in environments with restricted system calls.
> I prepared a patch that will at build time load all the time zone files into
> the binary and instead of accessing disk for the TZ information will simply
> load the buffer from memory. In addition this allows the user to compile the
> library with a static timezone to be assumed for local use. This comes in
> handy to avoid yet another set of system calls to assume the local timezone.
> The feature can be controlled using the following CMake flags
> * NO_EMBEDED_TZ_DB - to turn it off, by default is on
> * STATIC_TZ=VAL - where val is a name of a timezone.
> I'll create a PR for code-review.
> Would be great if you could consider this patch.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)