Search in sources :

Example 6 with FamilyFilter

use of org.apache.hadoop.hbase.filter.FamilyFilter in project hadoop by apache.

the class GenericEntityReader method constructFilterListBasedOnFields.

@Override
protected FilterList constructFilterListBasedOnFields() throws IOException {
    if (!needCreateFilterListBasedOnFields()) {
        // Fetch all the columns. No need of a filter.
        return null;
    }
    FilterList listBasedOnFields = new FilterList(Operator.MUST_PASS_ONE);
    FilterList infoColFamilyList = new FilterList();
    // By default fetch everything in INFO column family.
    FamilyFilter infoColumnFamily = new FamilyFilter(CompareOp.EQUAL, new BinaryComparator(EntityColumnFamily.INFO.getBytes()));
    infoColFamilyList.addFilter(infoColumnFamily);
    if (!isSingleEntityRead() && fetchPartialColsFromInfoFamily()) {
        // We can fetch only some of the columns from info family.
        infoColFamilyList.addFilter(createFilterListForColsOfInfoFamily());
    } else {
        // Exclude column prefixes in info column family which are not required
        // based on fields to retrieve.
        excludeFieldsFromInfoColFamily(infoColFamilyList);
    }
    listBasedOnFields.addFilter(infoColFamilyList);
    updateFilterForConfsAndMetricsToRetrieve(listBasedOnFields);
    return listBasedOnFields;
}
Also used : FilterList(org.apache.hadoop.hbase.filter.FilterList) TimelineFilterList(org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList) FamilyFilter(org.apache.hadoop.hbase.filter.FamilyFilter) BinaryComparator(org.apache.hadoop.hbase.filter.BinaryComparator)

Example 7 with FamilyFilter

use of org.apache.hadoop.hbase.filter.FamilyFilter in project hbase by apache.

the class TestAsyncTable method testCheckAndMutateWithTimestampFilterForOldApi.

@Test
@Deprecated
public void testCheckAndMutateWithTimestampFilterForOldApi() throws Throwable {
    AsyncTable<?> table = getTable.get();
    // Put with specifying the timestamp
    table.put(new Put(row).addColumn(FAMILY, Bytes.toBytes("A"), 100, Bytes.toBytes("a"))).get();
    // Put with success
    boolean ok = table.checkAndMutate(row, new FilterList(new FamilyFilter(CompareOperator.EQUAL, new BinaryComparator(FAMILY)), new QualifierFilter(CompareOperator.EQUAL, new BinaryComparator(Bytes.toBytes("A"))), new TimestampsFilter(Collections.singletonList(100L)))).thenPut(new Put(row).addColumn(FAMILY, Bytes.toBytes("B"), Bytes.toBytes("b"))).get();
    assertTrue(ok);
    Result result = table.get(new Get(row).addColumn(FAMILY, Bytes.toBytes("B"))).get();
    assertEquals("b", Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("B"))));
    // Put with failure
    ok = table.checkAndMutate(row, new FilterList(new FamilyFilter(CompareOperator.EQUAL, new BinaryComparator(FAMILY)), new QualifierFilter(CompareOperator.EQUAL, new BinaryComparator(Bytes.toBytes("A"))), new TimestampsFilter(Collections.singletonList(101L)))).thenPut(new Put(row).addColumn(FAMILY, Bytes.toBytes("C"), Bytes.toBytes("c"))).get();
    assertFalse(ok);
    assertFalse(table.exists(new Get(row).addColumn(FAMILY, Bytes.toBytes("C"))).get());
}
Also used : FilterList(org.apache.hadoop.hbase.filter.FilterList) TimestampsFilter(org.apache.hadoop.hbase.filter.TimestampsFilter) FamilyFilter(org.apache.hadoop.hbase.filter.FamilyFilter) BinaryComparator(org.apache.hadoop.hbase.filter.BinaryComparator) QualifierFilter(org.apache.hadoop.hbase.filter.QualifierFilter) Test(org.junit.Test)

Example 8 with FamilyFilter

use of org.apache.hadoop.hbase.filter.FamilyFilter in project hbase by apache.

the class TestCheckAndMutate method testCheckAndMutateWithTimestampFilter.

