orc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject orc git commit: ORC-172 Replace unique_ptr with shared_ptr for timezone cache.
Date Tue, 25 Apr 2017 17:40:36 GMT
Repository: orc
Updated Branches:
  refs/heads/master ce5213b2a -> 4f9528c16


ORC-172 Replace unique_ptr with shared_ptr for timezone cache.

Fixes #109

Signed-off-by: Owen O'Malley <omalley@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/orc/repo
Commit: http://git-wip-us.apache.org/repos/asf/orc/commit/4f9528c1
Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/4f9528c1
Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/4f9528c1

Branch: refs/heads/master
Commit: 4f9528c16cef9635a917a7d9f736df579a6c6f66
Parents: ce5213b
Author: Deepak Majeti <deepak.majeti@hpe.com>
Authored: Mon Apr 17 07:51:05 2017 -0400
Committer: Owen O'Malley <omalley@apache.org>
Committed: Tue Apr 25 10:40:10 2017 -0700

----------------------------------------------------------------------
 c++/src/Timezone.cc      | 12 ++++++------
 c++/src/Timezone.hh      |  2 +-
 c++/test/TestTimezone.cc |  4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/orc/blob/4f9528c1/c++/src/Timezone.cc
----------------------------------------------------------------------
diff --git a/c++/src/Timezone.cc b/c++/src/Timezone.cc
index 4b82034..5ffec3c 100644
--- a/c++/src/Timezone.cc
+++ b/c++/src/Timezone.cc
@@ -461,8 +461,8 @@ namespace orc {
   /**
    * Parse the POSIX TZ string.
    */
-  std::unique_ptr<FutureRule> parseFutureRule(const std::string& ruleString) {
-    std::unique_ptr<FutureRule> result(new FutureRuleImpl());
+  std::shared_ptr<FutureRule> parseFutureRule(const std::string& ruleString) {
+    std::shared_ptr<FutureRule> result(new FutureRuleImpl());
     FutureRuleParser parser(ruleString,
                             dynamic_cast<FutureRuleImpl*>(result.get()));
     return result;
@@ -636,7 +636,7 @@ namespace orc {
     uint64_t ancientVariant;
 
     // the rule for future times
-    std::unique_ptr<FutureRule> futureRule;
+    std::shared_ptr<FutureRule> futureRule;
 
     // the last explicit transition after which we use the future rule
     int64_t lastTransition;
@@ -651,7 +651,7 @@ namespace orc {
     DIAGNOSTIC_IGNORE("-Wexit-time-destructors")
   #endif
   static std::mutex timezone_mutex;
-  static std::map<std::string, std::unique_ptr<Timezone> > timezoneCache;
+  static std::map<std::string, std::shared_ptr<Timezone> > timezoneCache;
   DIAGNOSTIC_POP
 
   Timezone::~Timezone() {
@@ -691,7 +691,7 @@ namespace orc {
   const Timezone& getTimezoneByFilename(const std::string& filename) {
     // ORC-110
     std::lock_guard<std::mutex> timezone_lock(timezone_mutex);
-    std::map<std::string, std::unique_ptr<Timezone> >::iterator itr =
+    std::map<std::string, std::shared_ptr<Timezone> >::iterator itr =
       timezoneCache.find(filename);
     if (itr != timezoneCache.end()) {
       return *(itr->second).get();
@@ -729,7 +729,7 @@ namespace orc {
       err << "failed to close " << filename << " - " << strerror(errno);
       throw TimezoneError(err.str());
     }
-    timezoneCache[filename].reset(new TimezoneImpl(filename, buffer));
+    timezoneCache[filename] = std::shared_ptr<Timezone>(new TimezoneImpl(filename,
buffer));
     return *timezoneCache[filename].get();
   }
 

http://git-wip-us.apache.org/repos/asf/orc/blob/4f9528c1/c++/src/Timezone.hh
----------------------------------------------------------------------
diff --git a/c++/src/Timezone.hh b/c++/src/Timezone.hh
index 1ed3edf..1cf04cf 100644
--- a/c++/src/Timezone.hh
+++ b/c++/src/Timezone.hh
@@ -116,7 +116,7 @@ namespace orc {
   /**
    * Parse the POSIX TZ string.
    */
-  std::unique_ptr<FutureRule> parseFutureRule(const std::string& ruleString);
+  std::shared_ptr<FutureRule> parseFutureRule(const std::string& ruleString);
 }
 
 #endif

http://git-wip-us.apache.org/repos/asf/orc/blob/4f9528c1/c++/test/TestTimezone.cc
----------------------------------------------------------------------
diff --git a/c++/test/TestTimezone.cc b/c++/test/TestTimezone.cc
index 15a72f3..88415cc 100644
--- a/c++/test/TestTimezone.cc
+++ b/c++/test/TestTimezone.cc
@@ -59,7 +59,7 @@ namespace orc {
    * Parse a future rule string and return the parsed rule as a string.
    */
   std::string stringifyRule(const std::string& ruleString) {
-    std::unique_ptr<FutureRule> rule = parseFutureRule(ruleString);
+    std::shared_ptr<FutureRule> rule = parseFutureRule(ruleString);
     std::stringstream buffer;
     rule->print(buffer);
     return buffer.str();
@@ -130,7 +130,7 @@ namespace orc {
   }
 
   TEST(TestTimezone, useFutureRule) {
-    std::unique_ptr<FutureRule> rule =
+    std::shared_ptr<FutureRule> rule =
       parseFutureRule("FOO8BAR,M3.2.0,M11.1.0");
     // 1970
     EXPECT_EQ("FOO", getZoneFromRule(rule.get(), "1970-01-01 00:00:00"));


Mime
View raw message