2.13.2 (latest) 2.13.1 2.12.3 2.11.1 2.10.2 2.9.1 2.8.0 2.7.1 2.6.5 Reference documentation and code samples for the Cloud Bigtable API class Google::Cloud::Bigtable::RowFilter::InterleaveFilter.

## InterleaveFilter

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,bar,10,x             foo,bar,10,z              far,bar,7,a
    2: foo,blah,11,z            far,blah,5,x              far,blah,5,x
           |                         |                         |
           ---
                                     |
    1:                      foo,bar,10,z   # could have switched with #2
    2:                      foo,bar,10,x   # could have switched with #1
    3:                      foo,blah,11,z
    4:                      far,bar,7,a
    5:                      far,blah,5,x   # identical to #6
    6:                      far,blah,5,x   # identical to #5

All interleaved filters are executed atomically.

## Inherits

- Object

## Examples

Create an interleave filter with a simple filter.

```ruby
require "google/cloud/bigtable"

interleave = Google::Cloud::Bigtable::RowFilter.interleave

# Add filters to interleave filter
interleave.key "user-*"
interleave.sink

# OR
interleave.key("user-*").sink
```

Create a complex interleave filter.

```ruby
require "google/cloud/bigtable"

interleave = Google::Cloud::Bigtable::RowFilter.interleave

chain_1 = Google::Cloud::Bigtable::RowFilter.chain
chain_1.label("users").qualifier("name").cells_per_row(5)

# Add to main chain filter
interleave.chain(chain_1).value("xyz*").key("user-*")
```

## Methods

### #block

```ruby
def block() -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
Adds a block-all filter.


<br />

Does not match any cells, regardless of input. Useful for temporarily
disabling just part of a filter.
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Example**

```ruby
require "google/cloud/bigtable"

filter = Google::Cloud::Bigtable::RowFilter.interleave.block
```

### #cells_per_column

```ruby
def cells_per_column(limit) -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
Adds a cells-per-column filter.


<br />

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.
**Parameter**

- **limit** (String) --- Max cell match per column limit
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Example**

```ruby
require "google/cloud/bigtable"

filter = Google::Cloud::Bigtable::RowFilter.interleave.cells_per_column 5
```

### #cells_per_row

```ruby
def cells_per_row(limit) -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
Adds a cells-per-row-limit filter.


<br />

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.
**Parameter**

- **limit** (String) --- Max cell match per row limit
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Example**

```ruby
require "google/cloud/bigtable"

filter = Google::Cloud::Bigtable::RowFilter.interleave.cells_per_row 5
```

### #cells_per_row_offset

```ruby
def cells_per_row_offset(offset) -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
Adds a cell-per-row-offset filter instance to skip the first N cells.


<br />

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.
**Parameter**

- **offset** (Integer) --- Offset value.
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Example**

```ruby
require "google/cloud/bigtable"

filter = Google::Cloud::Bigtable::RowFilter.interleave.cells_per_row_offset 3
```

### #chain

```ruby
def chain(filter) -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
Adds a chain filter.


A Chain RowFilter that sends rows through several RowFilters in sequence.

See [InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt "Google::Cloud::Bigtable::RowFilter::InterleaveFilter (class)").

<br />

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.
**Parameter**

- **filter** ([SimpleFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-SimpleFilter.md.txt), [ChainFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-ChainFilter.md.txt), [InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt), [ConditionFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-ConditionFilter.md.txt))
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Raises**

- ([RowFilterError](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilterError.md.txt))
**Example**

Create a chain filter and add an interleave filter.

```ruby
require "google/cloud/bigtable"

chain = Google::Cloud::Bigtable::RowFilter.chain

# Add filters to chain filter
chain.key("user-*").cells_per_row(5)

filter = Google::Cloud::Bigtable::RowFilter.interleave.chain chain
```

### #column_range

```ruby
def column_range(range) -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
Adds a column-range filter.


<br />

Matches only cells from columns within the given range.
**Parameter**

- **range** ([Google::Cloud::Bigtable::ColumnRange](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-ColumnRange.md.txt))
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Example**

