Class: Google::Cloud::Spanner::Snapshot
- Inherits:
-
Object
- Object
- Google::Cloud::Spanner::Snapshot
- Defined in:
- lib/google/cloud/spanner/snapshot.rb
Overview
Snapshot
A snapshot in Cloud Spanner is a set of reads that execute atomically at a single logical point in time across columns, rows, and tables in a database.
Instance Method Summary collapse
-
#execute_query(sql, params: nil, types: nil, query_options: nil, request_options: nil, call_options: nil, directed_read_options: nil) ⇒ Google::Cloud::Spanner::Results
(also: #execute, #query, #execute_sql)
Executes a SQL query.
-
#fields(types) ⇒ Fields
Creates a configuration object (Fields) that may be provided to queries or used to create STRUCT objects.
-
#range(beginning, ending, exclude_begin: false, exclude_end: false) ⇒ Google::Cloud::Spanner::Range
Creates a Cloud Spanner Range.
-
#read(table, columns, keys: nil, index: nil, limit: nil, request_options: nil, call_options: nil, directed_read_options: nil) ⇒ Google::Cloud::Spanner::Results
Read rows from a database table, as a simple alternative to #execute_query.
-
#timestamp ⇒ Time
The read timestamp chosen for snapshots.
-
#transaction_id ⇒ String
Identifier of the transaction results were run in.
Instance Method Details
#execute_query(sql, params: nil, types: nil, query_options: nil, request_options: nil, call_options: nil, directed_read_options: nil) ⇒ Google::Cloud::Spanner::Results Also known as: execute, query, execute_sql
Executes a SQL query.
The following settings can be provided:
:exclude_replicas(Hash) Exclude_replicas indicates what replicas should be excluded from serving requests. Spanner will not route requests to the replicas in this list.:include_replicas(Hash) Include_replicas indicates the order of replicas to process the request. If auto_failover_disabled is set to true and all replicas are exhausted without finding a healthy replica, Spanner will wait for a replica in the list to become available, requests may fail due to DEADLINE_EXCEEDED errors.
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/google/cloud/spanner/snapshot.rb', line 335 def execute_query sql, params: nil, types: nil, query_options: nil, request_options: nil, call_options: nil, directed_read_options: nil ensure_session! params, types = Convert.to_input_params_and_types params, types = Convert. , tag_type: :request_tag session.execute_query sql, params: params, types: types, transaction: tx_selector, query_options: , request_options: , call_options: , directed_read_options: || end |
#fields(types) ⇒ Fields
Creates a configuration object (Fields) that may be provided to queries or used to create STRUCT objects. (The STRUCT will be represented by the Data class.) See Client#execute and/or Fields#struct.
For more information, see Data Types - Constructing a STRUCT.
517 518 519 |
# File 'lib/google/cloud/spanner/snapshot.rb', line 517 def fields types Fields.new types end |
#range(beginning, ending, exclude_begin: false, exclude_end: false) ⇒ Google::Cloud::Spanner::Range
Creates a Cloud Spanner Range. This can be used in place of a Ruby Range when needing to exclude the beginning value.
550 551 552 553 554 |
# File 'lib/google/cloud/spanner/snapshot.rb', line 550 def range beginning, ending, exclude_begin: false, exclude_end: false Range.new beginning, ending, exclude_begin: exclude_begin, exclude_end: exclude_end end |
#read(table, columns, keys: nil, index: nil, limit: nil, request_options: nil, call_options: nil, directed_read_options: nil) ⇒ Google::Cloud::Spanner::Results
Read rows from a database table, as a simple alternative to #execute_query.
The following settings can be provided:
:exclude_replicas(Hash) Exclude_replicas indicates what replicas should be excluded from serving requests. Spanner will not route requests to the replicas in this list.:include_replicas(Hash) Include_replicas indicates the order of replicas to process the request. If auto_failover_disabled is set to true and all replicas are exhausted without finding a healthy replica, Spanner will wait for a replica in the list to become available, requests may fail due to DEADLINE_EXCEEDED errors.
427 428 429 430 431 432 433 434 435 436 437 438 439 |
# File 'lib/google/cloud/spanner/snapshot.rb', line 427 def read table, columns, keys: nil, index: nil, limit: nil, request_options: nil, call_options: nil, directed_read_options: nil ensure_session! columns = Array(columns).map(&:to_s) keys = Convert.to_key_set keys session.read table, columns, keys: keys, index: index, limit: limit, transaction: tx_selector, request_options: , call_options: , directed_read_options: || end |
#timestamp ⇒ Time
The read timestamp chosen for snapshots.
75 76 77 78 |
# File 'lib/google/cloud/spanner/snapshot.rb', line 75 def return nil if @grpc.nil? Convert. @grpc. end |
#transaction_id ⇒ String
Identifier of the transaction results were run in.
67 68 69 70 |
# File 'lib/google/cloud/spanner/snapshot.rb', line 67 def transaction_id return nil if @grpc.nil? @grpc.id end |