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 to and including "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 and 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.



58
59
60
# File 'lib/google/cloud/bigtable/column_range.rb', line 58

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

Instance Method Details

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

Sets the 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:



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

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

#familyString

Gets the column family name.

Returns:

  • (String)


67
68
69
# File 'lib/google/cloud/bigtable/column_range.rb', line 67

def family
  @grpc.family_name
end

#family=(name) ⇒ Object

Sets the column family name.

Parameters:

  • name (String)

    Column family name



76
77
78
# File 'lib/google/cloud/bigtable/column_range.rb', line 76

def family= name
  @grpc.family_name = name
end

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

Sets the 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) (defaults to: true)

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

Returns:



104
105
106
107
108
109
110
111
# File 'lib/google/cloud/bigtable/column_range.rb', line 104

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

Sets the 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:



180
181
182
# File 'lib/google/cloud/bigtable/column_range.rb', line 180

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

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

Sets the 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) (defaults to: false)

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

Returns:



137
138
139
140
141
142
143
144
# File 'lib/google/cloud/bigtable/column_range.rb', line 137

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