Search in sources :

Example 16 with KeyValue

use of org.apache.hadoop.hbase.KeyValue in project hbase by apache.

the class TestRowEncoder method testForwardScanner.

@Test
public void testForwardScanner() {
    int counter = -1;
    while (searcher.advance()) {
        ++counter;
        KeyValue inputKv = rows.getInputs().get(counter);
        KeyValue outputKv = KeyValueUtil.copyToNewKeyValue(searcher.current());
        assertKeyAndValueEqual(inputKv, outputKv);
    }
    // assert same number of cells
    Assert.assertEquals(rows.getInputs().size(), counter + 1);
}
Also used : KeyValue(org.apache.hadoop.hbase.KeyValue) Test(org.junit.Test)

Example 17 with KeyValue

use of org.apache.hadoop.hbase.KeyValue 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 18 with KeyValue

use of org.apache.hadoop.hbase.KeyValue 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 19 with KeyValue

use of org.apache.hadoop.hbase.KeyValue 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 20 with KeyValue

use of org.apache.hadoop.hbase.KeyValue 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)552 Test (org.junit.Test)289 Cell (org.apache.hadoop.hbase.Cell)193 ArrayList (java.util.ArrayList)172 Put (org.apache.hadoop.hbase.client.Put)98 Scan (org.apache.hadoop.hbase.client.Scan)85 Result (org.apache.hadoop.hbase.client.Result)70 Configuration (org.apache.hadoop.conf.Configuration)64 Path (org.apache.hadoop.fs.Path)55 ArrayBackedTag (org.apache.hadoop.hbase.ArrayBackedTag)36 Tag (org.apache.hadoop.hbase.Tag)35 ByteBuffer (java.nio.ByteBuffer)34 List (java.util.List)34 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)34 IOException (java.io.IOException)32 TableName (org.apache.hadoop.hbase.TableName)32 TreeMap (java.util.TreeMap)29 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)28 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)28 WALEdit (org.apache.hadoop.hbase.regionserver.wal.WALEdit)27