Search in sources :

Example 1 with CollectionBackedScanner

use of org.apache.hadoop.hbase.util.CollectionBackedScanner in project hbase by apache.

the class TestPrefixTreeEncoding method verifySeeking.

private void verifySeeking(EncodedSeeker encodeSeeker, ByteBuffer encodedData, int batchId) {
    List<KeyValue> kvList = new ArrayList<>();
    for (int i = 0; i < NUM_ROWS_PER_BATCH; ++i) {
        kvList.clear();
        encodeSeeker.setCurrentBuffer(new SingleByteBuff(encodedData));
        KeyValue firstOnRow = KeyValueUtil.createFirstOnRow(getRowKey(batchId, i));
        encodeSeeker.seekToKeyInBlock(new KeyValue.KeyOnlyKeyValue(firstOnRow.getBuffer(), firstOnRow.getKeyOffset(), firstOnRow.getKeyLength()), false);
        boolean hasMoreOfEncodeScanner = encodeSeeker.next();
        CollectionBackedScanner collectionScanner = new CollectionBackedScanner(this.kvset);
        boolean hasMoreOfCollectionScanner = collectionScanner.seek(firstOnRow);
        if (hasMoreOfEncodeScanner != hasMoreOfCollectionScanner) {
            dumpInputKVSet();
            fail("Get error result after seeking " + firstOnRow);
        }
        if (hasMoreOfEncodeScanner) {
            if (CellComparator.COMPARATOR.compare(encodeSeeker.getCell(), collectionScanner.peek()) != 0) {
                dumpInputKVSet();
                fail("Expected " + collectionScanner.peek() + " actual " + encodeSeeker.getCell() + ", after seeking " + firstOnRow);
            }
        }
    }
}
Also used : KeyValue(org.apache.hadoop.hbase.KeyValue) ArrayList(java.util.ArrayList) SingleByteBuff(org.apache.hadoop.hbase.nio.SingleByteBuff) CollectionBackedScanner(org.apache.hadoop.hbase.util.CollectionBackedScanner)

Aggregations

ArrayList (java.util.ArrayList)1 KeyValue (org.apache.hadoop.hbase.KeyValue)1 SingleByteBuff (org.apache.hadoop.hbase.nio.SingleByteBuff)1 CollectionBackedScanner (org.apache.hadoop.hbase.util.CollectionBackedScanner)1