Search in sources :

Example 1 with PrefixTreeArraySearcher

use of org.apache.hadoop.hbase.codec.prefixtree.decode.PrefixTreeArraySearcher 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 PrefixTreeArraySearcher

use of org.apache.hadoop.hbase.codec.prefixtree.decode.PrefixTreeArraySearcher in project hbase by apache.

the class PrefixTreeCodec method getFirstKeyCellInBlock.

@Override
public Cell getFirstKeyCellInBlock(ByteBuff block) {
    block.rewind();
    PrefixTreeArraySearcher searcher = null;
    try {
        // should i includeMemstoreTS (second argument)?  i think PrefixKeyDeltaEncoder is, so i will
        searcher = DecoderFactory.checkOut(block, true);
        if (!searcher.positionAtFirstCell()) {
            return null;
        }
        return searcher.current();
    } finally {
        DecoderFactory.checkIn(searcher);
    }
}
Also used : PrefixTreeArraySearcher(org.apache.hadoop.hbase.codec.prefixtree.decode.PrefixTreeArraySearcher)

Aggregations

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