hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r1350844 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/io/hfile/Compression.java test/java/org/apache/hadoop/hbase/io/hfile/TestHFile.java
Date Sat, 16 Jun 2012 02:56:25 GMT
Author: apurtell
Date: Sat Jun 16 02:56:24 2012
New Revision: 1350844

URL: http://svn.apache.org/viewvc?rev=1350844&view=rev
Log:
HBASE-5838. Add an LZ4 compression option to HFile

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/Compression.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFile.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/Compression.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/Compression.java?rev=1350844&r1=1350843&r2=1350844&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/Compression.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/Compression.java
Sat Jun 16 02:56:24 2012
@@ -180,7 +180,26 @@ public final class Compression {
           }
           return snappyCodec;
         }
-    };
+    },
+    LZ4("lz4") {
+      // Use base type to avoid compile-time dependencies.
+      private transient CompressionCodec lz4Codec;
+
+      @Override
+      CompressionCodec getCodec(Configuration conf) {
+        if (lz4Codec == null) {
+          try {
+            Class<?> externalCodec =
+                getClassLoaderForCodec().loadClass("org.apache.hadoop.io.compress.Lz4Codec");
+            lz4Codec = (CompressionCodec) ReflectionUtils.newInstance(externalCodec, 
+                conf);
+          } catch (ClassNotFoundException e) {
+            throw new RuntimeException(e);
+          }
+        }
+        return lz4Codec;
+      }
+  };
 
     private final Configuration conf;
     private final String compressName;

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFile.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFile.java?rev=1350844&r1=1350843&r2=1350844&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFile.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFile.java
Sat Jun 16 02:56:24 2012
@@ -281,12 +281,14 @@ public class TestHFile extends HBaseTest
   }
 
   /**
-   * Make sure the orginals for our compression libs doesn't change on us.
+   * Make sure the ordinals for our compression algorithms do not change on us.
    */
   public void testCompressionOrdinance() {
     assertTrue(Compression.Algorithm.LZO.ordinal() == 0);
     assertTrue(Compression.Algorithm.GZ.ordinal() == 1);
     assertTrue(Compression.Algorithm.NONE.ordinal() == 2);
+    assertTrue(Compression.Algorithm.SNAPPY.ordinal() == 3);
+    assertTrue(Compression.Algorithm.LZ4.ordinal() == 4);
   }
 
   public void testComparator() throws IOException {



Mime
View raw message