[ 
https://issues.apache.org/jira/browse/ORC-218?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16113044#comment-16113044
 ] 

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_r131192257
  
    --- Diff: c++/src/Timezone.cc ---
    @@ -735,18 +739,36 @@ namespace orc {
        * Get the local timezone.
        */
       const Timezone& getLocalTimezone() {
    +#ifdef TZ_DB_STATIC_TZ
    +#define TZ_STR(x) #x
    +    return getTimezoneByName(TZ_STR(TZ_DB_STATIC_TZ));
    +#else
         return getTimezoneByFilename(LOCAL_TIMEZONE);
    +#endif
       }
     
       /**
        * Get a timezone by name (eg. America/Los_Angeles).
        * Results are cached.
        */
       const Timezone& getTimezoneByName(const std::string& zone) {
    +#ifdef USE_TZ_DB
    +    {
    +      std::lock_guard<std::mutex> timezone_lock(timezone_mutex);
    +      std::map<std::string, std::shared_ptr<Timezone> >::iterator itr =
    +          timezoneCache.find(zone);
    +      if (itr != timezoneCache.end()) {
    +        return *(itr->second).get();
    +      }
    +      timezoneCache[zone] = std::shared_ptr<Timezone>(new 
TimezoneImpl(zone, TZ_DATABASE[zone]));
    --- 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)

Reply via email to