Search in sources :

Example 1 with CellScannerPosition

use of org.apache.hadoop.hbase.codec.prefixtree.scanner.CellScannerPosition in project hbase by apache.

the class TestRowDataTrivialWithTags method individualSearcherAssertions.

@Override
public void individualSearcherAssertions(CellSearcher searcher) {
    /**
     * The searcher should get a token mismatch on the "r" branch. Assert that
     * it skips not only rA, but rB as well.
     */
    KeyValue afterLast = KeyValueUtil.createFirstOnRow(Bytes.toBytes("zzz"));
    CellScannerPosition position = searcher.positionAtOrAfter(afterLast);
    Assert.assertEquals(CellScannerPosition.AFTER_LAST, position);
    Assert.assertNull(searcher.current());
}
Also used : KeyValue(org.apache.hadoop.hbase.KeyValue) CellScannerPosition(org.apache.hadoop.hbase.codec.prefixtree.scanner.CellScannerPosition)

Example 2 with CellScannerPosition

use of org.apache.hadoop.hbase.codec.prefixtree.scanner.CellScannerPosition in project hbase by apache.

the class TestRowDataDeeper method individualSearcherAssertions.

@Override
public void individualSearcherAssertions(CellSearcher searcher) {
    /**
     * The searcher should get a token mismatch on the "r" branch.  Assert that it skips not only
     * rA, but rB as well.
     */
    KeyValue cfcRow = KeyValueUtil.createFirstOnRow(Bytes.toBytes("cfc"));
    CellScannerPosition position = searcher.positionAtOrAfter(cfcRow);
    Assert.assertEquals(CellScannerPosition.AFTER, position);
    Assert.assertEquals(d.get(2), searcher.current());
    searcher.previous();
    Assert.assertEquals(d.get(1), searcher.current());
}
Also used : KeyValue(org.apache.hadoop.hbase.KeyValue) CellScannerPosition(org.apache.hadoop.hbase.codec.prefixtree.scanner.CellScannerPosition)

Example 3 with CellScannerPosition

use of org.apache.hadoop.hbase.codec.prefixtree.scanner.CellScannerPosition in project hbase by apache.

the class TestRowDataSearcherRowMiss method testBetween2and3.

private void testBetween2and3(CellSearcher searcher) {
    //reuse
    CellScannerPosition p;
    Cell betweenAAAndB = new KeyValue(AAA, cf, cq, ts - 2, v);
    //test exact
    Assert.assertFalse(searcher.positionAt(betweenAAAndB));
    //test atOrBefore
    p = searcher.positionAtOrBefore(betweenAAAndB);
    Assert.assertEquals(CellScannerPosition.BEFORE, p);
    Assert.assertTrue(CellUtil.equals(searcher.current(), d.get(2)));
    //test atOrAfter
    p = searcher.positionAtOrAfter(betweenAAAndB);
    Assert.assertEquals(CellScannerPosition.AFTER, p);
    Assert.assertTrue(CellUtil.equals(searcher.current(), d.get(3)));
}
Also used : KeyValue(org.apache.hadoop.hbase.KeyValue) CellScannerPosition(org.apache.hadoop.hbase.codec.prefixtree.scanner.CellScannerPosition) Cell(org.apache.hadoop.hbase.Cell)

Example 4 with CellScannerPosition

use of org.apache.hadoop.hbase.codec.prefixtree.scanner.CellScannerPosition in project hbase by apache.

the class TestRowDataSimple method individualSearcherAssertions.

@Override
public void individualSearcherAssertions(CellSearcher searcher) {
    // reuse
    CellScannerPosition p;
    searcher.resetToBeforeFirstEntry();
    // test first cell
    try {
        searcher.advance();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    Cell first = searcher.current();
    Assert.assertTrue(CellUtil.equals(d.get(0), first));
    // test first cell in second row
    Assert.assertTrue(searcher.positionAt(d.get(3)));
    Assert.assertTrue(CellUtil.equals(d.get(3), searcher.current()));
    Cell between4And5 = new KeyValue(rowB, cf, cq1, ts - 2, v0);
    // test exact
    Assert.assertFalse(searcher.positionAt(between4And5));
    // test atOrBefore
    p = searcher.positionAtOrBefore(between4And5);
    Assert.assertEquals(CellScannerPosition.BEFORE, p);
    Assert.assertTrue(CellUtil.equals(searcher.current(), d.get(4)));
    // test atOrAfter
    p = searcher.positionAtOrAfter(between4And5);
    Assert.assertEquals(CellScannerPosition.AFTER, p);
    Assert.assertTrue(CellUtil.equals(searcher.current(), d.get(5)));
    // test when key falls before first key in block
    Cell beforeFirst = new KeyValue(Bytes.toBytes("A"), cf, cq0, ts, v0);
    Assert.assertFalse(searcher.positionAt(beforeFirst));
    p = searcher.positionAtOrBefore(beforeFirst);
    Assert.assertEquals(CellScannerPosition.BEFORE_FIRST, p);
    p = searcher.positionAtOrAfter(beforeFirst);
    Assert.assertEquals(CellScannerPosition.AFTER, p);
    Assert.assertTrue(CellUtil.equals(searcher.current(), d.get(0)));
    Assert.assertEquals(d.get(0), searcher.current());
    // test when key falls after last key in block
    // must be lower case z
    Cell afterLast = new KeyValue(Bytes.toBytes("z"), cf, cq0, ts, v0);
    Assert.assertFalse(searcher.positionAt(afterLast));
    p = searcher.positionAtOrAfter(afterLast);
    Assert.assertEquals(CellScannerPosition.AFTER_LAST, p);
    p = searcher.positionAtOrBefore(afterLast);
    Assert.assertEquals(CellScannerPosition.BEFORE, p);
    Assert.assertTrue(CellUtil.equals(searcher.current(), CollectionUtils.getLast(d)));
}
Also used : KeyValue(org.apache.hadoop.hbase.KeyValue) CellScannerPosition(org.apache.hadoop.hbase.codec.prefixtree.scanner.CellScannerPosition) IOException(java.io.IOException) Cell(org.apache.hadoop.hbase.Cell)

Example 5 with CellScannerPosition

use of org.apache.hadoop.hbase.codec.prefixtree.scanner.CellScannerPosition in project hbase by apache.

the class TestRowDataTrivial method individualSearcherAssertions.

@Override
public void individualSearcherAssertions(CellSearcher searcher) {
    /**
     * The searcher should get a token mismatch on the "r" branch. Assert that it skips not only rA,
     * but rB as well.
     */
    KeyValue afterLast = KeyValueUtil.createFirstOnRow(Bytes.toBytes("zzz"));
    CellScannerPosition position = searcher.positionAtOrAfter(afterLast);
    Assert.assertEquals(CellScannerPosition.AFTER_LAST, position);
    Assert.assertNull(searcher.current());
}
Also used : KeyValue(org.apache.hadoop.hbase.KeyValue) CellScannerPosition(org.apache.hadoop.hbase.codec.prefixtree.scanner.CellScannerPosition)

Aggregations

KeyValue (org.apache.hadoop.hbase.KeyValue)8 CellScannerPosition (org.apache.hadoop.hbase.codec.prefixtree.scanner.CellScannerPosition)8 Cell (org.apache.hadoop.hbase.Cell)4 CellSearcher (org.apache.hadoop.hbase.codec.prefixtree.scanner.CellSearcher)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 TestRowDataSearchWithPrefix (org.apache.hadoop.hbase.codec.prefixtree.row.data.TestRowDataSearchWithPrefix)1