Reference documentation and code samples for the Cloud Spanner API class Google::Cloud::Spanner::Partition.
Partition
Defines the segments of data to be read in a batch read/query context. A Partition instance can be serialized and used across several different machines or processes.
See BatchSnapshot#partition_read, BatchSnapshot#partition_query, and BatchSnapshot#execute_partition.
Inherits
- Object
Example
require "google/cloud/spanner" spanner = Google::Cloud::Spanner.new batch_client = spanner.batch_client "my-instance", "my-database" batch_snapshot = batch_client.batch_snapshot partitions = batch_snapshot.partition_read "users", [:id, :name] partition = partitions.first results = batch_snapshot.execute_partition partition
Methods
.load
def self.load(data) -> Google::Cloud::Spanner::Partition
Returns a Partition from a serialized representation.
- data (String) — The serialized representation of an existing batch partition. See #dump.
require "google/cloud/spanner" spanner = Google::Cloud::Spanner.new batch_client = spanner.batch_client "my-instance", "my-database" batch_snapshot = batch_client.batch_snapshot partitions = batch_snapshot.partition_read "users", [:id, :name] partition = partitions.first serialized_snapshot = batch_snapshot.dump serialized_partition = partition.dump # In a separate process new_batch_snapshot = batch_client.load_batch_snapshot \ serialized_snapshot new_partition = Google::Cloud::Spanner::Partition.load \ serialized_partition results = new_batch_snapshot.execute_partition \ new_partition
#dump
def dump() -> String
Serializes the batch partition object so it can be recreated on another process. See Partition.load and BatchClient#load_partition.
- (String) — The serialized representation of the batch partition.
require "google/cloud/spanner" spanner = Google::Cloud::Spanner.new batch_client = spanner.batch_client "my-instance", "my-database" batch_snapshot = batch_client.batch_snapshot partitions = batch_snapshot.partition_read "users", [:id, :name] partition = partitions.first serialized_snapshot = batch_snapshot.dump serialized_partition = partition.dump # In a separate process new_batch_snapshot = batch_client.load_batch_snapshot \ serialized_snapshot new_partition = batch_client.load_partition \ serialized_partition results = new_batch_snapshot.execute_partition \ new_partition
#execute
def execute()
@ private
#execute?
def execute?() -> Boolean
Whether the partition was created for an execute_query/query operation.
- (Boolean)
#execute_query?
def execute_query?() -> Boolean
Whether the partition was created for an execute_query/query operation.
- (Boolean)
#execute_sql?
def execute_sql?() -> Boolean
Whether the partition was created for an execute_query/query operation.
- (Boolean)
#query?
def query?() -> Boolean
Whether the partition was created for an execute_query/query operation.
- (Boolean)
#read
def read()
Returns the value of attribute read.
#read?
def read?() -> Boolean
Whether the partition was created for a read operation.
- (Boolean)
#serialize
def serialize() -> String
Serializes the batch partition object so it can be recreated on another process. See Partition.load and BatchClient#load_partition.
- (String) — The serialized representation of the batch partition.
require "google/cloud/spanner" spanner = Google::Cloud::Spanner.new batch_client = spanner.batch_client "my-instance", "my-database" batch_snapshot = batch_client.batch_snapshot partitions = batch_snapshot.partition_read "users", [:id, :name] partition = partitions.first serialized_snapshot = batch_snapshot.dump serialized_partition = partition.dump # In a separate process new_batch_snapshot = batch_client.load_batch_snapshot \ serialized_snapshot new_partition = batch_client.load_partition \ serialized_partition results = new_batch_snapshot.execute_partition \ new_partition