HBASE-5838. Add an LZ4 compression option to HFile

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1350844 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Kyle Purtell 2012-06-16 02:56:24 +00:00
parent ea1bdb75b6
commit e796407da8
2 changed files with 23 additions and 2 deletions

View File

@ -180,6 +180,25 @@ 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;

View File

@ -281,12 +281,14 @@ public class TestHFile extends HBaseTestCase {
}
/**
* 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 {