hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [5/6] hbase git commit: HBASE-16710 Add ZStandard Codec to Compression.java
Date Thu, 05 Jan 2017 18:57:35 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/3cbc5cc9
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/3cbc5cc9
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/3cbc5cc9

Branch: refs/heads/branch-1.1
Commit: 3cbc5cc9ebbd2d0448e013f8ad7fbde28220c602
Parents: 63d8186
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:45 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/3cbc5cc9/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 8a349db..62cc3a4 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 Configuration conf;

http://git-wip-us.apache.org/repos/asf/hbase/blob/3cbc5cc9/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 b65337e..7df29a9 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