class Google::Cloud::Bigtable::RowFilter::ConditionFilter

# 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.

@example

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)

Public Class Methods

new(predicate) click to toggle source

@private Creates a condition filter instance.

@param predicate [SimpleFilter, ChainFilter, InterleaveFilter, ConditionFilter]

# File lib/google/cloud/bigtable/row_filter/condition_filter.rb, line 50
def initialize predicate
  @grpc = Google::Cloud::Bigtable::V2::RowFilter::Condition.new
  @grpc.predicate_filter = predicate.to_grpc
end

Public Instance Methods

on_match(filter) click to toggle source

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.

@param filter [SimpleFilter, ChainFilter, InterleaveFilter, ConditionFilter] @return [Google::Cloud::Bigtable::RowFilter::ConditionFilter]

@example

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)
# 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) click to toggle source

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.

@param filter [SimpleFilter, ChainFilter, InterleaveFilter, ConditionFilter] @return [Google::Cloud::Bigtable::RowFilter::ConditionFilter]

@example

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)
# File lib/google/cloud/bigtable/row_filter/condition_filter.rb, line 98
def otherwise filter
  @grpc.false_filter = filter.to_grpc
  self
end
to_grpc() click to toggle source

@private Gets the row-filter gRPC instance. @return [Google::Cloud::Bigtable::V2::RowFilter]

# File lib/google/cloud/bigtable/row_filter/condition_filter.rb, line 107
def to_grpc
  Google::Cloud::Bigtable::V2::RowFilter.new condition: @grpc
end