Search in sources :

Example 6 with FieldValue

use of org.apache.hadoop.hbase.hbtop.field.FieldValue in project hbase by apache.

the class RecordFilter method parse.

/*
   * Parse a filter string and build a RecordFilter instance.
   */
public static RecordFilter parse(String filterString, List<Field> fields, boolean ignoreCase) {
    int index = 0;
    boolean not = isNot(filterString);
    if (not) {
        index += 1;
    }
    StringBuilder fieldString = new StringBuilder();
    while (filterString.length() > index && filterString.charAt(index) != '<' && filterString.charAt(index) != '>' && filterString.charAt(index) != '=') {
        fieldString.append(filterString.charAt(index++));
    }
    if (fieldString.length() == 0 || filterString.length() == index) {
        return null;
    }
    Field field = getField(fields, fieldString.toString());
    if (field == null) {
        return null;
    }
    StringBuilder operatorString = new StringBuilder();
    while (filterString.length() > index && (filterString.charAt(index) == '<' || filterString.charAt(index) == '>' || filterString.charAt(index) == '=')) {
        operatorString.append(filterString.charAt(index++));
    }
    Operator operator = getOperator(operatorString.toString());
    if (operator == null) {
        return null;
    }
    String value = filterString.substring(index);
    FieldValue fieldValue = getFieldValue(field, value);
    if (fieldValue == null) {
        return null;
    }
    return new RecordFilter(ignoreCase, not, field, operator, fieldValue);
}
Also used : Field(org.apache.hadoop.hbase.hbtop.field.Field) FieldValue(org.apache.hadoop.hbase.hbtop.field.FieldValue)

Aggregations

FieldValue (org.apache.hadoop.hbase.hbtop.field.FieldValue)6 Record (org.apache.hadoop.hbase.hbtop.Record)4 Field (org.apache.hadoop.hbase.hbtop.field.Field)3 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 ClusterMetrics (org.apache.hadoop.hbase.ClusterMetrics)2 RecordFilter (org.apache.hadoop.hbase.hbtop.RecordFilter)2 FieldInfo (org.apache.hadoop.hbase.hbtop.field.FieldInfo)2 InterfaceAudience (org.apache.yetus.audience.InterfaceAudience)2 Test (org.junit.Test)2 Nullable (edu.umd.cs.findbugs.annotations.Nullable)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1