```ruby
require "google/cloud/bigtable"

range = Google::Cloud::Bigtable::ColumnRange.new("cf").from("field0").to("field5")

filter = Google::Cloud::Bigtable::RowFilter.interleave.column_range range
```

### #condition

```ruby
def condition(filter) -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
Adds a condition filter.


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.

<br />

Cannot be used within the `predicate_filter`, `true_filter`, or `false_filter`.
**Parameter**

- **filter** ([Google::Cloud::Bigtable::RowFilter::ConditionFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-ConditionFilter.md.txt))
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Raises**

- ([RowFilterError](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilterError.md.txt))
**Example**

```ruby
require "google/cloud/bigtable"

predicate = Google::Cloud::Bigtable::RowFilter.key "user-*"

label = Google::Cloud::Bigtable::RowFilter.label "user"
strip_value = Google::Cloud::Bigtable::RowFilter.strip_value

condition_filter = Google::Cloud::Bigtable::RowFilter.condition(predicate)
                                                     .on_match(label)
                                                     .otherwise(strip_value)

filter = Google::Cloud::Bigtable::RowFilter.interleave.condition condition_filter
```

### #family

```ruby
def family(regex) -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
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.

<br />

For Regex syntax:
**Parameter**

- **regex** (String) --- Regex to match family name.
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Example**

```ruby
require "google/cloud/bigtable"

filter = Google::Cloud::Bigtable::RowFilter.interleave.family "cf-*"
```

### #filters

```ruby
def filters() -> Array<SimpleFilter|ChainFilter|InterleaveFilter|ConditionFilter>
```
Returns a frozen copy of the filters array.
**Returns**

- (Array\<SimpleFilter\|ChainFilter\|InterleaveFilter\|ConditionFilter\>)

### #interleave

```ruby
def interleave(filter) -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
Adds an 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,bar,10,x             foo,bar,10,z              far,bar,7,a
    2: foo,blah,11,z            far,blah,5,x              far,blah,5,x
           |                         |                         |
           ---
                                     |
    1:                      foo,bar,10,z   # could have switched with #2
    2:                      foo,bar,10,x   # could have switched with #1
    3:                      foo,blah,11,z
    4:                      far,bar,7,a
    5:                      far,blah,5,x   # identical to #6
    6:                      far,blah,5,x   # identical to #5

<br />

All interleaved filters are executed atomically.
**Parameter**

- **filter** ([SimpleFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-SimpleFilter.md.txt), [ChainFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-ChainFilter.md.txt), [InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt), [ConditionFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-ConditionFilter.md.txt))
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Raises**

- ([RowFilterError](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilterError.md.txt))
**Example**

Add an interleave filter to a chain filter.

```ruby
require "google/cloud/bigtable"

interleave = Google::Cloud::Bigtable::RowFilter.interleave

# Add filters to an interleave filter.
interleave.key("user-*").cells_per_column(3)

filter = Google::Cloud::Bigtable::RowFilter.interleave.interleave interleave
```

### #key

```ruby
def key(regex) -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
Adds a row-key filter instance to match key 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.

<br />

For Regex syntax:
**Parameter**

- **regex** (String) --- Regex to match row keys.
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Example**

```ruby
require "google/cloud/bigtable"

filter = Google::Cloud::Bigtable::RowFilter.interleave.key "user-*"
```

### #label

```ruby
def label(value) -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
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 in length, and match the RE2
pattern `[a-z0-9\-]+`.

<br />

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 which contains a `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.
**Parameter**

- **value** (String) --- Label name
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Example**

```ruby
require "google/cloud/bigtable"

filter = Google::Cloud::Bigtable::RowFilter.interleave.label "user-detail"
```

### #length

```ruby
def length() -> Integer
```
Returns the number of filters in the interleave.
**Returns**

- (Integer)
**Example**

```ruby
require "google/cloud/bigtable"

filter = Google::Cloud::Bigtable::RowFilter.interleave.key("user-1*").label("user")
filter.length # 2
```

### #pass

