orc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xndai <...@git.apache.org>
Subject [GitHub] orc pull request #142: [ORC-218] Cache timezone information in the library.
Date Mon, 31 Jul 2017 22:07:15 GMT
Github user xndai commented on a diff in the pull request:

    https://github.com/apache/orc/pull/142#discussion_r130475038
  
    --- 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 --
    
    why don't we pre populate the whole time zone map so you don't need to acquire a mutex
every time accessing the map?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message