You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by om...@apache.org on 2017/01/04 17:14:22 UTC

[1/2] orc git commit: ORC-122. Use unique_ptr to wrap Timezone instances in the cache.

Repository: orc
Updated Branches:
  refs/heads/branch-1.2 6ef73189d -> 9860c2ba7


ORC-122. Use unique_ptr to wrap Timezone instances in the cache.

Fixes #73

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


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

Branch: refs/heads/branch-1.2
Commit: d43c862ccc609daab8ece5797ea7ac84dba7734b
Parents: 6ef7318
Author: Deepak Majeti <de...@hpe.com>
Authored: Fri Dec 16 12:27:12 2016 -0500
Committer: Owen O'Malley <om...@apache.org>
Committed: Fri Dec 16 11:35:58 2016 -0800

----------------------------------------------------------------------
 c++/src/Timezone.cc | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/orc/blob/d43c862c/c++/src/Timezone.cc
----------------------------------------------------------------------
diff --git a/c++/src/Timezone.cc b/c++/src/Timezone.cc
index 73026d2..4b82034 100644
--- a/c++/src/Timezone.cc
+++ b/c++/src/Timezone.cc
@@ -651,7 +651,7 @@ namespace orc {
     DIAGNOSTIC_IGNORE("-Wexit-time-destructors")
   #endif
   static std::mutex timezone_mutex;
-  static std::map<std::string, Timezone*> timezoneCache;
+  static std::map<std::string, std::unique_ptr<Timezone> > timezoneCache;
   DIAGNOSTIC_POP
 
   Timezone::~Timezone() {
@@ -691,10 +691,10 @@ namespace orc {
   const Timezone& getTimezoneByFilename(const std::string& filename) {
     // ORC-110
     std::lock_guard<std::mutex> timezone_lock(timezone_mutex);
-    std::map<std::string, Timezone*>::iterator itr =
+    std::map<std::string, std::unique_ptr<Timezone> >::iterator itr =
       timezoneCache.find(filename);
     if (itr != timezoneCache.end()) {
-      return *(itr->second);
+      return *(itr->second).get();
     }
     int in = open(filename.c_str(), O_RDONLY);
     if (in == -1) {
@@ -729,9 +729,8 @@ namespace orc {
       err << "failed to close " << filename << " - " << strerror(errno);
       throw TimezoneError(err.str());
     }
-    Timezone* result = new TimezoneImpl(filename, buffer);
-    timezoneCache[filename] = result;
-    return *result;
+    timezoneCache[filename].reset(new TimezoneImpl(filename, buffer));
+    return *timezoneCache[filename].get();
   }
 
   /**


[2/2] orc git commit: ORC-125. Fix deserialization of WriterVersion so that future versions don't cause runtime errors. (omalley)

Posted by om...@apache.org.
ORC-125. Fix deserialization of WriterVersion so that future versions don't cause
runtime errors. (omalley)

Fixes #75

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


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

Branch: refs/heads/branch-1.2
Commit: 9860c2ba7566a8cdae7f5e0517312afe6c38fc66
Parents: d43c862
Author: Owen O'Malley <om...@apache.org>
Authored: Tue Jan 3 09:09:05 2017 -0800
Committer: Owen O'Malley <om...@apache.org>
Committed: Wed Jan 4 09:12:02 2017 -0800

----------------------------------------------------------------------
 java/core/src/java/org/apache/orc/OrcFile.java        | 14 +++++++++++++-
 .../src/test/org/apache/orc/TestVectorOrcFile.java    |  7 +++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/orc/blob/9860c2ba/java/core/src/java/org/apache/orc/OrcFile.java
----------------------------------------------------------------------
diff --git a/java/core/src/java/org/apache/orc/OrcFile.java b/java/core/src/java/org/apache/orc/OrcFile.java
index 6b2d48e..7551c2e 100644
--- a/java/core/src/java/org/apache/orc/OrcFile.java
+++ b/java/core/src/java/org/apache/orc/OrcFile.java
@@ -141,8 +141,16 @@ public class OrcFile {
       }
     }
 
+    /**
+     * Convert the integer from OrcProto.PostScript.writerVersion
+     * to the enumeration with unknown versions being mapped to FUTURE.
+     * @param val the serialized writer version
+     * @return the corresponding enumeration value
+     */
     public static WriterVersion from(int val) {
-      if (val == FUTURE.id) return FUTURE; // Special handling for the magic value.
+      if (val >= values.length) {
+        return FUTURE;
+      }
       return values[val];
     }
 
@@ -150,6 +158,10 @@ public class OrcFile {
       return id >= other.id;
     }
   }
+
+  /**
+   * The WriterVersion for this version of the software.
+   */
   public static final WriterVersion CURRENT_WRITER = WriterVersion.ORC_101;
 
   public enum EncodingStrategy {

http://git-wip-us.apache.org/repos/asf/orc/blob/9860c2ba/java/core/src/test/org/apache/orc/TestVectorOrcFile.java
----------------------------------------------------------------------
diff --git a/java/core/src/test/org/apache/orc/TestVectorOrcFile.java b/java/core/src/test/org/apache/orc/TestVectorOrcFile.java
index 5ef0ced..af31b4d 100644
--- a/java/core/src/test/org/apache/orc/TestVectorOrcFile.java
+++ b/java/core/src/test/org/apache/orc/TestVectorOrcFile.java
@@ -2923,4 +2923,11 @@ public class TestVectorOrcFile {
     assertFalse(rows.nextBatch(batch));
     rows.close();
   }
+
+  @Test
+  public void testWriterVersion() throws Exception {
+    assertEquals(OrcFile.WriterVersion.FUTURE, OrcFile.WriterVersion.from(99));
+    assertEquals(OrcFile.WriterVersion.ORIGINAL, OrcFile.WriterVersion.from(0));
+    assertEquals(OrcFile.WriterVersion.HIVE_4243, OrcFile.WriterVersion.from(2));
+  }
 }