Search in sources :

Example 21 with QualifierFilter

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

the class QuotaTableUtil method makeFilter.

/**
 * converts quotafilter to serializeable filterlists.
 */
public static Filter makeFilter(final QuotaFilter filter) {
    FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL);
    if (StringUtils.isNotEmpty(filter.getUserFilter())) {
        FilterList userFilters = new FilterList(FilterList.Operator.MUST_PASS_ONE);
        boolean hasFilter = false;
        if (StringUtils.isNotEmpty(filter.getNamespaceFilter())) {
            FilterList nsFilters = new FilterList(FilterList.Operator.MUST_PASS_ALL);
            nsFilters.addFilter(new RowFilter(CompareOperator.EQUAL, new RegexStringComparator(getUserRowKeyRegex(filter.getUserFilter()), 0)));
            nsFilters.addFilter(new QualifierFilter(CompareOperator.EQUAL, new RegexStringComparator(getSettingsQualifierRegexForUserNamespace(filter.getNamespaceFilter()), 0)));
            userFilters.addFilter(nsFilters);
            hasFilter = true;
        }
        if (StringUtils.isNotEmpty(filter.getTableFilter())) {
            FilterList tableFilters = new FilterList(FilterList.Operator.MUST_PASS_ALL);
            tableFilters.addFilter(new RowFilter(CompareOperator.EQUAL, new RegexStringComparator(getUserRowKeyRegex(filter.getUserFilter()), 0)));
            tableFilters.addFilter(new QualifierFilter(CompareOperator.EQUAL, new RegexStringComparator(getSettingsQualifierRegexForUserTable(filter.getTableFilter()), 0)));
            userFilters.addFilter(tableFilters);
            hasFilter = true;
        }
        if (!hasFilter) {
            userFilters.addFilter(new RowFilter(CompareOperator.EQUAL, new RegexStringComparator(getUserRowKeyRegex(filter.getUserFilter()), 0)));
        }
        filterList.addFilter(userFilters);
    } else if (StringUtils.isNotEmpty(filter.getTableFilter())) {
        filterList.addFilter(new RowFilter(CompareOperator.EQUAL, new RegexStringComparator(getTableRowKeyRegex(filter.getTableFilter()), 0)));
    } else if (StringUtils.isNotEmpty(filter.getNamespaceFilter())) {
        filterList.addFilter(new RowFilter(CompareOperator.EQUAL, new RegexStringComparator(getNamespaceRowKeyRegex(filter.getNamespaceFilter()), 0)));
    } else if (StringUtils.isNotEmpty(filter.getRegionServerFilter())) {
        filterList.addFilter(new RowFilter(CompareOperator.EQUAL, new RegexStringComparator(getRegionServerRowKeyRegex(filter.getRegionServerFilter()), 0)));
    }
    return filterList;
}
Also used : RegexStringComparator(org.apache.hadoop.hbase.filter.RegexStringComparator) RowFilter(org.apache.hadoop.hbase.filter.RowFilter) FilterList(org.apache.hadoop.hbase.filter.FilterList) QualifierFilter(org.apache.hadoop.hbase.filter.QualifierFilter)

Aggregations

QualifierFilter (org.apache.hadoop.hbase.filter.QualifierFilter)21 Test (org.junit.Test)12 BinaryComparator (org.apache.hadoop.hbase.filter.BinaryComparator)11 FilterList (org.apache.hadoop.hbase.filter.FilterList)11 Filter (org.apache.hadoop.hbase.filter.Filter)9 RegexStringComparator (org.apache.hadoop.hbase.filter.RegexStringComparator)8 Scan (org.apache.hadoop.hbase.client.Scan)7 FamilyFilter (org.apache.hadoop.hbase.filter.FamilyFilter)6 RowFilter (org.apache.hadoop.hbase.filter.RowFilter)6 TableName (org.apache.hadoop.hbase.TableName)5 FirstKeyOnlyFilter (org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter)5 InclusiveStopFilter (org.apache.hadoop.hbase.filter.InclusiveStopFilter)5 KeyValue (org.apache.hadoop.hbase.KeyValue)4 BinaryPrefixComparator (org.apache.hadoop.hbase.filter.BinaryPrefixComparator)4 PrefixFilter (org.apache.hadoop.hbase.filter.PrefixFilter)4 TimestampsFilter (org.apache.hadoop.hbase.filter.TimestampsFilter)4 ValueFilter (org.apache.hadoop.hbase.filter.ValueFilter)4 Cell (org.apache.hadoop.hbase.Cell)3 MultiRowMutationEndpoint (org.apache.hadoop.hbase.coprocessor.MultiRowMutationEndpoint)3 KeyOnlyFilter (org.apache.hadoop.hbase.filter.KeyOnlyFilter)3