hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [1/6] hbase git commit: HBASE-16710 Add ZStandard Codec to Compression.java
Date Thu, 05 Jan 2017 18:57:31 GMT
Repository: hbase
Updated Branches:
  refs/heads/0.98 9c13a1c3d -> 010421d83
  refs/heads/branch-1 a9bac6a49 -> 667c5eb3a
  refs/heads/branch-1.1 63d8186d4 -> 3cbc5cc9e
  refs/heads/branch-1.2 601518abb -> 2e344a7c9
  refs/heads/branch-1.3 1829cd541 -> 8f0d0e78c
  refs/heads/master df98d8dcd -> 0f6c79eb1
Updated Tags:  refs/tags/rel/0.98.24 [created] c28c2f713


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/0f6c79eb
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/0f6c79eb
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/0f6c79eb

Branch: refs/heads/master
Commit: 0f6c79eb123e43133df4f4ba2a123029d62580dc
Parents: df98d8d
Author: rahul gidwani <rgidwani@salesforce.com>
Authored: Tue Sep 27 10:18:09 2016 -0700
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Thu Jan 5 10:46:55 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/0f6c79eb/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 6dc4190..8dfab44 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
@@ -262,6 +262,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/0f6c79eb/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 398f3f0..395c04d 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
@@ -76,6 +76,7 @@ public class TestCompressionTest {
       nativeCodecTest("LZ4", null, "org.apache.hadoop.io.compress.Lz4Codec");
       nativeCodecTest("SNAPPY", "snappy", "org.apache.hadoop.io.compress.SnappyCodec");
       nativeCodecTest("BZIP2", "bzip2", "org.apache.hadoop.io.compress.BZip2Codec");
+      nativeCodecTest("ZSTD", "zstd", "org.apache.hadoop.io.compress.ZStandardCodec");
     } else {
       // Hadoop nativelib is not available
       LOG.debug("Native code not loaded");
@@ -83,6 +84,7 @@ public class TestCompressionTest {
       assertFalse(CompressionTest.testCompression("LZ4"));
       assertFalse(CompressionTest.testCompression("SNAPPY"));
       assertFalse(CompressionTest.testCompression("BZIP2"));
+      assertFalse(CompressionTest.testCompression("ZSTD"));
     }
   }
 


Mime
View raw message