Class Filter (3.5.4)

A filter takes a row as input and produces an alternate view of the row based on specified rules. For example, a row filter might trim down a row to include just the cells from columns matching a given regular expression, or might return all the cells of a row but not their values. More complicated filters can be composed out of these components to express requests such as, "within every column of a particular family, give just the two most recent cells which are older than timestamp X."

There are two broad categories of filters (true filters and transformers), as well as two ways to compose simple filters into more complex ones (). They work as follows:

True filters alter the input row by excluding some of its cells wholesale from the output row. An example of a true filter is the filter, which excludes cells whose values don't match the specified pattern. All regex true filters use RE2 syntax (https://github.com/google/re2/wiki/Syntax) and are evaluated as full matches. An important point to keep in mind is that RE2(.) is equivalent by default to RE2([^\n]), meaning that it does not match newlines. When attempting to match an arbitrary byte, you should therefore use the escape sequence '\C', which may need to be further escaped as '\C' in your client language.

Transformers alter the input row by changing the values of some of its cells in the output, without excluding them completely. Currently, the only supported transformer is the strip filter, which replaces every cell's value with the empty string.

The total serialized size of a filter message must not exceed 4096 bytes, and filters may not be nested within each other to a depth of more than 20.

Use the following table for the various examples found throughout the filter documentation.

| Row Key | follows:gwashington | follows:jadams | follows:tjefferson | | ----------- |:-------------------:|:--------------:|:------------------:| | gwashington | | 1 | | | tjefferson | 1 | 1 | | | jadams | 1 | | 1 |

Package

@google-cloud/bigtable!

Constructors

(constructor)()

constructor();

Constructs a new instance of the Filter class

Properties

filters_

filters_: Array<{
        [index: string]: {};
    }>;
Property Value
TypeDescription
Array<{ [index: string]: {}; }>

Methods

all(pass)

all(pass: boolean): void;

Sets passAllFilter or blockAllFilter

Parameter
NameDescription
pass boolean

Whether to passAllFilter or blockAllFilter

Assign true for enabling passAllFilter and false for enabling blockAllFilter

Returns
TypeDescription
void

column(column)

column(column: RegExp | string | {}): void;

Matches only cells from columns whose qualifiers satisfy the given RE2 regex.

Parameter
NameDescription
column RegExp | string | {}

Matching Column to filter with

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.

Returns
TypeDescription
void

condition(condition)

condition(condition: Condition): void;

A filter which evaluates one of two possible filters, depending on whether or not a test filter outputs any cells from the input row.

IMPORTANT NOTE: The test filter does not execute atomically with the pass and fail filters, which may lead to inconsistent or unexpected results. Additionally, condition filters have poor performance, especially when filters are set for the fail condition.

Parameter
NameDescription
condition Condition

Condition to filter.

Returns
TypeDescription
void

convertToRegExpString(regex)

static convertToRegExpString(regex: RegExp | RegExp[] | string | string[] | Buffer | Buffer[] | number | number[]): string | Buffer;
Parameter
NameDescription
regex RegExp | RegExp[] | string | string[] | Buffer | Buffer[] | number | number[]

Either a plain regex, a regex in string form or an array of strings.

Returns
TypeDescription
string | Buffer

{string}

createRange(start, end, key)

static createRange(start: BoundData | null, end: BoundData | null, key: string): {};

Creates a range object. All bounds default to inclusive.

Parameters
NameDescription
start BoundData | null

Lower bound value.

end BoundData | null

Upper bound value.

key string

Key used to create range value keys.

Returns
TypeDescription
{}

{object}

family(family)

family(family: RegExp | string | number | Buffer | RegExp[] | string[] | number[] | Buffer[]): void;

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.

Parameter
NameDescription
family RegExp | string | number | Buffer | RegExp[] | string[] | number[] | Buffer[]

Expression to filter family

Returns
TypeDescription
void

interleave(filters)

interleave(filters: RawFilter[]): void;

Applies several filters to the data in parallel and combines the results.

Parameter
NameDescription
filters RawFilter[]

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. All interleaved filters are executed atomically.

Returns
TypeDescription
void

label(label)

label(label: string): void;

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.

Parameter
NameDescription
label string

Label to determine filter point Values must be at most 15 characters in length, and match the RE2 pattern [a-z0-9\-]+

Due to a technical limitation, it is not currently possible to apply multiple labels to a cell. As a result, a chain filter may have no more than one sub-filter which contains a apply label transformer. It is okay for an to contain multiple apply label transformers, as they will be applied to separate copies of the input. This may be relaxed in the future.

Returns
TypeDescription
void

parse(filters)

static parse(filters: RawFilter[] | RawFilter): {} | null;
Parameter
NameDescription
filters RawFilter[] | RawFilter

The list of filters to be parsed.

Returns
TypeDescription
{} | null

{object}

row(row)

row(row: Row | string | RegExp | string[]): void;

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.

Parameter
NameDescription
row Row | string | RegExp | string[]

Row format to Filter

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.

Returns
TypeDescription
void

set(key, value)

set(key: string, value: {}): void;

Stores a filter object.

Parameters
NameDescription
key string

Filter name.

value {}

Filter value.

Returns
TypeDescription
void

sink(sink)

sink(sink: boolean): void;

This filter is meant for advanced use only. Hook for introspection into the filter. Outputs all cells directly to the output of the read rather than to any parent filter. Despite being excluded by the qualifier filter, a copy of every cell that reaches the sink is present in the final result. As with an filter, duplicate cells are possible, and appear in an unspecified mutual order.

Cannot be used within filter.

Parameter
NameDescription
sink boolean
Returns
TypeDescription
void

time(time)

time(time: Time): void;

Matches only cells with timestamps within the given range.

Parameter
NameDescription
time Time

Start and End time Object

Returns
TypeDescription
void

toProto()

toProto(): null | {};

If we detect multiple filters, we'll assume it's a chain filter and the execution of the filters will be the order in which they were specified.

Returns
TypeDescription
null | {}

value(value)

value(value: string | string[] | ValueFilter): void;

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.

Parameter
NameDescription
value string | string[] | ValueFilter

Value to filter cells

Returns
TypeDescription
void