Class: Google::Cloud::Bigtable::RowFilter::ChainFilter
- Inherits:
-
Object
- Object
- Google::Cloud::Bigtable::RowFilter::ChainFilter
- Defined in:
- lib/google/cloud/bigtable/row_filter/chain_filter.rb
Overview
ChainFilter
A RowFilter that sends rows through several RowFilters in sequence.
The elements of "filters" are chained together to process the input row: in row -> f(0) -> intermediate row -> f(1) -> ... -> f(N) -> out row The full chain is executed atomically.
Instance Method Summary collapse
-
#block ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a block-all filter instance.
-
#cells_per_column(limit) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a cells-per-column filter instance.
-
#cells_per_row(limit) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a cells-per-row-limit filter instance.
-
#cells_per_row_offset(offset) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a cell-per-row-offset filter instance to skip the first N cells.
-
#chain(filter) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a chain filter instance.
-
#column_range(range) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a column-range filter instance.
-
#condition(filter) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a condition filter instance.
-
#family(regex) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a family-name-match filter using a regular expression.
-
#filters ⇒ Array<Google::Bigtable::V2::RowFilter>
Gets the list of filters.
-
#interleave(filter) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Add interleave filter.
-
#key(regex) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a key-filter instance to match keys using a regular expression.
-
#label(value) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a label filter instance to apply a label based on the result of read rows.
-
#length ⇒ Integer
Gets the number of filters in the chain filter.
-
#pass ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a pass filter instance.
-
#qualifier(regex) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Add a column-qualifier-match filter using a regular expression.
-
#sample(probability) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a sample-probability filter instance.
-
#sink ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a sink filter instance.
-
#strip_value ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a strip-value filter instance.
-
#timestamp_range(from: nil, to: nil) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a timestamp-range filter instance.
-
#value(regex) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a value-match filter using a regular expression.
-
#value_range(range) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a value-range filter instance.
Instance Method Details
#block ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a block-all filter instance.
Does not match any cells, regardless of input. Useful for temporarily disabling just part of a filter.
190 191 192 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 190 def block add(RowFilter.block) end |
#cells_per_column(limit) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a cells-per-column filter instance.
Matches only the most recent N cells within each column. For example,
if N=2, this filter would match column foo:bar at timestamps 10 and 9,
skip all earlier cells in foo:bar, and then begin matching again in
column foo:bar2.
If duplicate cells are present, as is possible when using an Interleave,
each copy of the cell is counted separately.
418 419 420 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 418 def cells_per_column limit add(RowFilter.cells_per_column(limit)) end |
#cells_per_row(limit) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a cells-per-row-limit filter instance.
Matches only the first N cells of each row. If duplicate cells are present, as is possible when using an Interleave, each copy of the cell is counted separately.
397 398 399 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 397 def cells_per_row limit add(RowFilter.cells_per_row(limit)) end |
#cells_per_row_offset(offset) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a cell-per-row-offset filter instance to skip the first N cells.
Skips the first N cells of each row, matching all subsequent cells. If duplicate cells are present, as is possible when using an Interleave, each copy of the cell is counted separately.
379 380 381 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 379 def cells_per_row_offset offset add(RowFilter.cells_per_row_offset(offset)) end |
#chain(filter) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a chain filter instance.
A Chain RowFilter that sends rows through several RowFilters in sequence.
The elements of "filters" are chained together to process the input row: in row -> f(0) -> intermediate row -> f(1) -> ... -> f(N) -> out row The full chain is executed atomically.
68 69 70 71 72 73 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 68 def chain filter unless filter.instance_of?(ChainFilter) raise RowFilterError, "Filter type must be ChainFilter" end add(filter) end |
#column_range(range) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a column-range filter instance.
Matches only cells from columns within the given range.
488 489 490 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 488 def column_range range add(RowFilter.column_range(range)) end |
#condition(filter) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a condition filter instance.
A RowFilter that evaluates one of two possible RowFilters, depending on whether or not a predicate RowFilter outputs any cells from the input row.
IMPORTANT NOTE: The predicate filter does not execute atomically with the true and false filters, which may lead to inconsistent or unexpected results. Additionally, condition filters have poor performance, especially when filters are set for the false condition.
Cannot be used within the predicate_filter, true_filter, or false_filter.
155 156 157 158 159 160 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 155 def condition filter unless filter.instance_of?(ConditionFilter) raise RowFilterError, "Filter type must be ConditionFilter" end add(filter) end |
#family(regex) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a family-name-match filter using a regular expression.
Matches only cells from columns whose families satisfy the given RE2
regex. For technical reasons, the regex must not contain the :
character, even if it is not being used as a literal.
Note that, since column families cannot contain the new line character
\n, it is sufficient to use . as a full wildcard when matching
column family names.
For Regex syntax:
287 288 289 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 287 def family regex add(RowFilter.family(regex)) end |
#filters ⇒ Array<Google::Bigtable::V2::RowFilter>
Gets the list of filters.
509 510 511 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 509 def filters @grpc.filters end |
#interleave(filter) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Add interleave filter.
A RowFilter that sends each row to each of several component RowFilters and interleaves the results.
The elements of "filters" all process a copy of the input row, and the results are pooled, sorted, and combined into a single output row. If multiple cells are produced with the same column and timestamp, they will all appear in the output row in an unspecified mutual order. Consider the following example, with three filters:
input row
|
-----------------------------------------------------
| | |
f(0) f(1) f(2)
| | |
1: foo,,10,x foo,,10,z far,,7,a
2: foo,blah,11,z far,blah,5,x far,blah,5,x
| | |
-----------------------------------------------------
|
1: foo,,10,z # could have switched with #2
2: foo,,10,x # could have switched with #1
3: foo,blah,11,z
4: far,,7,a
5: far,blah,5,x # identical to #6
6: far,blah,5,x # identical to #5
All interleaved filters are executed atomically.
See InterleaveFilter
121 122 123 124 125 126 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 121 def interleave filter unless filter.instance_of?(InterleaveFilter) raise RowFilterError, "Filter type must be InterleaveFilter" end add(filter) end |
#key(regex) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a key-filter instance to match keys using a regular expression.
Matches only cells from rows whose keys satisfy the given RE2 regex. In
other words, passes through the entire row when the key matches, and
otherwise produces an empty row.
Note that, since row keys can contain arbitrary bytes, the \C escape
sequence must be used if a true wildcard is desired. The . character
will not match the new line character \n, which may be present in a
binary key.
For Regex syntax:
245 246 247 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 245 def key regex add(RowFilter.key(regex)) end |
#label(value) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a label filter instance to apply a label based on the result of read rows.
Applies the given label to all cells in the output row. This allows the client to determine which results were produced from which part of the filter.
Values must be at most 15 characters and match the RE2
pattern [a-z0-9\\-]+
Due to a technical limitation, it is not possible to apply
multiple labels to a cell. As a result, a chain may have no more than
one sub-filter that contains an apply_label_transformer. It is okay for
an Interleave to contain multiple apply_label_transformers, as they
will be applied to separate copies of the input.
361 362 363 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 361 def label value add(RowFilter.label(value)) end |
#length ⇒ Integer
Gets the number of filters in the chain filter.
501 502 503 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 501 def length @grpc.filters.length end |
#pass ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a pass filter instance.
Matches all cells, regardless of input. Functionally equivalent to
leaving filter unset, but included for completeness.
174 175 176 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 174 def pass add(RowFilter.pass) end |
#qualifier(regex) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Add a column-qualifier-match filter using a regular expression.
Matches only cells from columns whose qualifiers satisfy the given RE2
regex.
Note that, since column qualifiers can contain arbitrary bytes, the \C
escape sequence must be used if a true wildcard is desired. The .
character will not match the new line character \n, which may be
present in a binary qualifier.
For Regex syntax:
311 312 313 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 311 def qualifier regex add(RowFilter.qualifier(regex)) end |
#sample(probability) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a sample-probability filter instance.
Matches all cells from a row with probability p, and matches no cells from the row with probability 1-p.
263 264 265 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 263 def sample probability add(RowFilter.sample(probability)) end |
#sink ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a sink filter instance.
Outputs all cells directly to the output of the read rather than to any parent filter.
205 206 207 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 205 def sink add(RowFilter.sink) end |
#strip_value ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a strip-value filter instance.
Replaces each cell's value with an empty string.
220 221 222 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 220 def strip_value add(RowFilter.strip_value) end |
#timestamp_range(from: nil, to: nil) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a timestamp-range filter instance.
Matches only cells with timestamps within the given range. Specifies a contiguous range of timestamps.
442 443 444 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 442 def from: nil, to: nil add(RowFilter.(from: from, to: to)) end |
#value(regex) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a value-match filter using a regular expression.
Matches only cells with values that satisfy the given regular expression.
Note that, since cell values can contain arbitrary bytes, the \C escape
sequence must be used if a true wildcard is desired. The . character
will not match the new line character \n, which may be present in a
binary value.
For Regex syntax:
334 335 336 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 334 def value regex add(RowFilter.value(regex)) end |
#value_range(range) ⇒ Google::Cloud::Bigtable::RowFilter::ChainFilter
Adds a value-range filter instance.
Matches only cells with values that fall within the given range.
See ValueRange#from and { Google::Cloud::Bigtable::ValueRange#to} for range option inclusive/exclusive options
- The value at which to start the range. If neither field is set, interpreted as an empty string, inclusive.
- The value at which to end the range. If neither field is set, interpreted as the infinite string, exclusive.
470 471 472 |
# File 'lib/google/cloud/bigtable/row_filter/chain_filter.rb', line 470 def value_range range add(RowFilter.value_range(range)) end |