@Test
public void testCheckAndMutateWithTimestampFilter() throws Throwable {
    try (Table table = createTable()) {
        // Put with specifying the timestamp
        table.put(new Put(ROWKEY).addColumn(FAMILY, Bytes.toBytes("A"), 100, Bytes.toBytes("a")));
        // Put with success
        CheckAndMutateResult result = table.checkAndMutate(CheckAndMutate.newBuilder(ROWKEY).ifMatches(new FilterList(new FamilyFilter(CompareOperator.EQUAL, new BinaryComparator(FAMILY)), new QualifierFilter(CompareOperator.EQUAL, new BinaryComparator(Bytes.toBytes("A"))), new TimestampsFilter(Collections.singletonList(100L)))).build(new Put(ROWKEY).addColumn(FAMILY, Bytes.toBytes("B"), Bytes.toBytes("b"))));
        assertTrue(result.isSuccess());
        assertNull(result.getResult());
        Result r = table.get(new Get(ROWKEY).addColumn(FAMILY, Bytes.toBytes("B")));
        assertEquals("b", Bytes.toString(r.getValue(FAMILY, Bytes.toBytes("B"))));
        // Put with failure
        result = table.checkAndMutate(CheckAndMutate.newBuilder(ROWKEY).ifMatches(new FilterList(new FamilyFilter(CompareOperator.EQUAL, new BinaryComparator(FAMILY)), new QualifierFilter(CompareOperator.EQUAL, new BinaryComparator(Bytes.toBytes("A"))), new TimestampsFilter(Collections.singletonList(101L)))).build(new Put(ROWKEY).addColumn(FAMILY, Bytes.toBytes("C"), Bytes.toBytes("c"))));
        assertFalse(result.isSuccess());
        assertNull(result.getResult());
        assertFalse(table.exists(new Get(ROWKEY).addColumn(FAMILY, Bytes.toBytes("C"))));
    }
}
Also used : FilterList(org.apache.hadoop.hbase.filter.FilterList) TimestampsFilter(org.apache.hadoop.hbase.filter.TimestampsFilter) FamilyFilter(org.apache.hadoop.hbase.filter.FamilyFilter) BinaryComparator(org.apache.hadoop.hbase.filter.BinaryComparator) QualifierFilter(org.apache.hadoop.hbase.filter.QualifierFilter) Test(org.junit.Test)

Example 9 with FamilyFilter

use of org.apache.hadoop.hbase.filter.FamilyFilter in project hbase by apache.

the class TestCheckAndMutate method testCheckAndMutateWithTimestampFilterForOldApi.

@Test
@Deprecated
public void testCheckAndMutateWithTimestampFilterForOldApi() throws Throwable {
    try (Table table = createTable()) {
        // Put with specifying the timestamp
        table.put(new Put(ROWKEY).addColumn(FAMILY, Bytes.toBytes("A"), 100, Bytes.toBytes("a")));
        // Put with success
        boolean ok = table.checkAndMutate(ROWKEY, new FilterList(new FamilyFilter(CompareOperator.EQUAL, new BinaryComparator(FAMILY)), new QualifierFilter(CompareOperator.EQUAL, new BinaryComparator(Bytes.toBytes("A"))), new TimestampsFilter(Collections.singletonList(100L)))).thenPut(new Put(ROWKEY).addColumn(FAMILY, Bytes.toBytes("B"), Bytes.toBytes("b")));
        assertTrue(ok);
        Result result = table.get(new Get(ROWKEY).addColumn(FAMILY, Bytes.toBytes("B")));
        assertEquals("b", Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("B"))));
        // Put with failure
        ok = table.checkAndMutate(ROWKEY, new FilterList(new FamilyFilter(CompareOperator.EQUAL, new BinaryComparator(FAMILY)), new QualifierFilter(CompareOperator.EQUAL, new BinaryComparator(Bytes.toBytes("A"))), new TimestampsFilter(Collections.singletonList(101L)))).thenPut(new Put(ROWKEY).addColumn(FAMILY, Bytes.toBytes("C"), Bytes.toBytes("c")));
        assertFalse(ok);
        assertFalse(table.exists(new Get(ROWKEY).addColumn(FAMILY, Bytes.toBytes("C"))));
    }
}
Also used : FilterList(org.apache.hadoop.hbase.filter.FilterList) TimestampsFilter(org.apache.hadoop.hbase.filter.TimestampsFilter) FamilyFilter(org.apache.hadoop.hbase.filter.FamilyFilter) BinaryComparator(org.apache.hadoop.hbase.filter.BinaryComparator) QualifierFilter(org.apache.hadoop.hbase.filter.QualifierFilter) Test(org.junit.Test)

Aggregations

BinaryComparator (org.apache.hadoop.hbase.filter.BinaryComparator)9 FamilyFilter (org.apache.hadoop.hbase.filter.FamilyFilter)9 FilterList (org.apache.hadoop.hbase.filter.FilterList)9 QualifierFilter (org.apache.hadoop.hbase.filter.QualifierFilter)7 TimestampsFilter (org.apache.hadoop.hbase.filter.TimestampsFilter)4 Test (org.junit.Test)4 TimelineFilterList (org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineFilterList)3 Filter (org.apache.hadoop.hbase.filter.Filter)2 BinaryPrefixComparator (org.apache.hadoop.hbase.filter.BinaryPrefixComparator)1 SingleColumnValueFilter (org.apache.hadoop.hbase.filter.SingleColumnValueFilter)1 TimelineDataToRetrieve (org.apache.hadoop.yarn.server.timelineservice.reader.TimelineDataToRetrieve)1 ApplyAndFilterDeletesFilter (org.apache.phoenix.hbase.index.covered.filter.ApplyAndFilterDeletesFilter)1 ColumnTrackingNextLargestTimestampFilter (org.apache.phoenix.hbase.index.covered.filter.ColumnTrackingNextLargestTimestampFilter)1 ColumnReference (org.apache.phoenix.hbase.index.covered.update.ColumnReference)1