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);
}
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());
}
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)));
}
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)));
}
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());
}
Aggregations