hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject hbase git commit: HBASE-15881 Allow BZIP2 compression.
Date Thu, 02 Jun 2016 19:19:33 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 7e5d53087 -> fc890a2ec


HBASE-15881 Allow BZIP2 compression.


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

Branch: refs/heads/master
Commit: fc890a2ecb12c3c664ad00f8b2f8788dba04c71d
Parents: 7e5d530
Author: Lars Hofhansl <larsh@apache.org>
Authored: Thu Jun 2 12:19:02 2016 -0700
Committer: Lars Hofhansl <larsh@apache.org>
Committed: Thu Jun 2 12:19:02 2016 -0700

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


http://git-wip-us.apache.org/repos/asf/hbase/blob/fc890a2e/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 821b21f..6dc4190 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,7 +235,34 @@ public final class Compression {
           throw new RuntimeException(e);
         }
       }
-  };
+    },
+    BZIP2("bzip2") {
+      // Use base type to avoid compile-time dependencies.
+      private volatile transient CompressionCodec bzipCodec;
+      private transient Object lock = new Object();
+
+      @Override
+      CompressionCodec getCodec(Configuration conf) {
+        if (bzipCodec == null) {
+          synchronized (lock) {
+            if (bzipCodec == null) {
+              bzipCodec = buildCodec(conf);
+            }
+          }
+        }
+        return bzipCodec;
+      }
+
+      private CompressionCodec buildCodec(Configuration conf) {
+        try {
+          Class<?> externalCodec =
+              getClassLoaderForCodec().loadClass("org.apache.hadoop.io.compress.BZip2Codec");
+          return (CompressionCodec) ReflectionUtils.newInstance(externalCodec, conf);
+        } catch (ClassNotFoundException e) {
+          throw new RuntimeException(e);
+        }
+      }
+    };
 
     private final Configuration conf;
     private final String compressName;

http://git-wip-us.apache.org/repos/asf/hbase/blob/fc890a2e/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 43c7cfc..398f3f0 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
@@ -75,12 +75,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("BZIP2", "bzip2", "org.apache.hadoop.io.compress.BZip2Codec");
     } 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("BZIP2"));
     }
   }
 


Mime
View raw message