```ruby
def pass() -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
Adds a pass filter.


<br />

Matches all cells, regardless of input. Functionally equivalent to
leaving `filter` unset, but included for completeness.
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Example**

```ruby
require "google/cloud/bigtable"

filter = Google::Cloud::Bigtable::RowFilter.interleave.pass
```

### #qualifier

```ruby
def qualifier(regex) -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
Adds 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.

<br />

For Regex syntax:
**Parameter**

- **regex** (String) --- Regex to match column qualifier name.
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Example**

```ruby
require "google/cloud/bigtable"

filter = Google::Cloud::Bigtable::RowFilter.interleave.qualifier "user-name*"
```

### #sample

```ruby
def sample(probability) -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
Adds a sample-probability filter.


<br />

Matches all cells from a row with probability p, and matches no cells
from the row with probability 1-p.
**Parameter**

- **probability** (Float) --- Probability value. Probability must be greater than 0 and less than 1.0.
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Example**

```ruby
require "google/cloud/bigtable"

filter = Google::Cloud::Bigtable::RowFilter.interleave.sample 0.5
```

### #sink

```ruby
def sink() -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
Adds a sink filter.


<br />

Outputs all cells directly to the output of the read rather than to any parent filter.
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Example**

```ruby
require "google/cloud/bigtable"

filter = Google::Cloud::Bigtable::RowFilter.interleave.sink
```

### #strip_value

```ruby
def strip_value() -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
Adds a strip-value filter.


<br />

Replaces each cell's value with an empty string.
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Example**

```ruby
require "google/cloud/bigtable"

filter = Google::Cloud::Bigtable::RowFilter.interleave.strip_value
```

### #timestamp_range

```ruby
def timestamp_range(from: nil, to: nil) -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
Adds a timestamp-range filter.


<br />

Matches only cells with timestamps within the given range.
Specifies a contiguous range of timestamps.
**Parameters**

- **from** (Integer) *(defaults to: nil)* --- Inclusive lower bound. If left empty, interpreted as 0.
- **to** (Integer) *(defaults to: nil)* --- Exclusive upper bound. If left empty, interpreted as infinity.
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Example**

```ruby
require "google/cloud/bigtable"

timestamp_micros = (Time.now.to_f * 1_000_000).round(-3)
from = timestamp_micros - 300_000_000
to = timestamp_micros

filter = Google::Cloud::Bigtable::RowFilter.interleave.timestamp_range from: from, to: to
```

### #value

```ruby
def value(regex) -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
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.

<br />

For Regex syntax:
**Parameter**

- **regex** (String) --- Regex to match cell value.
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Example**

```ruby
require "google/cloud/bigtable"

filter = Google::Cloud::Bigtable::RowFilter.interleave.value "abc*"
```

### #value_range

```ruby
def value_range(range) -> Google::Cloud::Bigtable::RowFilter::InterleaveFilter
```
Adds a value-range filter.

Matches only cells with values that fall within the given range.

See [ValueRange#from](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-ValueRange.md.txt#Google__Cloud__Bigtable__ValueRange_from_instance_ "Google::Cloud::Bigtable::ValueRange#from (method)") 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 an infinite string, exclusive.
**Parameter**

- **range** ([Google::Cloud::Bigtable::ValueRange](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-ValueRange.md.txt))
**Returns**

- ([Google::Cloud::Bigtable::RowFilter::InterleaveFilter](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigtable/latest/Google-Cloud-Bigtable-RowFilter-InterleaveFilter.md.txt)) --- `self` instance of interleave filter.
**Examples**

Start to end range.

```ruby
require "google/cloud/bigtable"

bigtable = Google::Cloud::Bigtable.new
table = bigtable.table "my-instance", "my-table"

range = table.new_value_range.from("value-001").to("value-005")
filter = Google::Cloud::Bigtable::RowFilter.interleave.value_range range
```

Start exlusive to infinite end range.

```ruby
require "google/cloud/bigtable"

bigtable = Google::Cloud::Bigtable.new
table = bigtable.table "my-instance", "my-table"

range = table.new_value_range.from "value-001", inclusive: false
filter = Google::Cloud::Bigtable::RowFilter.interleave.value_range range
```