hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [4/6] hbase git commit: HBASE-16710 Add ZStandard Codec to Compression.java
Date Thu, 05 Jan 2017 18:57:34 GMT
HBASE-16710 Add ZStandard Codec to Compression.java

Signed-off-by: Andrew Purtell <apurtell@apache.org>


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

Branch: refs/heads/branch-1.2
Commit: 2e344a7c91df14f14aecc74c5c430f73c92ed7c6
Parents: 601518a
Author: rahul gidwani <rgidwani@salesforce.com>
Authored: Tue Sep 27 10:24:52 2016 -0700
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Thu Jan 5 10:47:33 2017 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/io/compress/Compression.java   | 27 ++++++++++++++++++++
 .../hadoop/hbase/util/TestCompressionTest.java  |  2 ++
 2 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/2e344a7c/hbase-common/src/main/java/org/apache/hadoop/hbase/io/compress/Compression.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/compress/Compression.java
b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/compress/Compression.java
index c6ebff5..a927dc4 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/compress/Compression.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/compress/Compression.java
@@ -235,6 +235,33 @@ public final class Compression {
           throw new RuntimeException(e);
         }
       }
+  },
+  ZSTD("zstd") {
+    // Use base type to avoid compile-time dependencies.
+    private volatile transient CompressionCodec zStandardCodec;
+    private transient Object lock = new Object();
+
+    @Override
+    CompressionCodec getCodec(Configuration conf) {
+      if (zStandardCodec == null) {
+        synchronized (lock) {
+          if (zStandardCodec == null) {
+            zStandardCodec = buildCodec(conf);
+          }
+        }
+      }
+      return zStandardCodec;
+    }
+
+    private CompressionCodec buildCodec(Configuration conf) {
+      try {
+        Class<?> externalCodec =
+            getClassLoaderForCodec().loadClass("org.apache.hadoop.io.compress.ZStandardCodec");
+        return (CompressionCodec) ReflectionUtils.newInstance(externalCodec, conf);
+      } catch (ClassNotFoundException e) {
+        throw new RuntimeException(e);
+      }
+    }
   };
 
     private final transient Configuration conf; // FindBugs: SE_BAD_FIELD so just made it
transient

http://git-wip-us.apache.org/repos/asf/hbase/blob/2e344a7c/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestCompressionTest.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestCompressionTest.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestCompressionTest.java
index 682b066..f9a0211 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestCompressionTest.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestCompressionTest.java
@@ -74,12 +74,14 @@ public class TestCompressionTest {
       nativeCodecTest("LZO", "lzo2", "com.hadoop.compression.lzo.LzoCodec");
       nativeCodecTest("LZ4", null, "org.apache.hadoop.io.compress.Lz4Codec");
       nativeCodecTest("SNAPPY", "snappy", "org.apache.hadoop.io.compress.SnappyCodec");
+      nativeCodecTest("ZSTD", "zstd", "org.apache.hadoop.io.compress.ZStandardCodec");
     } else {
       // Hadoop nativelib is not available
       LOG.debug("Native code not loaded");
       assertFalse(CompressionTest.testCompression("LZO"));
       assertFalse(CompressionTest.testCompression("LZ4"));
       assertFalse(CompressionTest.testCompression("SNAPPY"));
+      assertFalse(CompressionTest.testCompression("ZSTD"));
     }
   }
 


Mime
View raw message