use of org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeBlockMeta in project hbase by apache.
the class TestRowEncoder method compile.
@Before
public void compile() throws IOException {
// Always run with tags. But should also ensure that KVs without tags work fine
os = new ByteArrayOutputStream(1 << 20);
encoder = new PrefixTreeEncoder(os, includeMemstoreTS);
inputKvs = rows.getInputs();
for (KeyValue kv : inputKvs) {
encoder.write(kv);
}
encoder.flush();
totalBytes = encoder.getTotalBytes();
blockMetaWriter = encoder.getBlockMeta();
outputBytes = os.toByteArray();
// start reading, but save the assertions for @Test methods
ByteBuffer out = ByteBuffer.allocateDirect(outputBytes.length);
ByteBufferUtils.copyFromArrayToBuffer(out, outputBytes, 0, outputBytes.length);
out.position(0);
buffer = new SingleByteBuff(out);
blockMetaReader = new PrefixTreeBlockMeta(buffer);
searcher = new PrefixTreeArraySearcher(blockMetaReader, blockMetaReader.getRowTreeDepth(), blockMetaReader.getMaxRowLength(), blockMetaReader.getMaxQualifierLength(), blockMetaReader.getMaxTagsLength());
searcher.initOnBlock(blockMetaReader, buffer, includeMemstoreTS);
}
use of org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeBlockMeta in project hbase by apache.
the class TestBlockMeta method testStreamSerialization.
@Test
public void testStreamSerialization() throws IOException {
PrefixTreeBlockMeta original = createSample();
ByteArrayOutputStream os = new ByteArrayOutputStream(10000);
original.writeVariableBytesToOutputStream(os);
ByteBuffer buffer = ByteBuffer.wrap(os.toByteArray());
PrefixTreeBlockMeta roundTripped = new PrefixTreeBlockMeta(new SingleByteBuff(buffer));
Assert.assertTrue(original.equals(roundTripped));
}
use of org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeBlockMeta in project hbase by apache.
the class TestBlockMeta method createSample.
private static PrefixTreeBlockMeta createSample() {
PrefixTreeBlockMeta m = new PrefixTreeBlockMeta();
m.setNumMetaBytes(0);
m.setNumKeyValueBytes(3195);
m.setNumRowBytes(0);
m.setNumFamilyBytes(3);
m.setNumQualifierBytes(12345);
m.setNumTagsBytes(50);
m.setNumTimestampBytes(23456);
m.setNumMvccVersionBytes(5);
m.setNumValueBytes(34567);
m.setNextNodeOffsetWidth(3);
m.setFamilyOffsetWidth(1);
m.setQualifierOffsetWidth(2);
m.setTagsOffsetWidth(2);
m.setTimestampIndexWidth(1);
m.setMvccVersionIndexWidth(2);
m.setValueOffsetWidth(8);
m.setValueLengthWidth(3);
m.setRowTreeDepth(11);
m.setMaxRowLength(200);
m.setMaxQualifierLength(50);
m.setMaxTagsLength(40);
m.setMinTimestamp(1318966363481L);
m.setTimestampDeltaWidth(3);
m.setMinMvccVersion(100L);
m.setMvccVersionDeltaWidth(4);
m.setAllSameType(false);
m.setAllTypes(KeyValue.Type.Delete.getCode());
m.setNumUniqueRows(88);
m.setNumUniqueFamilies(1);
m.setNumUniqueQualifiers(56);
m.setNumUniqueTags(5);
return m;
}
use of org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeBlockMeta in project hbase by apache.
the class DecoderFactory method ensureArraySearcherValid.
/**************************** helper ******************************/
public static PrefixTreeArraySearcher ensureArraySearcherValid(ByteBuff buffer, PrefixTreeArraySearcher searcher, boolean includeMvccVersion) {
if (searcher == null) {
PrefixTreeBlockMeta blockMeta = new PrefixTreeBlockMeta(buffer);
searcher = new PrefixTreeArraySearcher(blockMeta, blockMeta.getRowTreeDepth(), blockMeta.getMaxRowLength(), blockMeta.getMaxQualifierLength(), blockMeta.getMaxTagsLength());
searcher.initOnBlock(blockMeta, buffer, includeMvccVersion);
return searcher;
}
PrefixTreeBlockMeta blockMeta = searcher.getBlockMeta();
blockMeta.initOnBlock(buffer);
if (!searcher.areBuffersBigEnough()) {
int maxRowTreeStackNodes = Math.max(blockMeta.getRowTreeDepth(), searcher.getMaxRowTreeStackNodes());
int rowBufferLength = Math.max(blockMeta.getMaxRowLength(), searcher.getRowBufferLength());
int qualifierBufferLength = Math.max(blockMeta.getMaxQualifierLength(), searcher.getQualifierBufferLength());
int tagBufferLength = Math.max(blockMeta.getMaxTagsLength(), searcher.getTagBufferLength());
searcher = new PrefixTreeArraySearcher(blockMeta, maxRowTreeStackNodes, rowBufferLength, qualifierBufferLength, tagBufferLength);
}
//this is where we parse the BlockMeta
searcher.initOnBlock(blockMeta, buffer, includeMvccVersion);
return searcher;
}
Aggregations