Class: Google::Cloud::Bigtable::ValueRange

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

Overview

ValueRange

Specifies a contiguous range of string values.

  • from value bound : The value at which to from the range. If neither field is set, interpreted as the empty string, inclusive.
  • End value bound: The value at which to end the range. If neither field is set, interpreted as the infinite string value, exclusive.

Examples:

require "google/cloud/bigtable"

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

# Range that includes all row keys including "value-001" to "value-005" excluding
table.new_value_range.from("value-001").to("value-005")

# Range that includes all row keys including "value-001" up to inclusive "value-010".
table.new_value_range.from("value-001").to("value-010", inclusive: true)

# Range that includes all row keys including "value-001" up until end of the row keys.
table.new_value_range.from("value-001")

# Range that includes all row keys exclusive "value-001" up until end of the row keys.
table.new_value_range.from("value-001", inclusive: false)

# Range with unbounded from and the exclusive end "value-100"
table.new_value_range.to("value-100")

# Range that includes all row keys including from and end row keys "value-001", "value-100"
table.new_value_range.between("value-001", "value-100")

# Range that includes all row keys including "value-001" up until "value-100"
table.new_value_range.of("value-001", "value-100")

Instance Method Summary collapse

Instance Method Details

#between(from_value, to_value) ⇒ Google::Cloud::Bigtable::ValueRange

Set value range with the inclusive lower and upper bound.

Examples:

require "google/cloud/bigtable"

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

range = table.new_value_range.between("value-001", "value-010")

Parameters:

  • from_value (String)

    Inclusive from value. Required

  • to_value (String)

    Inclusive end value. Required

Returns:



143
144
145
# File 'lib/google/cloud/bigtable/value_range.rb', line 143

def between from_value, to_value
  from(from_value).to(to_value, inclusive: true)
end

#from(value, inclusive: true) ⇒ Google::Cloud::Bigtable::ValueRange

Ser row range with the lower bound.

Examples:

Inclusive lower bound.

require "google/cloud/bigtable"

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

range = table.new_value_range.from("value-001")

Exclusive lower bound.

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)

Parameters:

  • value (String)

    value. Required

  • inclusive (String)

    Inclusive/Exclusive lower bound. Default it is an inclusive lower bound.

Returns:



87
88
89
90
91
92
93
94
# File 'lib/google/cloud/bigtable/value_range.rb', line 87

def from value, inclusive: true
  if inclusive
    @grpc.start_value_closed = value
  else
    @grpc.start_value_open = value
  end
  self
end

#of(from_value, to_value) ⇒ Google::Cloud::Bigtable::ValueRange

Set value range with the inclusive lower and the exclusive upper bound.

Examples:

require "google/cloud/bigtable"

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

range = table.new_value_range.of("value-001", "value-010")

Parameters:

  • from_value (String)

    Inclusive from value

  • to_value (String)

    Exclusive to value

Returns:



161
162
163
# File 'lib/google/cloud/bigtable/value_range.rb', line 161

def of from_value, to_value
  from(from_value).to(to_value)
end

#to(value, inclusive: false) ⇒ Google::Cloud::Bigtable::ValueRange

Set value range with upper bound.

Examples:

Inclusive upper bound.

require "google/cloud/bigtable"

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

range = table.new_value_range.to("value-010", inclusive: true)

Exclusive upper bound.

require "google/cloud/bigtable"

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

range = table.new_value_range.to("value-010")

Parameters:

  • value (String)

    value. Required

  • inclusive (String)

    Inclusive/Exclusive upper bound. Default it is an exclusive upper bound.

Returns:



119
120
121
122
123
124
125
126
# File 'lib/google/cloud/bigtable/value_range.rb', line 119

def to value, inclusive: false
  if inclusive
    @grpc.end_value_closed = value
  else
    @grpc.end_value_open = value
  end
  self
end