Class: Google::Cloud::Bigtable::RowFilter::ConditionFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/bigtable/row_filter/condition_filter.rb

Overview

ConditionFilter

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.

If predicate_filter outputs any cells, then true_filter will be evaluated on the input row. Otherwise, false_filter will be evaluated.

Examples:

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

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

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

Instance Method Summary collapse

Instance Method Details

#on_match(filter) ⇒ Google::Cloud::Bigtable::RowFilter::ConditionFilter

Sets a true filter on predicate-filter match.

The filter to apply to the input row if predicate_filter returns any results. If not provided, no results will be returned in the true case.

Examples:

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

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

Parameters:

Returns:



73
74
75
76
# File 'lib/google/cloud/bigtable/row_filter/condition_filter.rb', line 73

def on_match filter
  @grpc.true_filter = filter.to_grpc
  self
end

#otherwise(filter) ⇒ Google::Cloud::Bigtable::RowFilter::ConditionFilter

Set otherwise(false) filter.

The filter to apply to the input row if predicate_filter does not return any results. If not provided, no results will be returned in the false case.

Examples:

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

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

Parameters:

Returns:



98
99
100
101
# File 'lib/google/cloud/bigtable/row_filter/condition_filter.rb', line 98

def otherwise filter
  @grpc.false_filter = filter.to_grpc
  self
end