Search in sources :

Example 1 with PrefixTreeBlockMeta

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);
}
Also used : PrefixTreeEncoder(org.apache.hadoop.hbase.codec.prefixtree.encode.PrefixTreeEncoder) PrefixTreeArraySearcher(org.apache.hadoop.hbase.codec.prefixtree.decode.PrefixTreeArraySearcher) KeyValue(org.apache.hadoop.hbase.KeyValue) SingleByteBuff(org.apache.hadoop.hbase.nio.SingleByteBuff) PrefixTreeBlockMeta(org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeBlockMeta) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteBuffer(java.nio.ByteBuffer) Before(org.junit.Before)

Example 2 with PrefixTreeBlockMeta

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));
}
Also used : PrefixTreeBlockMeta(org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeBlockMeta) SingleByteBuff(org.apache.hadoop.hbase.nio.SingleByteBuff) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 3 with PrefixTreeBlockMeta

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;
}
Also used : PrefixTreeBlockMeta(org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeBlockMeta)

Example 4 with PrefixTreeBlockMeta

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;
}
Also used : PrefixTreeBlockMeta(org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeBlockMeta)

Aggregations

PrefixTreeBlockMeta (org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeBlockMeta)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ByteBuffer (java.nio.ByteBuffer)2 SingleByteBuff (org.apache.hadoop.hbase.nio.SingleByteBuff)2 KeyValue (org.apache.hadoop.hbase.KeyValue)1 PrefixTreeArraySearcher (org.apache.hadoop.hbase.codec.prefixtree.decode.PrefixTreeArraySearcher)1 PrefixTreeEncoder (org.apache.hadoop.hbase.codec.prefixtree.encode.PrefixTreeEncoder)1 Before (org.junit.Before)1 Test (org.junit.Test)1