Module: Google::Cloud::Bigtable::ReadOperations
- Included in:
- Table
- Defined in:
- lib/google/cloud/bigtable/read_operations.rb
Overview
ReadOperations
Collection of read rows apis.
- Sample row key
- Read row
- Read rows
Instance Method Summary collapse
-
#filter ⇒ Google::Cloud::Bigtable::RowRange
Get row filter.
-
#new_column_range(family) ⇒ Google::Cloud::Bigtable::ColumnRange
Get new instance of ColumnRange.
-
#new_row_range ⇒ Google::Cloud::Bigtable::RowRange
Get new instance of RowRange.
-
#new_value_range ⇒ Google::Cloud::Bigtable::ValueRange
Create new instance of ValueRange.
-
#read_row(key, filter: nil) ⇒ Google::Cloud::Bigtable::Row
Read single row by key.
-
#read_rows(keys: nil, ranges: nil, filter: nil, limit: nil, &block) ⇒ Array<Google::Cloud::Bigtable::Row> | :yields: row
Read rows.
-
#sample_row_keys ⇒ :yields: sample_row_key
Read sample row keys.
Instance Method Details
#filter ⇒ Google::Cloud::Bigtable::RowRange
Get row filter
319 320 321 |
# File 'lib/google/cloud/bigtable/read_operations.rb', line 319 def filter Google::Cloud::Bigtable::RowFilter end |
#new_column_range(family) ⇒ Google::Cloud::Bigtable::ColumnRange
Get new instance of ColumnRange.
274 275 276 |
# File 'lib/google/cloud/bigtable/read_operations.rb', line 274 def new_column_range family Google::Cloud::Bigtable::ColumnRange.new(family) end |
#new_row_range ⇒ Google::Cloud::Bigtable::RowRange
Get new instance of RowRange.
303 304 305 |
# File 'lib/google/cloud/bigtable/read_operations.rb', line 303 def new_row_range Google::Cloud::Bigtable::RowRange.new end |
#new_value_range ⇒ Google::Cloud::Bigtable::ValueRange
Create new instance of ValueRange.
244 245 246 |
# File 'lib/google/cloud/bigtable/read_operations.rb', line 244 def new_value_range Google::Cloud::Bigtable::ValueRange.new end |
#read_row(key, filter: nil) ⇒ Google::Cloud::Bigtable::Row
Read single row by key
215 216 217 |
# File 'lib/google/cloud/bigtable/read_operations.rb', line 215 def read_row key, filter: nil read_rows(keys: [key], filter: filter).first end |
#read_rows(keys: nil, ranges: nil, filter: nil, limit: nil, &block) ⇒ Array<Google::Cloud::Bigtable::Row> | :yields: row
Read rows
Streams back the contents of all requested rows in key order, optionally
applying the same Reader filter to each.
read_rows
, row_ranges
and filter
if not specified, reads from all rows.
See Google::Cloud::Bigtable::RowFilter for filter types.
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/google/cloud/bigtable/read_operations.rb', line 151 def read_rows \ keys: nil, ranges: nil, filter: nil, limit: nil, &block unless block_given? return enum_for( :read_rows, keys: keys, ranges: ranges, filter: filter, limit: limit ) end row_set = build_row_set(keys, ranges) rows_limit = limit rows_filter = filter.to_grpc if filter rows_reader = RowsReader.new(self) begin rows_reader.read( rows: row_set, filter: rows_filter, rows_limit: rows_limit, &block ) rescue *RowsReader::RETRYABLE_ERRORS => e rows_reader.retry_count += 1 unless rows_reader.retryable? raise Google::Cloud::Error.from_error(e) end rows_limit, row_set = rows_reader.(limit, row_set) retry end end |
#sample_row_keys ⇒ :yields: sample_row_key
Read sample row keys.
Returns a sample of row keys in the table. The returned row keys will delimit contiguous sections of the table of approximately equal size, which can be used to break up the data for distributed tasks like mapreduces.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/google/cloud/bigtable/read_operations.rb', line 58 def sample_row_keys return enum_for(:sample_row_keys) unless block_given? response = client.sample_row_keys( path, app_profile_id: @app_profile_id ) response.each do |grpc| yield SampleRowKey.from_grpc(grpc) end end |