Cloud Spanner API - Class Google::Cloud::Spanner::Partition (v2.23.0)

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.

Parameter
  • data (String) — The serialized representation of an existing batch partition. See #dump.
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 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
Aliases

Serializes the batch partition object so it can be recreated on another process. See Partition.load and BatchClient#load_partition.

Returns
  • (String) — The serialized representation of the batch partition.
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 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
Alias Of: #execute_query?

Whether the partition was created for an execute_query/query operation.

Returns
  • (Boolean)

#execute_query?

def execute_query?() -> Boolean

Whether the partition was created for an execute_query/query operation.

Returns
  • (Boolean)

#execute_sql?

def execute_sql?() -> Boolean
Alias Of: #execute_query?

Whether the partition was created for an execute_query/query operation.

Returns
  • (Boolean)

#query?

def query?() -> Boolean
Alias Of: #execute_query?

Whether the partition was created for an execute_query/query operation.

Returns
  • (Boolean)

#read

def read()

Returns the value of attribute read.

#read?

def read?() -> Boolean

Whether the partition was created for a read operation.

Returns
  • (Boolean)

#serialize

def serialize() -> String
Alias Of: #dump

Serializes the batch partition object so it can be recreated on another process. See Partition.load and BatchClient#load_partition.

Returns
  • (String) — The serialized representation of the batch partition.
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 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