Filters rows based on an expression applied to the row key. The regular expression will be applied on the server-side, on the row key. Rows for which the key doesn't match will not be returned to the scanner, which can be useful to carefully select which rows are matched when you can't just do
| 59 | * @since 1.5 |
| 60 | */ |
| 61 | public final class KeyRegexpFilter extends ScanFilter { |
| 62 | |
| 63 | private static final byte[] ROWFILTER = Bytes.ISO88591("org.apache.hadoop" |
| 64 | + ".hbase.filter.RowFilter"); |
| 65 | private static final byte[] REGEXSTRINGCOMPARATOR = Bytes.ISO88591("org.apache.hadoop" |
| 66 | + ".hbase.filter.RegexStringComparator"); |
| 67 | private static final byte[] EQUAL = new byte[] { 'E', 'Q', 'U', 'A', 'L' }; |
| 68 | |
| 69 | private final byte[] regexp; |
| 70 | private final byte[] charset; |
| 71 | |
| 72 | /** |
| 73 | * Sets a regular expression to filter results based on the row key. |
| 74 | * <p> |
| 75 | * This is equivalent to calling {@link #KeyRegexpFilter(String, Charset)} |
| 76 | * with the ISO-8859-1 charset in argument. |
| 77 | * @param regexp The regular expression with which to filter the row keys. |
| 78 | */ |
| 79 | public KeyRegexpFilter(final String regexp) { |
| 80 | this(regexp, CharsetUtil.ISO_8859_1); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Sets a regular expression to filter results based on the row key. |
| 85 | * @param regexp The regular expression with which to filter the row keys. |
| 86 | * @param charset The charset used to decode the bytes of the row key into a |
| 87 | * string. The RegionServer must support this charset, otherwise it will |
| 88 | * unexpectedly close the connection the first time you attempt to use this |
| 89 | * scanner. |
| 90 | * @see #KeyRegexpFilter(byte[], Charset) |
| 91 | */ |
| 92 | public KeyRegexpFilter(final String regexp, final Charset charset) { |
| 93 | this(Bytes.UTF8(regexp), charset); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Sets a regular expression to filter results based on the row key. |
| 98 | * <p> |
| 99 | * This is equivalent to calling {@link #KeyRegexpFilter(byte[], Charset)} |
| 100 | * with the ISO-8859-1 charset in argument. |
| 101 | * @param regexp The binary regular expression with which to filter |
| 102 | * the row keys. |
| 103 | */ |
| 104 | public KeyRegexpFilter(final byte[] regexp) { |
| 105 | this(regexp, CharsetUtil.ISO_8859_1); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Sets a regular expression to filter results based on the row key. |
| 110 | * @param regexp The regular expression with which to filter the row keys. |
| 111 | * @param charset The charset used to decode the bytes of the row key into a |
| 112 | * string. The RegionServer must support this charset, otherwise it will |
| 113 | * unexpectedly close the connection the first time you attempt to use this |
| 114 | * scanner. |
| 115 | */ |
| 116 | public KeyRegexpFilter(final byte[] regexp, final Charset charset) { |
| 117 | this.regexp = regexp; |
| 118 | this.charset = Bytes.UTF8(charset.name()); |
nothing calls this directly
no test coverage detected
searching dependent graphs…