Hbase shell scanフィルタ

4946 ワード

1.クエリがフィルタリングで使用される比較方法は以下のとおりです.
  • The ComparatorType for the various comparators is as follows:
  • - BinaryComparator - binary
  • - BinaryPrefixComparator - binaryprefix
  • - RegexStringComparator - regexstring
  • - SubStringComparator - substring

  • Example ComparatorValues:
  • - binary:abc will match everything that is lexicographically greater than "abc"
  • - binaryprefix:abc will match everything whose first 3 characters are lexicographically equal to "abc"
  • - regexstring:ab*yz will match everything that doesn’t begin with "ab"and ends with "yz"
  • - substring:abc123 will match everything that begins with the substring "abc123"


  • 2.コマンドサンプルコード:
    scan "{namespace}:{tablename}",{FILTER=>"(RowFilter(=,'regexstring:{regstr}'))"}
  • namespace:ネーミングスペース.
  • tablename:テーブル名.
  • regstr:一致する文字.

  • ここではRowFilterを用い,RowKeyをフィルタリングし,RowKeyにregstrを含むデータのみを検出した.3.フィルタの種類:
  • KeyOnlyFilter:This filter doesn’t take any arguments. It returns only the key component of each key-value.
  • FirstKeyOnlyFilter:This filter doesn’t take any arguments. It returns only the first key-value from each row.
  • PrefixFilter:This filter takes one argument – a prefix of a row key. It returns only those key-values present in a row that starts with the specified row prefix
  • ColumnPrefixFilter:This filter takes one argument – a column prefix. It returns only those key-values present in a column that starts with the specified column prefix. The column prefix must be of the form: “qualifier”.
  • MultipleColumnPrefixFilter:This filter takes a list of column prefixes. It returns key-values that are present in a column that starts with any of the specified column prefixes. Each of the column prefixes must be of the form: “qualifier”.
  • ColumnCountGetFilter:This filter takes one argument – a limit. It returns the first limit number of columns in the table.
  • PageFilter:This filter takes one argument – a page size. It returns page size number of rows from the table.
  • ColumnPaginationFilter:This filter takes two arguments – a limit and offset. It returns limit number of columns after offset number of columns. It does this for all the rows.
  • InclusiveStopFilter:This filter takes one argument – a row key on which to stop scanning. It returns all key-values present in rows up to and including the specified row.
  • TimeStampsFilter:This filter takes a list of timestamps. It returns those key-values whose timestamps matches any of the specified timestamps.
  • RowFilter:This filter takes a compare operator and a comparator. It compares each row key with the comparator using the compare operator and if the comparison returns true, it returns all the key-values in that row.
  • FamilyFilter:This filter takes a compare operator and a comparator. It compares each column family name with the comparator using the compare operator and if the comparison returns true, it returns all the Cells in that column family.
  • QualifierFilter:This filter takes a compare operator and a comparator. It compares each qualifier name with the comparator using the compare operator and if the comparison returns true, it returns all the key-values in that column.
  • ValueFilter:This filter takes a compare operator and a comparator. It compares each value with the comparator using the compare operator and if the comparison returns true, it returns that key-value.
  • DependentColumnFilter:This filter takes two arguments – a family and a qualifier. It tries to locate this column in each row and returns all key-values in that row that have the same timestamp. If the row doesn’t contain the specified column – none of the key-values in that row will be returned.
  • SingleColumnValueFilter:This filter takes a column family, a qualifier, a compare operator and a comparator. If the specified column is not found – all the columns of that row will be emitted. If the column is found and the comparison with the comparator returns true, all the columns of the row will be emitted. If the condition fails, the row will not be emitted.
  • SingleColumnValueExcludeFilter:This filter takes the same arguments and behaves same as SingleColumnValueFilter – however, if the column is found and the condition passes, all the columns of the row will be emitted except for the tested column value.
  • ColumnRangeFilter:This filter is used for selecting only those keys with columns that are between minColumn and maxColumn. It also takes two boolean variables to indicate whether to include the minColumn and maxColumn or not.

  • 参照先:http://hbase.apache.org/book.html#_shell_tricks