Search in sources :

Example 11 with ScanInfo

use of org.apache.hadoop.hbase.regionserver.ScanInfo in project hbase by apache.

the class TestUserScanQueryMatcher method testMatchExplicitColumns.

@Test
public void testMatchExplicitColumns() throws IOException {
    // Moving up from the Tracker by using Gets and List<KeyValue> instead
    // of just byte []
    // Expected result
    List<MatchCode> expected = new ArrayList<>(6);
    expected.add(ScanQueryMatcher.MatchCode.SEEK_NEXT_COL);
    expected.add(ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_COL);
    expected.add(ScanQueryMatcher.MatchCode.SEEK_NEXT_COL);
    expected.add(ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_COL);
    expected.add(ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_ROW);
    expected.add(ScanQueryMatcher.MatchCode.DONE);
    long now = EnvironmentEdgeManager.currentTime();
    // 2,4,5
    UserScanQueryMatcher qm = UserScanQueryMatcher.create(scan, new ScanInfo(this.conf, fam2, 0, 1, ttl, KeepDeletedCells.FALSE, 0, rowComparator), get.getFamilyMap().get(fam2), now - ttl, now, null);
    List<KeyValue> memstore = new ArrayList<>(6);
    memstore.add(new KeyValue(row1, fam2, col1, 1, data));
    memstore.add(new KeyValue(row1, fam2, col2, 1, data));
    memstore.add(new KeyValue(row1, fam2, col3, 1, data));
    memstore.add(new KeyValue(row1, fam2, col4, 1, data));
    memstore.add(new KeyValue(row1, fam2, col5, 1, data));
    memstore.add(new KeyValue(row2, fam1, col1, data));
    List<ScanQueryMatcher.MatchCode> actual = new ArrayList<>(memstore.size());
    KeyValue k = memstore.get(0);
    qm.setToNewRow(k);
    for (KeyValue kv : memstore) {
        actual.add(qm.match(kv));
    }
    assertEquals(expected.size(), actual.size());
    for (int i = 0; i < expected.size(); i++) {
        LOG.debug("expected " + expected.get(i) + ", actual " + actual.get(i));
        assertEquals(expected.get(i), actual.get(i));
    }
}
Also used : MatchCode(org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher.MatchCode) KeyValue(org.apache.hadoop.hbase.KeyValue) ArrayList(java.util.ArrayList) ScanInfo(org.apache.hadoop.hbase.regionserver.ScanInfo) Test(org.junit.Test)

Example 12 with ScanInfo

use of org.apache.hadoop.hbase.regionserver.ScanInfo in project hbase by apache.

the class TestUserScanQueryMatcher method testNeverIncludeFakeCell.

/**
   * This is a cryptic test. It is checking that we don't include a fake cell, one that has a
   * timestamp of {@link HConstants#OLDEST_TIMESTAMP}. See HBASE-16074 for background.
   * @throws IOException
   */
@Test
public void testNeverIncludeFakeCell() throws IOException {
    long now = EnvironmentEdgeManager.currentTime();
    // Do with fam2 which has a col2 qualifier.
    UserScanQueryMatcher qm = UserScanQueryMatcher.create(scan, new ScanInfo(this.conf, fam2, 10, 1, ttl, KeepDeletedCells.FALSE, 0, rowComparator), get.getFamilyMap().get(fam2), now - ttl, now, null);
    Cell kv = new KeyValue(row1, fam2, col2, 1, data);
    Cell cell = CellUtil.createLastOnRowCol(kv);
    qm.setToNewRow(kv);
    MatchCode code = qm.match(cell);
    assertFalse(code.compareTo(MatchCode.SEEK_NEXT_COL) != 0);
}
Also used : MatchCode(org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher.MatchCode) KeyValue(org.apache.hadoop.hbase.KeyValue) ScanInfo(org.apache.hadoop.hbase.regionserver.ScanInfo) Cell(org.apache.hadoop.hbase.Cell) Test(org.junit.Test)

Aggregations

ScanInfo (org.apache.hadoop.hbase.regionserver.ScanInfo)12 ArrayList (java.util.ArrayList)8 KeyValue (org.apache.hadoop.hbase.KeyValue)6 MatchCode (org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher.MatchCode)6 Test (org.junit.Test)5 List (java.util.List)3 Scan (org.apache.hadoop.hbase.client.Scan)3 StoreScanner (org.apache.hadoop.hbase.regionserver.StoreScanner)3 Configuration (org.apache.hadoop.conf.Configuration)2 FileSystem (org.apache.hadoop.fs.FileSystem)2 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)2 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)2 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)2 InternalScanner (org.apache.hadoop.hbase.regionserver.InternalScanner)2 ScanType (org.apache.hadoop.hbase.regionserver.ScanType)2 Store (org.apache.hadoop.hbase.regionserver.Store)2 StoreFileScanner (org.apache.hadoop.hbase.regionserver.StoreFileScanner)2 Scanner (org.apache.hadoop.hbase.regionserver.compactions.TestCompactor.Scanner)2 Cell (org.apache.hadoop.hbase.Cell)1