HBASE-7936 Undo prefix-tree module as dependency for mapreduce and for DataBlockEncoding (Ted Yu)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1451669 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2013-03-01 17:54:27 +00:00
parent 0a0d9310c3
commit 1046174cc8
1 changed files with 13 additions and 8 deletions

View File

@ -36,16 +36,17 @@ public enum DataBlockEncoding {
/** Disable data block encoding. */ /** Disable data block encoding. */
NONE(0, null), NONE(0, null),
// id 1 is reserved for the BITSET algorithm to be added later // id 1 is reserved for the BITSET algorithm to be added later
PREFIX(2, createEncoder("org.apache.hadoop.hbase.io.encoding.PrefixKeyDeltaEncoder")), PREFIX(2, "org.apache.hadoop.hbase.io.encoding.PrefixKeyDeltaEncoder"),
DIFF(3, createEncoder("org.apache.hadoop.hbase.io.encoding.DiffKeyDeltaEncoder")), DIFF(3, "org.apache.hadoop.hbase.io.encoding.DiffKeyDeltaEncoder"),
FAST_DIFF(4, createEncoder("org.apache.hadoop.hbase.io.encoding.FastDiffDeltaEncoder")), FAST_DIFF(4, "org.apache.hadoop.hbase.io.encoding.FastDiffDeltaEncoder"),
// id 5 is reserved for the COPY_KEY algorithm for benchmarking // id 5 is reserved for the COPY_KEY algorithm for benchmarking
// COPY_KEY(5, createEncoder("org.apache.hadoop.hbase.io.encoding.CopyKeyDataBlockEncoder")), // COPY_KEY(5, "org.apache.hadoop.hbase.io.encoding.CopyKeyDataBlockEncoder"),
PREFIX_TREE(6, createEncoder("org.apache.hbase.codec.prefixtree.PrefixTreeCodec")); PREFIX_TREE(6, "org.apache.hbase.codec.prefixtree.PrefixTreeCodec");
private final short id; private final short id;
private final byte[] idInBytes; private final byte[] idInBytes;
private final DataBlockEncoder encoder; private DataBlockEncoder encoder;
private final String encoderCls;
public static final int ID_SIZE = Bytes.SIZEOF_SHORT; public static final int ID_SIZE = Bytes.SIZEOF_SHORT;
@ -66,7 +67,7 @@ public enum DataBlockEncoding {
} }
} }
private DataBlockEncoding(int id, DataBlockEncoder encoder) { private DataBlockEncoding(int id, String encoderClsName) {
if (id < Short.MIN_VALUE || id > Short.MAX_VALUE) { if (id < Short.MIN_VALUE || id > Short.MAX_VALUE) {
throw new AssertionError( throw new AssertionError(
"Data block encoding algorithm id is out of range: " + id); "Data block encoding algorithm id is out of range: " + id);
@ -79,7 +80,7 @@ public enum DataBlockEncoding {
throw new RuntimeException("Unexpected length of encoder ID byte " + throw new RuntimeException("Unexpected length of encoder ID byte " +
"representation: " + Bytes.toStringBinary(idInBytes)); "representation: " + Bytes.toStringBinary(idInBytes));
} }
this.encoder = encoder; this.encoderCls = encoderClsName;
} }
/** /**
@ -122,6 +123,10 @@ public enum DataBlockEncoding {
* selected. * selected.
*/ */
public DataBlockEncoder getEncoder() { public DataBlockEncoder getEncoder() {
if (encoder == null && id != 0) {
// lazily create the encoder
encoder = createEncoder(encoderCls);
}
return encoder; return encoder;
} }