Class: Google::Cloud::Bigtable::ColumnRange

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

Overview

ColumnRange

Specifies a contiguous range of column qualifiers.

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

Examples:

require "google/cloud/bigtable"

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

# Range that includes all qualifiers including "user-001" up until "user-010"
table.new_column_range("cf").from("user-001").to("user-010")

# Range that includes all qualifiers including "user-001" up incluing "user-005"
table.new_column_range("cf").from("user-001").to("user-005", inclusive: true)

# Range that includes all qualifiers until end of the row key "user-001".
table.new_column_range("cf").to("user-010") # exclusive

# Range with unbounded start and the inclusive end "user-100"
table.new_column_range("cf").to("user-100", inclusive: true)

# Range that includes all qualifiers including "user-001" up to including "user-100"
table.new_column_range("cf").between("user-001", "user-100")

Instance Method Summary collapse

Constructor Details

#initialize(family) ⇒ ColumnRange

Create qualifier range instance.

Parameters:

  • family (String)

    Column family name.



56
57
58
# File 'lib/google/cloud/bigtable/column_range.rb', line 56

def initialize family
  @grpc = Google::Bigtable::V2::ColumnRange.new(family_name: family)
end

Instance Method Details

#between(from_qualifier, to_qualifier) ⇒ Google::Cloud::Bigtable::ColumnRange

Set column range with the inclusive upper and lower bound.

Examples:

require "google/cloud/bigtable"

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

table.new_column_range("cf").between("qualifier-1", "qualifier-10")

Parameters:

  • from_qualifier (String)

    Inclusive from qualifier. Required

  • to_qualifier (String)

    Inclusive to qualifier. Required

Returns:



154
155
156
# File 'lib/google/cloud/bigtable/column_range.rb', line 154

def between from_qualifier, to_qualifier
  from(from_qualifier).to(to_qualifier, inclusive: true)
end

#familyString

Get column family name

Returns:

  • (String)


64
65
66
# File 'lib/google/cloud/bigtable/column_range.rb', line 64

def family
  @grpc.family_name
end

#family=(name) ⇒ Object

Set column family name

Parameters:

  • name (String)

    Column family name



72
73
74
# File 'lib/google/cloud/bigtable/column_range.rb', line 72

def family= name
  @grpc.family_name = name
end

#from(qualifier, inclusive: true) ⇒ Google::Cloud::Bigtable::ColumnRange

Set column 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")

table.new_column_range("cf").from("qualifier-1")

Exclusive lower bound.

require "google/cloud/bigtable"

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

table.new_column_range("cf").from("qualifier-1", inclusive: false)

Parameters:

  • qualifier (String)

    Column qualifier name. Required

  • inclusive (String)

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

Returns:



99
100
101
102
103
104
105
106
# File 'lib/google/cloud/bigtable/column_range.rb', line 99

def from qualifier, inclusive: true
  if inclusive
    @grpc.start_qualifier_closed = qualifier
  else
    @grpc.start_qualifier_open = qualifier
  end
  self
end

#of(from_qualifier, to_qualifier) ⇒ Google::Cloud::Bigtable::ColumnRange

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

Examples:

require "google/cloud/bigtable"

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

table.new_column_range("cf").of("qualifier-1", "qualifier-10")

Parameters:

  • from_qualifier (String)

    Inclusive from qualifier

  • to_qualifier (String)

    Exclusive to qualifier

Returns:



172
173
174
# File 'lib/google/cloud/bigtable/column_range.rb', line 172

def of from_qualifier, to_qualifier
  from(from_qualifier).to(to_qualifier)
end

#to(qualifier, inclusive: false) ⇒ Google::Cloud::Bigtable::ColumnRange

Set column 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")

table.new_column_range("cf").to("qualifier-10", inclusive: true)

Exclusive upper bound.

require "google/cloud/bigtable"

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

table.new_column_range("cf").to("qualifier-10")

Parameters:

  • qualifier (String)

    Column qualifier name. Required

  • inclusive (String)

    Upper bound flag. Inclusive/Exclusive.. Default it is an inclusive upper bound.

Returns:



131
132
133
134
135
136
137
138
# File 'lib/google/cloud/bigtable/column_range.rb', line 131

def to qualifier, inclusive: false
  if inclusive
    @grpc.end_qualifier_closed = qualifier
  else
    @grpc.end_qualifier_open = qualifier
  end
  self
end