Class: Google::Cloud::Bigtable::RowRange

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

Overview

RowRange

Specifies a contiguous range of rows.

  • from key bound : The row key at which to from the range. If neither field is set, interpreted as the empty string, inclusive.
  • End key bound: The row key at which to end the range. If neither field is set, interpreted as the infinite row key, 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 "user-001" to "user-005"
table.new_row_range.from("user-001").to("user-005", inclusive: true)

# Range that includes all row keys including "user-001" up to exclusive "user-010".
table.new_row_range.from("user-001").to("user-010")

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

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

# Range with unbounded from and the exclusive end "user-010"
table.new_row_range.to("user-010")

# Range that includes all row keys including from and end row keys "user-001", "user-010"
table.new_row_range.between("user-001", "user-010")

# Range that includes all row keys including "user-001" up until "user-010"
table.new_row_range.of("user-001", "user-010")

Instance Method Summary collapse

Instance Method Details

#between(from_key, to_key) ⇒ Google::Cloud::Bigtable::RowRange

Set row range with the inclusive upper and lower bounds.

Examples:

require "google/cloud/bigtable"

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

range = table.new_row_range.between("key-001", "key-010")

Parameters:

  • from_key (String)

    Inclusive from row key. Required

  • to_key (String)

    Inclusive end row key. Required

Returns:



141
142
143
# File 'lib/google/cloud/bigtable/row_range.rb', line 141

def between from_key, to_key
  from(from_key).to(to_key, inclusive: true)
end

#from(key, inclusive: true) ⇒ Google::Cloud::Bigtable::RowRange

Set 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_row_range.from("key-001")

Exclusive lower bound.

require "google/cloud/bigtable"

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

range = table.new_row_range.from("key-001", inclusive: false)

Parameters:

  • key (String)

    Row key. Required

  • inclusive (String)

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

Returns:



85
86
87
88
89
90
91
92
# File 'lib/google/cloud/bigtable/row_range.rb', line 85

def from key, inclusive: true
  if inclusive
    @grpc.start_key_closed = key
  else
    @grpc.start_key_open = key
  end
  self
end

#of(from_key, to_key) ⇒ Google::Cloud::Bigtable::RowRange

Set row 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_row_range.of("key-001", "key-010")

Parameters:

  • from_key (String)

    Inclusive from row key

  • to_key (String)

    Exclusive end row key

Returns:



160
161
162
# File 'lib/google/cloud/bigtable/row_range.rb', line 160

def of from_key, to_key
  from(from_key).to(to_key)
end

#to(key, inclusive: false) ⇒ Google::Cloud::Bigtable::RowRange

Set row range with the 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_row_range.to("key-001", inclusive: true)

Exclusive upper bound.

require "google/cloud/bigtable"

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

range = table.new_row_range.to("key-001")

Parameters:

  • key (String)

    Row key. Required

  • inclusive (String)

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

Returns:



117
118
119
120
121
122
123
124
# File 'lib/google/cloud/bigtable/row_range.rb', line 117

def to key, inclusive: false
  if inclusive
    @grpc.end_key_closed = key
  else
    @grpc.end_key_open = key
  end
  self
end