Search in sources :

Example 6 with MatchCode

use of org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher.MatchCode in project hbase by apache.

the class TestScanWildcardColumnTracker method testCheckColumnOk.

@Test
public void testCheckColumnOk() throws IOException {
    ScanWildcardColumnTracker tracker = new ScanWildcardColumnTracker(0, VERSIONS, Long.MIN_VALUE);
    // Create list of qualifiers
    List<byte[]> qualifiers = new ArrayList<>(4);
    qualifiers.add(Bytes.toBytes("qualifier1"));
    qualifiers.add(Bytes.toBytes("qualifier2"));
    qualifiers.add(Bytes.toBytes("qualifier3"));
    qualifiers.add(Bytes.toBytes("qualifier4"));
    // Setting up expected result
    List<MatchCode> expected = new ArrayList<>(4);
    expected.add(ScanQueryMatcher.MatchCode.INCLUDE);
    expected.add(ScanQueryMatcher.MatchCode.INCLUDE);
    expected.add(ScanQueryMatcher.MatchCode.INCLUDE);
    expected.add(ScanQueryMatcher.MatchCode.INCLUDE);
    List<ScanQueryMatcher.MatchCode> actual = new ArrayList<>(qualifiers.size());
    for (byte[] qualifier : qualifiers) {
        ScanQueryMatcher.MatchCode mc = ScanQueryMatcher.checkColumn(tracker, qualifier, 0, qualifier.length, 1, KeyValue.Type.Put.getCode(), false);
        actual.add(mc);
    }
    // Compare actual with expected
    for (int i = 0; i < expected.size(); i++) {
        assertEquals(expected.get(i), actual.get(i));
    }
}
Also used : MatchCode(org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher.MatchCode) MatchCode(org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher.MatchCode) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with MatchCode

use of org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher.MatchCode 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 8 with MatchCode

use of org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher.MatchCode 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

MatchCode (org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher.MatchCode)8 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 KeyValue (org.apache.hadoop.hbase.KeyValue)6 ScanInfo (org.apache.hadoop.hbase.regionserver.ScanInfo)6 Cell (org.apache.hadoop.hbase.Cell)1