Google Cloud Spanner C++ Client
A C++ Client Library for Google Cloud Spanner
Classes | Typedefs | Enumerations | Functions
google::cloud::spanner::v1 Namespace Reference

The inlined, versioned namespace for the Cloud Spanner C++ client APIs. More...

Classes

class  Backup
 This class identifies a Cloud Spanner Backup. More...
 
struct  BatchDmlResult
 The result of executing a batch of DML statements. More...
 
class  Bytes
 A representation of the Spanner BYTES type: variable-length binary data. More...
 
class  Client
 Performs database client operations on Spanner. More...
 
class  ClientOptions
 ClientOptions allows the caller to set a variety of options when constructing a Client instance. More...
 
struct  CommitResult
 The result of committing a Transaction. More...
 
struct  CommitTimestamp
 A sentinel type used to update a commit timestamp column. More...
 
class  Connection
 A connection to a Spanner database instance. More...
 
struct  ConnectionOptionsTraits
 The traits to configure ConnectionOptions<T> for Cloud Spanner. More...
 
class  CreateInstanceRequestBuilder
 CreateInstanceRequestBuilder is a builder class for google::spanner::admin::instance::v1::CreateInstanceRequest More...
 
class  Database
 This class identifies a Cloud Spanner Database. More...
 
class  DatabaseAdminClient
 Performs database administration operations on Spanner. More...
 
class  DatabaseAdminConnection
 A connection to the Cloud Spanner instance administration service. More...
 
class  Date
 Represents a date in the proleptic Gregorian calendar as a triple of year, month (1-12), and day (1-31). More...
 
class  DmlResult
 Represents the result of a data modifying operation using spanner::Client::ExecuteDml(). More...
 
class  GenericPollingPolicy
 Combine a RetryPolicy and a BackoffPolicy to create simple polling policies. More...
 
class  Instance
 This class identifies a Cloud Spanner Instance. More...
 
class  InstanceAdminClient
 Performs instance administration operations on Cloud Spanner. More...
 
class  InstanceAdminConnection
 A connection to the Cloud Spanner instance administration service. More...
 
class  KeyBound
 The KeyBound class is a regular type that represents an open or closed endpoint for a range of keys. More...
 
class  KeySet
 The KeySet class is a regular type that represents a collection of Keys. More...
 
class  Mutation
 A wrapper for Cloud Spanner mutations. More...
 
struct  PartitionedDmlResult
 The result of executing a Partitioned DML query. More...
 
struct  PartitionOptions
 Options passed to Client::PartitionRead or Client::PartitionQuery. More...
 
class  PollingPolicy
 Control the Cloud Spanner C++ client library behavior with respect to polling on long running operations. More...
 
class  ProfileDmlResult
 Represents the result and profile stats of a data modifying operation using spanner::Client::ProfileDml(). More...
 
class  ProfileQueryResult
 Represents the stream of Rows and profile stats returned from spanner::Client::ProfileQuery(). More...
 
class  QueryOptions
 These QueryOptions allow users to configure features about how their SQL queries executes on the server. More...
 
class  QueryPartition
 The QueryPartition class is a regular type that represents a single slice of a parallel SQL read. More...
 
struct  ReadOptions
 Options passed to Client::Read or Client::PartitionRead. More...
 
class  ReadPartition
 The ReadPartition class is a regular type that represents a single slice of a parallel Read operation. More...
 
class  Row
 A Row is a sequence of columns each with a name and an associated Value. More...
 
class  RowStream
 Represents the stream of Rows returned from spanner::Client::Read() or spanner::Client::ExecuteQuery(). More...
 
class  RowStreamIterator
 A RowStreamIterator is an Input Iterator (see below) that returns a sequence of StatusOr<Row> objects. More...
 
class  SessionPoolOptions
 Controls the session pool maintained by a spanner::Client. More...
 
class  SqlStatement
 Represents a potentially parameterized SQL statement. More...
 
class  Timestamp
 A representation of the Spanner TIMESTAMP type: An instant in time. More...
 
class  Transaction
 The representation of a Cloud Spanner transaction. More...
 
class  TupleStream
 A TupleStream<Tuple> defines a range that parses Tuple objects from the given range of RowStreamIterators. More...
 
class  TupleStreamIterator
 A TupleStreamIterator<Tuple> is an "Input Iterator" that wraps a RowStreamIterator, parsing its elements into a sequence of StatusOr<Tuple> objects. More...
 
class  UpdateInstanceRequestBuilder
 UpdateInstanceRequestBuilder is a builder class for google::spanner::admin::instance::v1::UpdateInstanceRequest More...
 
class  Value
 The Value class represents a type-safe, nullable Spanner value. More...
 

Typedefs

using BackoffPolicy = ::google::cloud::internal::BackoffPolicy
 The base class for spanner's backoff policies. More...
 
using ExponentialBackoffPolicy = google::cloud::internal::ExponentialBackoffPolicy
 A truncated exponential backoff policy with randomized periods. More...
 
using ConnectionOptions = google::cloud::ConnectionOptions< ConnectionOptionsTraits >
 The options for Cloud Spanner connections. More...
 
using ListDatabaseRange = google::cloud::internal::PaginationRange< google::spanner::admin::database::v1::Database, google::spanner::admin::database::v1::ListDatabasesRequest, google::spanner::admin::database::v1::ListDatabasesResponse >
 An input range to stream all the databases in a Cloud Spanner instance. More...
 
using ListBackupOperationsRange = google::cloud::internal::PaginationRange< google::longrunning::Operation, google::spanner::admin::database::v1::ListBackupOperationsRequest, google::spanner::admin::database::v1::ListBackupOperationsResponse >
 An input range to stream backup operations in Cloud Spanner instance. More...
 
using ListDatabaseOperationsRange = google::cloud::internal::PaginationRange< google::longrunning::Operation, google::spanner::admin::database::v1::ListDatabaseOperationsRequest, google::spanner::admin::database::v1::ListDatabaseOperationsResponse >
 An input range to stream database operations in Cloud Spanner instance. More...
 
using ListBackupsRange = google::cloud::internal::PaginationRange< google::spanner::admin::database::v1::Backup, google::spanner::admin::database::v1::ListBackupsRequest, google::spanner::admin::database::v1::ListBackupsResponse >
 An input range to stream backups in Cloud Spanner instance. More...
 
using IamUpdater = std::function< optional< google::iam::v1::Policy >(google::iam::v1::Policy)>
 
using ListInstancesRange = google::cloud::internal::PaginationRange< google::spanner::admin::instance::v1::Instance, google::spanner::admin::instance::v1::ListInstancesRequest, google::spanner::admin::instance::v1::ListInstancesResponse >
 An input range to stream all the instances in a Cloud project. More...
 
using ListInstanceConfigsRange = google::cloud::internal::PaginationRange< google::spanner::admin::instance::v1::InstanceConfig, google::spanner::admin::instance::v1::ListInstanceConfigsRequest, google::spanner::admin::instance::v1::ListInstanceConfigsResponse >
 An input range to stream all the instance configs in a Cloud project. More...
 
using Key = std::vector< Value >
 A Key is a collection of Value objects where the i'th value corresponds to the i'th component of the table or primary index key. More...
 
using Mutations = std::vector< Mutation >
 An ordered sequence of mutations to pass to Client::Commit() or return from the Client::Commit() mutator. More...
 
using InsertMutationBuilder = internal::WriteMutationBuilder< internal::InsertOp >
 A helper class to construct "insert" mutations. More...
 
using UpdateMutationBuilder = internal::WriteMutationBuilder< internal::UpdateOp >
 A helper class to construct "update" mutations. More...
 
using InsertOrUpdateMutationBuilder = internal::WriteMutationBuilder< internal::InsertOrUpdateOp >
 A helper class to construct "insert_or_update" mutations. More...
 
using ReplaceMutationBuilder = internal::WriteMutationBuilder< internal::ReplaceOp >
 A helper class to construct "replace" mutations. More...
 
using DeleteMutationBuilder = internal::DeleteMutationBuilder
 A helper class to construct "delete" mutations. More...
 
using ExecutionPlan = ::google::spanner::v1::QueryPlan
 Contains a hierarchical representation of the operations the database server performs in order to execute a particular SQL statement. More...
 
using RetryPolicy = google::cloud::internal::RetryPolicy< google::cloud::Status, internal::SafeGrpcRetry >
 The base class for retry policies. More...
 
using LimitedTimeRetryPolicy = google::cloud::internal::LimitedTimeRetryPolicy< google::cloud::Status, internal::SafeGrpcRetry >
 A retry policy that limits based on time. More...
 
using LimitedErrorCountRetryPolicy = google::cloud::internal::LimitedErrorCountRetryPolicy< google::cloud::Status, internal::SafeGrpcRetry >
 A retry policy that limits the number of times a request can fail. More...
 
using TransactionRerunPolicy = google::cloud::internal::RetryPolicy< google::cloud::Status, internal::SafeTransactionRerun >
 The base class for transaction rerun policies. More...
 
using LimitedTimeTransactionRerunPolicy = google::cloud::internal::LimitedTimeRetryPolicy< google::cloud::Status, internal::SafeTransactionRerun >
 A transaction rerun policy that limits the duration of the rerun loop. More...
 
using LimitedErrorCountTransactionRerunPolicy = google::cloud::internal::LimitedErrorCountRetryPolicy< google::cloud::Status, internal::SafeTransactionRerun >
 A transaction rerun policy that limits the number of failures. More...
 
template<typename Duration >
using sys_time = std::chrono::time_point< std::chrono::system_clock, Duration >
 Convenience alias. More...
 
using TracingOptions = google::cloud::TracingOptions
 The configuration parameters for RPC/protobuf tracing. More...
 

Enumerations

enum  ActionOnExhaustion { ActionOnExhaustion::kBlock, ActionOnExhaustion::kFail }
 

Functions

bool operator== (Backup const &a, Backup const &b)
 
bool operator!= (Backup const &a, Backup const &b)
 
std::ostream & operator<< (std::ostream &os, Backup const &bn)
 
std::ostream & operator<< (std::ostream &os, Bytes const &bytes)
 
std::shared_ptr< ConnectionMakeConnection (Database const &db, ConnectionOptions const &connection_options=ConnectionOptions(), SessionPoolOptions session_pool_options=SessionPoolOptions())
 Returns a Connection object that can be used for interacting with Spanner. More...
 
std::shared_ptr< ConnectionMakeConnection (Database const &db, ConnectionOptions const &connection_options, SessionPoolOptions session_pool_options, std::unique_ptr< RetryPolicy > retry_policy, std::unique_ptr< BackoffPolicy > backoff_policy)
 Returns a Connection object that can be used for interacting with Spanner. More...
 
bool operator== (Database const &a, Database const &b)
 
bool operator!= (Database const &a, Database const &b)
 
std::ostream & operator<< (std::ostream &os, Database const &dn)
 
std::shared_ptr< DatabaseAdminConnectionMakeDatabaseAdminConnection (ConnectionOptions const &options=ConnectionOptions())
 Returns an DatabaseAdminConnection object that can be used for interacting with Cloud Spanner's admin APIs. More...
 
std::shared_ptr< DatabaseAdminConnectionMakeDatabaseAdminConnection (ConnectionOptions const &options, std::unique_ptr< RetryPolicy > retry_policy, std::unique_ptr< BackoffPolicy > backoff_policy, std::unique_ptr< PollingPolicy > polling_policy)
 Returns an DatabaseAdminConnection object that can be used for interacting with Cloud Spanner's admin APIs. More...
 
std::ostream & operator<< (std::ostream &os, Date const &date)
 
bool operator== (Date const &a, Date const &b)
 
bool operator!= (Date const &a, Date const &b)
 
bool operator< (Date const &a, Date const &b)
 
bool operator<= (Date const &a, Date const &b)
 
bool operator>= (Date const &a, Date const &b)
 
bool operator> (Date const &a, Date const &b)
 
bool operator== (Instance const &a, Instance const &b)
 
bool operator!= (Instance const &a, Instance const &b)
 
std::ostream & operator<< (std::ostream &os, Instance const &dn)
 
std::shared_ptr< InstanceAdminConnectionMakeInstanceAdminConnection (ConnectionOptions const &options=ConnectionOptions())
 Returns an InstanceAdminConnection object that can be used for interacting with Cloud Spanner's admin APIs. More...
 
std::shared_ptr< InstanceAdminConnectionMakeInstanceAdminConnection (ConnectionOptions const &options, std::unique_ptr< RetryPolicy > retry_policy, std::unique_ptr< BackoffPolicy > backoff_policy, std::unique_ptr< PollingPolicy > polling_policy)
 Returns an InstanceAdminConnection object that can be used for interacting with Cloud Spanner's admin APIs. More...
 
bool operator== (KeyBound const &a, KeyBound const &b)
 
bool operator== (KeySet const &a, KeySet const &b)
 
template<typename... Ts>
Key MakeKey (Ts &&... ts)
 Constructs a Key from the given arguments. More...
 
template<typename... Ts>
KeyBound MakeKeyBoundClosed (Ts &&... ts)
 Returns a "closed" KeyBound with a Key constructed from the given arguments. More...
 
template<typename... Ts>
KeyBound MakeKeyBoundOpen (Ts &&... ts)
 Returns an "open" KeyBound with a Key constructed from the given arguments. More...
 
bool operator== (Mutation const &lhs, Mutation const &rhs)
 
void PrintTo (Mutation const &m, std::ostream *os)
 
template<typename... Ts>
Mutation MakeInsertMutation (std::string table_name, std::vector< std::string > columns, Ts &&... values)
 Creates a simple insert mutation for the values in values. More...
 
template<typename... Ts>
Mutation MakeUpdateMutation (std::string table_name, std::vector< std::string > columns, Ts &&... values)
 Creates a simple update mutation for the values in values. More...
 
template<typename... Ts>
Mutation MakeInsertOrUpdateMutation (std::string table_name, std::vector< std::string > columns, Ts &&... values)
 Creates a simple "insert or update" mutation for the values in values. More...
 
template<typename... Ts>
Mutation MakeReplaceMutation (std::string table_name, std::vector< std::string > columns, Ts &&... values)
 Creates a simple "replace" mutation for the values in values. More...
 
Mutation MakeDeleteMutation (std::string table_name, KeySet keys)
 Creates a simple "delete" mutation for the values in keys. More...
 
bool operator== (PartitionOptions const &a, PartitionOptions const &b)
 
bool operator!= (PartitionOptions const &a, PartitionOptions const &b)
 
bool operator== (QueryPartition const &a, QueryPartition const &b)
 
StatusOr< std::string > SerializeQueryPartition (QueryPartition const &query_partition)
 Serializes an instance of QueryPartition to a string of bytes. More...
 
StatusOr< QueryPartitionDeserializeQueryPartition (std::string const &serialized_query_partition)
 Deserializes the provided string into a QueryPartition. More...
 
bool operator== (ReadOptions const &lhs, ReadOptions const &rhs)
 
bool operator!= (ReadOptions const &lhs, ReadOptions const &rhs)
 
bool operator== (ReadPartition const &lhs, ReadPartition const &rhs)
 
bool operator!= (ReadPartition const &lhs, ReadPartition const &rhs)
 
StatusOr< std::string > SerializeReadPartition (ReadPartition const &read_partition)
 Serializes an instance of ReadPartition to a string of bytes. More...
 
StatusOr< ReadPartitionDeserializeReadPartition (std::string const &serialized_read_partition)
 Deserializes the provided string into a ReadPartition. More...
 
Row MakeTestRow (std::vector< std::pair< std::string, Value >> pairs)
 Creates a Row with the specified column names and values. More...
 
bool operator== (Row const &a, Row const &b)
 
bool operator== (RowStreamIterator const &a, RowStreamIterator const &b)
 
bool operator!= (RowStreamIterator const &a, RowStreamIterator const &b)
 
template<typename... Ts>
Row MakeTestRow (Ts &&... ts)
 Creates a Row with Values created from the given arguments and with auto-generated column names. More...
 
template<typename Tuple , typename RowRange >
TupleStream< Tuple > StreamOf (RowRange &&range)
 A factory that creates a TupleStream<Tuple> by wrapping the given range. More...
 
template<typename RowRange >
auto GetSingularRow (RowRange &&range) -> typename std::decay< decltype(*std::forward< RowRange >(range).begin())>::type
 Returns the only row from a range that contains exactly one row. More...
 
std::ostream & operator<< (std::ostream &os, SqlStatement const &stmt)
 
template<typename Duration >
StatusOr< TimestampMakeTimestamp (sys_time< Duration > const &)
 Construct a Timestamp from a std::chrono::time_point on the system clock. More...
 
Transaction MakeReadOnlyTransaction (Transaction::ReadOnlyOptions opts={})
 Create a read-only transaction configured with opts. More...
 
Transaction MakeReadWriteTransaction (Transaction::ReadWriteOptions opts={})
 Create a read-write transaction configured with opts. More...
 
Transaction MakeReadWriteTransaction (Transaction const &txn, Transaction::ReadWriteOptions opts={})
 Create a read-write transaction configured with opts, and sharing lock priority with txn. More...
 
bool operator== (Value const &a, Value const &b)
 
std::ostream & operator<< (std::ostream &os, Value const &v)
 
template<typename T >
Value MakeNullValue ()
 Factory to construct a "null" Value of the specified type T. More...
 
std::string VersionString ()
 The version as a string, in MAJOR.MINOR.PATCH+gitrev format. More...
 
int constexpr VersionMajor ()
 The Cloud spanner C++ Client major version. More...
 
int constexpr VersionMinor ()
 The Cloud spanner C++ Client minor version. More...
 
int constexpr VersionPatch ()
 The Cloud spanner C++ Client patch version. More...
 
int constexpr Version ()
 A single integer representing the Major/Minor/Patch version. More...
 

Detailed Description

The inlined, versioned namespace for the Cloud Spanner C++ client APIs.

Applications may need to link multiple versions of the Cloud spanner C++ client, for example, if they link a library that uses an older version of the client than they do. This namespace is inlined, so applications can use spanner::Foo in their source, but the symbols are versioned, i.e., the symbol becomes spanner::v1::Foo.

Typedef Documentation

◆ BackoffPolicy

using google::cloud::spanner::v1::BackoffPolicy = typedef ::google::cloud::internal::BackoffPolicy

The base class for spanner's backoff policies.

Definition at line 27 of file backoff_policy.h.

◆ ConnectionOptions

using google::cloud::spanner::v1::ConnectionOptions = typedef google::cloud::ConnectionOptions<ConnectionOptionsTraits>

The options for Cloud Spanner connections.

See google::cloud::ConnectionOptions<T> for more details at https://googleapis.dev/cpp/google-cloud-common/latest/

Definition at line 46 of file connection_options.h.

◆ DeleteMutationBuilder

using google::cloud::spanner::v1::DeleteMutationBuilder = typedef internal::DeleteMutationBuilder

A helper class to construct "delete" mutations.

Example
void DeleteMutationBuilder(google::cloud::spanner::Client client) {
namespace spanner = ::google::cloud::spanner;
auto commit = client.Commit(
"Albums", spanner::KeySet()
.AddKey(spanner::MakeKey(1, 1))
.AddKey(spanner::MakeKey(1, 2)))
.Build()});
if (!commit) throw std::runtime_error(commit.status().message());
std::cout << "delete-mutation-builder was successful\n";
}
See also
The Mutation class documentation for an overview of the Cloud Spanner mutation API
https://cloud.google.com/spanner/docs/modify-mutation-api for more information about the Cloud Spanner mutation API.

Definition at line 342 of file mutations.h.

◆ ExecutionPlan

using google::cloud::spanner::v1::ExecutionPlan = typedef ::google::spanner::v1::QueryPlan

Contains a hierarchical representation of the operations the database server performs in order to execute a particular SQL statement.

Query Plan proto

Example:
// Only SQL queries with a Distributed Union as the first operator in the
// `ExecutionPlan` can be partitioned.
auto is_partitionable = [](spanner::ExecutionPlan const& plan) {
return (!plan.plan_nodes().empty() &&
plan.plan_nodes(0).kind() ==
google::spanner::v1::PlanNode::RELATIONAL &&
plan.plan_nodes(0).display_name() == "Distributed Union");
};
google::cloud::StatusOr<spanner::ExecutionPlan> plan = client.AnalyzeSql(
spanner::SqlStatement(
"SELECT SingerId, FirstName, LastName FROM Singers"));
if (!plan) throw std::runtime_error(plan.status().message());
if (!is_partitionable(*plan)) {
throw std::runtime_error("Query is not partitionable");
}

Definition at line 40 of file results.h.

◆ ExponentialBackoffPolicy

using google::cloud::spanner::v1::ExponentialBackoffPolicy = typedef google::cloud::internal::ExponentialBackoffPolicy

A truncated exponential backoff policy with randomized periods.

Definition at line 31 of file backoff_policy.h.

◆ IamUpdater

using google::cloud::spanner::v1::IamUpdater = typedef std::function<optional<google::iam::v1::Policy>(google::iam::v1::Policy)>

Definition at line 29 of file iam_updater.h.

◆ InsertMutationBuilder

using google::cloud::spanner::v1::InsertMutationBuilder = typedef internal::WriteMutationBuilder<internal::InsertOp>

A helper class to construct "insert" mutations.

Example
void InsertMutationBuilder(google::cloud::spanner::Client client) {
namespace spanner = ::google::cloud::spanner;
auto commit = client.Commit(
"Singers", {"SingerId", "FirstName", "LastName"})
.EmplaceRow(1, "Marc", "Richards")
.EmplaceRow(2, "Catalina", "Smith")
.EmplaceRow(3, "Alice", "Trentor")
.EmplaceRow(4, "Lea", "Martin")
.EmplaceRow(5, "David", "Lomond")
.Build(),
"Albums", {"SingerId", "AlbumId", "AlbumTitle"})
.EmplaceRow(1, 1, "Total Junk")
.EmplaceRow(1, 2, "Go, Go, Go")
.EmplaceRow(2, 1, "Green")
.EmplaceRow(2, 2, "Forever Hold Your Peace")
.EmplaceRow(2, 3, "Terrified")
.Build()});
if (!commit) throw std::runtime_error(commit.status().message());
std::cout << "insert-mutation-builder was successful\n";
}
See also
The Mutation class documentation for an overview of the Cloud Spanner mutation API
https://cloud.google.com/spanner/docs/modify-mutation-api for more information about the Cloud Spanner mutation API.

Definition at line 201 of file mutations.h.

◆ InsertOrUpdateMutationBuilder

using google::cloud::spanner::v1::InsertOrUpdateMutationBuilder = typedef internal::WriteMutationBuilder<internal::InsertOrUpdateOp>

A helper class to construct "insert_or_update" mutations.

Example
void InsertOrUpdateMutationBuilder(google::cloud::spanner::Client client) {
namespace spanner = ::google::cloud::spanner;
auto commit = client.Commit(spanner::Mutations{
"Albums", {"SingerId", "AlbumId", "AlbumTitle", "MarketingBudget"})
.EmplaceRow(1, 1, "Total Junk", 100000)
.EmplaceRow(1, 2, "Go, Go, Go", 200000)
.EmplaceRow(2, 1, "Green", 300000)
.EmplaceRow(2, 2, "Forever Hold Your Peace", 400000)
.EmplaceRow(2, 3, "Terrified", 500000)
.Build()});
if (!commit) throw std::runtime_error(commit.status().message());
std::cout << "insert-or-update-mutation-builder was successful\n";
}
See also
The Mutation class documentation for an overview of the Cloud Spanner mutation API
https://cloud.google.com/spanner/docs/modify-mutation-api for more information about the Cloud Spanner mutation API.

Definition at line 271 of file mutations.h.

◆ Key

using google::cloud::spanner::v1::Key = typedef std::vector<Value>

A Key is a collection of Value objects where the i'th value corresponds to the i'th component of the table or primary index key.

In C++, this is implemented as a std::vector<Value>. See the MakeKey factory function below for an easy way to construct a valid Key instance.

Definition at line 37 of file keys.h.

◆ LimitedErrorCountRetryPolicy

using google::cloud::spanner::v1::LimitedErrorCountRetryPolicy = typedef google::cloud::internal::LimitedErrorCountRetryPolicy< google::cloud::Status, internal::SafeGrpcRetry>

A retry policy that limits the number of times a request can fail.

Definition at line 70 of file retry_policy.h.

◆ LimitedErrorCountTransactionRerunPolicy

using google::cloud::spanner::v1::LimitedErrorCountTransactionRerunPolicy = typedef google::cloud::internal::LimitedErrorCountRetryPolicy< google::cloud::Status, internal::SafeTransactionRerun>

A transaction rerun policy that limits the number of failures.

Definition at line 85 of file retry_policy.h.

◆ LimitedTimeRetryPolicy

using google::cloud::spanner::v1::LimitedTimeRetryPolicy = typedef google::cloud::internal::LimitedTimeRetryPolicy<google::cloud::Status, internal::SafeGrpcRetry>

A retry policy that limits based on time.

Definition at line 65 of file retry_policy.h.

◆ LimitedTimeTransactionRerunPolicy

using google::cloud::spanner::v1::LimitedTimeTransactionRerunPolicy = typedef google::cloud::internal::LimitedTimeRetryPolicy< google::cloud::Status, internal::SafeTransactionRerun>

A transaction rerun policy that limits the duration of the rerun loop.

Definition at line 80 of file retry_policy.h.

◆ ListBackupOperationsRange

using google::cloud::spanner::v1::ListBackupOperationsRange = typedef google::cloud::internal::PaginationRange< google::longrunning::Operation, google::spanner::admin::database::v1::ListBackupOperationsRequest, google::spanner::admin::database::v1::ListBackupOperationsResponse>

An input range to stream backup operations in Cloud Spanner instance.

This type models an input range of google::longrunning::Operation objects. Applications can make a single pass through the results.

Definition at line 61 of file database_admin_connection.h.

◆ ListBackupsRange

using google::cloud::spanner::v1::ListBackupsRange = typedef google::cloud::internal::PaginationRange< google::spanner::admin::database::v1::Backup, google::spanner::admin::database::v1::ListBackupsRequest, google::spanner::admin::database::v1::ListBackupsResponse>

An input range to stream backups in Cloud Spanner instance.

This type models an input range of google::longrunning::Operation objects. Applications can make a single pass through the results.

Definition at line 89 of file database_admin_connection.h.

◆ ListDatabaseOperationsRange

using google::cloud::spanner::v1::ListDatabaseOperationsRange = typedef google::cloud::internal::PaginationRange< google::longrunning::Operation, google::spanner::admin::database::v1::ListDatabaseOperationsRequest, google::spanner::admin::database::v1::ListDatabaseOperationsResponse>

An input range to stream database operations in Cloud Spanner instance.

This type models an input range of google::longrunning::Operation objects. Applications can make a single pass through the results.

Definition at line 75 of file database_admin_connection.h.

◆ ListDatabaseRange

using google::cloud::spanner::v1::ListDatabaseRange = typedef google::cloud::internal::PaginationRange< google::spanner::admin::database::v1::Database, google::spanner::admin::database::v1::ListDatabasesRequest, google::spanner::admin::database::v1::ListDatabasesResponse>

An input range to stream all the databases in a Cloud Spanner instance.

This type models an input range of google::spanner::admin::v1::Database objects. Applications can make a single pass through the results.

Definition at line 47 of file database_admin_connection.h.

◆ ListInstanceConfigsRange

using google::cloud::spanner::v1::ListInstanceConfigsRange = typedef google::cloud::internal::PaginationRange< google::spanner::admin::instance::v1::InstanceConfig, google::spanner::admin::instance::v1::ListInstanceConfigsRequest, google::spanner::admin::instance::v1::ListInstanceConfigsResponse>

An input range to stream all the instance configs in a Cloud project.

This type models an input range of google::spanner::admin::v1::Instance objects. Applications can make a single pass through the results.

Definition at line 57 of file instance_admin_connection.h.

◆ ListInstancesRange

using google::cloud::spanner::v1::ListInstancesRange = typedef google::cloud::internal::PaginationRange< google::spanner::admin::instance::v1::Instance, google::spanner::admin::instance::v1::ListInstancesRequest, google::spanner::admin::instance::v1::ListInstancesResponse>

An input range to stream all the instances in a Cloud project.

This type models an input range of google::spanner::admin::v1::Instance objects. Applications can make a single pass through the results.

Definition at line 43 of file instance_admin_connection.h.

◆ Mutations

using google::cloud::spanner::v1::Mutations = typedef std::vector<Mutation>

An ordered sequence of mutations to pass to Client::Commit() or return from the Client::Commit() mutator.

Definition at line 95 of file mutations.h.

◆ ReplaceMutationBuilder

using google::cloud::spanner::v1::ReplaceMutationBuilder = typedef internal::WriteMutationBuilder<internal::ReplaceOp>

A helper class to construct "replace" mutations.

Example
void ReplaceMutationBuilder(google::cloud::spanner::Client client) {
namespace spanner = ::google::cloud::spanner;
auto commit = client.Commit(spanner::Mutations{
"Albums", {"SingerId", "AlbumId", "AlbumTitle", "MarketingBudget"})
.EmplaceRow(1, 1, "Total Junk", 500000)
.EmplaceRow(1, 2, "Go, Go, Go", 400000)
.EmplaceRow(2, 1, "Green", 300000)
.Build()});
if (!commit) throw std::runtime_error(commit.status().message());
std::cout << "replace-mutation-builder was successful\n";
}
See also
The Mutation class documentation for an overview of the Cloud Spanner mutation API
https://cloud.google.com/spanner/docs/modify-mutation-api for more information about the Cloud Spanner mutation API.

Definition at line 308 of file mutations.h.

◆ RetryPolicy

using google::cloud::spanner::v1::RetryPolicy = typedef google::cloud::internal::RetryPolicy<google::cloud::Status, internal::SafeGrpcRetry>

The base class for retry policies.

Definition at line 60 of file retry_policy.h.

◆ sys_time

template<typename Duration >
using google::cloud::spanner::v1::sys_time = typedef std::chrono::time_point<std::chrono::system_clock, Duration>

Convenience alias.

std::chrono::sys_time since C++20.

Definition at line 39 of file timestamp.h.

◆ TracingOptions

using google::cloud::spanner::v1::TracingOptions = typedef google::cloud::TracingOptions

The configuration parameters for RPC/protobuf tracing.

The default options are: single_line_mode=on use_short_repeated_primitives=on truncate_string_field_longer_than=128

Definition at line 34 of file tracing_options.h.

◆ TransactionRerunPolicy

using google::cloud::spanner::v1::TransactionRerunPolicy = typedef google::cloud::internal::RetryPolicy<google::cloud::Status, internal::SafeTransactionRerun>

The base class for transaction rerun policies.

Definition at line 75 of file retry_policy.h.

◆ UpdateMutationBuilder

using google::cloud::spanner::v1::UpdateMutationBuilder = typedef internal::WriteMutationBuilder<internal::UpdateOp>

A helper class to construct "update" mutations.

Example
void UpdateMutationBuilder(google::cloud::spanner::Client client) {
namespace spanner = ::google::cloud::spanner;
auto commit = client.Commit(spanner::Mutations{
{"SingerId", "AlbumId", "MarketingBudget"})
.EmplaceRow(1, 1, 100000)
.EmplaceRow(2, 2, 500000)
.Build()});
if (!commit) throw std::runtime_error(commit.status().message());
std::cout << "update-mutation-builder was successful\n";
}
See also
The Mutation class documentation for an overview of the Cloud Spanner mutation API
https://cloud.google.com/spanner/docs/modify-mutation-api for more information about the Cloud Spanner mutation API.

Definition at line 236 of file mutations.h.

Enumeration Type Documentation

◆ ActionOnExhaustion

Enumerator
kBlock 
kFail 

Definition at line 30 of file session_pool_options.h.

Function Documentation

◆ DeserializeQueryPartition()

StatusOr< QueryPartition > google::cloud::spanner::v1::DeserializeQueryPartition ( std::string const &  serialized_query_partition)

Deserializes the provided string into a QueryPartition.

The serialized_query_partition argument must be a string that was previously returned by a call to SerializeQueryPartition().

Note
The serialized string may contain NUL and other non-printable characters. Therefore, callers should avoid formatted IO functions that may incorrectly reformat the string data.
Parameters
serialized_query_partition
Example
google::cloud::StatusOr<google::cloud::spanner::QueryPartition>
ReceiveQueryPartitionFromRemoteMachine() {
std::string serialized_partition = Receive();
serialized_partition);
}

Definition at line 61 of file query_partition.cc.

◆ DeserializeReadPartition()

StatusOr< ReadPartition > google::cloud::spanner::v1::DeserializeReadPartition ( std::string const &  serialized_read_partition)

Deserializes the provided string into a ReadPartition.

The serialized_read_partition argument must be a string that was previously returned by a call to SerializeReadPartition().

Note
The serialized string may contain NUL and other non-printable characters. Therefore, callers should avoid formatted IO functions that may incorrectly reformat the string data.
Parameters
serialized_read_partition- string representation to be deserialized.
Example
google::cloud::StatusOr<google::cloud::spanner::ReadPartition>
ReceiveReadPartitionFromRemoteMachine() {
std::string serialized_partition = Receive();
serialized_partition);
}

Definition at line 60 of file read_partition.cc.

◆ GetSingularRow()

template<typename RowRange >
auto google::cloud::spanner::v1::GetSingularRow ( RowRange &&  range) -> typename std::decay< decltype(*std::forward<RowRange>(range).begin())>::type

Returns the only row from a range that contains exactly one row.

An error is returned if the given range does not contain exactly one row. This is a convenience function that may be useful when the caller knows that a range should contain exactly one row, such as when LIMIT 1 is used in an SQL query, or when a read is performed on a guaranteed unique key such that only a single row could possibly match. In cases where the caller does not know how many rows may be returned, they should instead consume the range in a loop.

void GetSingularRow(google::cloud::spanner::Client client) {
namespace spanner = ::google::cloud::spanner;
auto query = client.ExecuteQuery(spanner::SqlStatement(
"SELECT FirstName, LastName FROM Singers WHERE SingerId = @singer_id",
{{"singer_id", spanner::Value(2)}}));
// `SingerId` is the primary key for the `Singers` table, the `GetSingularRow`
// helper returns a single row or an error:
using RowType = std::tuple<std::string, std::string>;
auto row = GetSingularRow(spanner::StreamOf<RowType>(query));
if (!row) throw std::runtime_error(row.status().message());
std::cout << "FirstName: " << std::get<0>(*row)
<< "\nLastName: " << std::get<1>(*row) << "\n";
}
Warning
Due to the fact that a RowStreamIteartor is an input iterator, this function may consume the first element in the range, even in cases where an error is returned. But again, this function should not be used if range might contain multiple rows.

Definition at line 462 of file row.h.

◆ MakeConnection() [1/2]

std::shared_ptr< Connection > google::cloud::spanner::v1::MakeConnection ( Database const &  db,
ConnectionOptions const &  connection_options = ConnectionOptions(),
SessionPoolOptions  session_pool_options = SessionPoolOptions() 
)

Returns a Connection object that can be used for interacting with Spanner.

The returned connection object should not be used directly, rather it should be given to a Client instance, and methods should be invoked on Client.

See also
Connection
Parameters
dbSee Database.
connection_options(optional) configure the Connection created by this function.
session_pool_options(optional) configure the SessionPool created by the Connection.

Definition at line 320 of file client.cc.

◆ MakeConnection() [2/2]

std::shared_ptr< Connection > google::cloud::spanner::v1::MakeConnection ( Database const &  db,
ConnectionOptions const &  connection_options,
SessionPoolOptions  session_pool_options,
std::unique_ptr< RetryPolicy retry_policy,
std::unique_ptr< BackoffPolicy backoff_policy 
)

Returns a Connection object that can be used for interacting with Spanner.

The returned connection object should not be used directly, rather it should be given to a Client instance, and methods should be invoked on Client.

See also
Connection
Parameters
dbSee Database.
connection_options(optional) configure the Connection created by this function.
session_pool_options(optional) configure the SessionPool created by the Connection.
retry_policyoverride the default RetryPolicy, controls how long the returned Connection object retries requests on transient failures.
backoff_policyoverride the default BackoffPolicy, controls how long the Connection object waits before retrying a failed request.

Definition at line 328 of file client.cc.

◆ MakeDatabaseAdminConnection() [1/2]

std::shared_ptr< DatabaseAdminConnection > google::cloud::spanner::v1::MakeDatabaseAdminConnection ( ConnectionOptions const &  options = ConnectionOptions())

Returns an DatabaseAdminConnection object that can be used for interacting with Cloud Spanner's admin APIs.

The returned connection object should not be used directly, rather it should be given to a DatabaseAdminClient instance.

See also
DatabaseAdminConnection
Parameters
options(optional) configure the DatabaseAdminConnection created by this function.

Definition at line 628 of file database_admin_connection.cc.

◆ MakeDatabaseAdminConnection() [2/2]

std::shared_ptr< DatabaseAdminConnection > google::cloud::spanner::v1::MakeDatabaseAdminConnection ( ConnectionOptions const &  options,
std::unique_ptr< RetryPolicy retry_policy,
std::unique_ptr< BackoffPolicy backoff_policy,
std::unique_ptr< PollingPolicy polling_policy 
)

Returns an DatabaseAdminConnection object that can be used for interacting with Cloud Spanner's admin APIs.

The returned connection object should not be used directly, rather it should be given to a DatabaseAdminClient instance.

See also
DatabaseAdminConnection
Parameters
options(optional) configure the DatabaseAdminConnection created by this function.
retry_policycontrol for how long (or how many times) are retryable RPCs attempted
backoff_policycontrols the backoff behavior between retry attempts, typically some form of exponential backoff with jitter
polling_policycontrols for how often, and how quickly, are long running checked for completion
Example
namespace spanner = ::google::cloud::spanner;
[](std::string const& project_id, std::string const& instance_id) {
// A database admin client is controlled by three policies. The retry
// policy determines for how long the client will retry transient failures.
auto retry_policy = spanner::LimitedTimeRetryPolicy(
/*maximum_duration=*/std::chrono::minutes(25))
.clone();
// The backoff policy controls how long does the client waits to retry after
// a transient failure. Here we configure a truncated exponential backoff
// with jitter:
// https://en.wikipedia.org/wiki/Exponential_backoff
// https://cloud.google.com/storage/docs/exponential-backoff
auto backoff_policy = spanner::ExponentialBackoffPolicy(
/*initial_delay=*/std::chrono::seconds(2),
/*maximum_delay=*/std::chrono::minutes(10),
/*scaling=*/2.0)
.clone();
// The polling policy controls how the client waits for long-running
// operations (such as creating new instances). `GenericPollingPolicy<>`
// combines existing policies. In this case, keep polling until the
// operation completes (with success or error) or 45 minutes, whichever
// happens first. Initially pause for 10 seconds between polling requests,
// increasing the pause by a factor of 4 until it becomes 2 minutes.
auto polling_policy =
spanner::GenericPollingPolicy<>(
/*maximum_duration=*/std::chrono::minutes(45)),
/*initial_delay=*/std::chrono::seconds(10),
/*maximum_delay=*/std::chrono::minutes(2),
/*scaling=*/4.0))
.clone();
auto client =
spanner::DatabaseAdminClient(spanner::MakeDatabaseAdminConnection(
spanner::ConnectionOptions{}, std::move(retry_policy),
std::move(backoff_policy), std::move(polling_policy)));
// Use the client as usual.
spanner::Instance instance(project_id, instance_id);
std::cout << "Available databases for instance " << instance << "\n";
for (auto const& db : client.ListDatabases(instance)) {
if (!db) throw std::runtime_error(db.status().message());
std::cout << db->name() << "\n";
}
std::cout << "End of available databases\n";
}

Definition at line 634 of file database_admin_connection.cc.

◆ MakeDeleteMutation()

Mutation google::cloud::spanner::v1::MakeDeleteMutation ( std::string  table_name,
KeySet  keys 
)
inline

Creates a simple "delete" mutation for the values in keys.

Example
void MakeDeleteMutation(google::cloud::spanner::Client client) {
namespace spanner = ::google::cloud::spanner;
auto commit = client.Commit(spanner::Mutations{
spanner::MakeDeleteMutation("Albums", spanner::KeySet::All()),
});
if (!commit) throw std::runtime_error(commit.status().message());
std::cout << "make-delete-mutation was successful\n";
}
See also
The Mutation class documentation for an overview of the Cloud Spanner mutation API
https://cloud.google.com/spanner/docs/modify-mutation-api for more information about the Cloud Spanner mutation API.

Definition at line 356 of file mutations.h.

◆ MakeInsertMutation()

template<typename... Ts>
Mutation google::cloud::spanner::v1::MakeInsertMutation ( std::string  table_name,
std::vector< std::string >  columns,
Ts &&...  values 
)

Creates a simple insert mutation for the values in values.

Example
void MakeInsertMutation(google::cloud::spanner::Client client) {
namespace spanner = ::google::cloud::spanner;
// Delete each of the albums by individual key, then delete all the singers
// using a key range.
auto commit_result = client.Commit(spanner::Mutations{
"Performances",
{"SingerId", "VenueId", "EventDate", "Revenue", "LastUpdateTime"})
.EmplaceRow(1, 4, spanner::Date(2017, 10, 5), 11000,
spanner::CommitTimestamp{})
.EmplaceRow(1, 19, spanner::Date(2017, 11, 2), 15000,
spanner::CommitTimestamp{})
.Build()});
if (!commit_result) {
throw std::runtime_error(commit_result.status().message());
}
std::cout << "make-insert-mutation was successful\n";
}
See also
The Mutation class documentation for an overview of the Cloud Spanner mutation API
https://cloud.google.com/spanner/docs/modify-mutation-api for more information about the Cloud Spanner mutation API.

Definition at line 216 of file mutations.h.

◆ MakeInsertOrUpdateMutation()

template<typename... Ts>
Mutation google::cloud::spanner::v1::MakeInsertOrUpdateMutation ( std::string  table_name,
std::vector< std::string >  columns,
Ts &&...  values 
)

Creates a simple "insert or update" mutation for the values in values.

Example
void MakeInsertOrUpdateMutation(google::cloud::spanner::Client client) {
namespace spanner = ::google::cloud::spanner;
auto commit = client.Commit(spanner::Mutations{
"Albums", {"SingerId", "AlbumId", "AlbumTitle", "MarketingBudget"}, 1,
1, "Total Junk", 200000),
});
if (!commit) throw std::runtime_error(commit.status().message());
std::cout << "make-insert-or-update-mutation was successful\n";
}
See also
The Mutation class documentation for an overview of the Cloud Spanner mutation API
https://cloud.google.com/spanner/docs/modify-mutation-api for more information about the Cloud Spanner mutation API.

Definition at line 286 of file mutations.h.

◆ MakeInstanceAdminConnection() [1/2]

std::shared_ptr< InstanceAdminConnection > google::cloud::spanner::v1::MakeInstanceAdminConnection ( ConnectionOptions const &  options = ConnectionOptions())

Returns an InstanceAdminConnection object that can be used for interacting with Cloud Spanner's admin APIs.

The returned connection object should not be used directly, rather it should be given to a InstanceAdminClient instance.

See also
InstanceAdminConnection
Parameters
options(optional) configure the InstanceAdminConnection created by this function.

Definition at line 302 of file instance_admin_connection.cc.

◆ MakeInstanceAdminConnection() [2/2]

std::shared_ptr< InstanceAdminConnection > google::cloud::spanner::v1::MakeInstanceAdminConnection ( ConnectionOptions const &  options,
std::unique_ptr< RetryPolicy retry_policy,
std::unique_ptr< BackoffPolicy backoff_policy,
std::unique_ptr< PollingPolicy polling_policy 
)

Returns an InstanceAdminConnection object that can be used for interacting with Cloud Spanner's admin APIs.

The returned connection object should not be used directly, rather it should be given to a InstanceAdminClient instance.

See also
InstanceAdminConnection
Parameters
options(optional) configure the InstanceAdminConnection created by this function.
retry_policycontrol for how long (or how many times) are retryable RPCs attempted
backoff_policycontrols the backoff behavior between retry attempts, typically some form of expotential backoff with jitter
polling_policycontrols for how often, and how quickly, are long running checked for completion
Example
namespace spanner = ::google::cloud::spanner;
[](std::string const& project_id) {
// An instance admin client is controlled by three policies. The retry
// policy determines for how long the client will retry transient failures.
auto retry_policy = spanner::LimitedTimeRetryPolicy(
/*maximum_duration=*/std::chrono::minutes(25))
.clone();
// The backoff policy controls how long does the client waits to retry after
// a transient failure. Here we configure a truncated exponential backoff
// with jitter:
// https://en.wikipedia.org/wiki/Exponential_backoff
// https://cloud.google.com/storage/docs/exponential-backoff
auto backoff_policy = spanner::ExponentialBackoffPolicy(
/*initial_delay=*/std::chrono::seconds(2),
/*maximum_delay=*/std::chrono::minutes(10),
/*scaling=*/2.0)
.clone();
// The polling policy controls how the client waits for long-running
// operations (such as creating new instances). `GenericPollingPolicy<>`
// combines existing policies. In this case, keep polling until the
// operation completes (with success or error) or 45 minutes, whichever
// happens first. Initially pause for 10 seconds between polling requests,
// increasing the pause by a factor of 4 until it becomes 2 minutes.
auto polling_policy =
spanner::GenericPollingPolicy<>(
/*maximum_duration=*/std::chrono::minutes(45)),
/*initial_delay=*/std::chrono::seconds(10),
/*maximum_delay=*/std::chrono::minutes(2),
/*scaling=*/4.0))
.clone();
auto client =
spanner::InstanceAdminClient(spanner::MakeInstanceAdminConnection(
spanner::ConnectionOptions{}, std::move(retry_policy),
std::move(backoff_policy), std::move(polling_policy)));
// Use the client as usual.
std::cout << "Available configs for project " << project_id << "\n";
for (auto const& cfg : client.ListInstanceConfigs(project_id)) {
if (!cfg) throw std::runtime_error(cfg.status().message());
std::cout << cfg->name() << "\n";
}
std::cout << "End of available configs\n";
}

Definition at line 308 of file instance_admin_connection.cc.

◆ MakeKey()

template<typename... Ts>
Key google::cloud::spanner::v1::MakeKey ( Ts &&...  ts)

Constructs a Key from the given arguments.

Example
void DeleteData(google::cloud::spanner::Client client) {
namespace spanner = ::google::cloud::spanner;
// Delete each of the albums by individual key, then delete all the singers
// using a key range.
auto delete_albums = spanner::DeleteMutationBuilder(
"Albums", spanner::KeySet()
.AddKey(spanner::MakeKey(1, 1))
.AddKey(spanner::MakeKey(1, 2))
.AddKey(spanner::MakeKey(2, 1))
.AddKey(spanner::MakeKey(2, 2))
.AddKey(spanner::MakeKey(2, 3)))
.Build();
auto delete_singers =
"Singers", spanner::KeySet().AddRange(spanner::MakeKeyBoundClosed(1),
.Build();
auto commit_result =
client.Commit(spanner::Mutations{delete_albums, delete_singers});
if (!commit_result) {
throw std::runtime_error(commit_result.status().message());
}
std::cout << "Delete was successful [spanner_delete_data]\n";
}

Definition at line 46 of file keys.h.

◆ MakeKeyBoundClosed()

template<typename... Ts>
KeyBound google::cloud::spanner::v1::MakeKeyBoundClosed ( Ts &&...  ts)

Returns a "closed" KeyBound with a Key constructed from the given arguments.

Example
void DeleteData(google::cloud::spanner::Client client) {
namespace spanner = ::google::cloud::spanner;
// Delete each of the albums by individual key, then delete all the singers
// using a key range.
auto delete_albums = spanner::DeleteMutationBuilder(
"Albums", spanner::KeySet()
.AddKey(spanner::MakeKey(1, 1))
.AddKey(spanner::MakeKey(1, 2))
.AddKey(spanner::MakeKey(2, 1))
.AddKey(spanner::MakeKey(2, 2))
.AddKey(spanner::MakeKey(2, 3)))
.Build();
auto delete_singers =
"Singers", spanner::KeySet().AddRange(spanner::MakeKeyBoundClosed(1),
.Build();
auto commit_result =
client.Commit(spanner::Mutations{delete_albums, delete_singers});
if (!commit_result) {
throw std::runtime_error(commit_result.status().message());
}
std::cout << "Delete was successful [spanner_delete_data]\n";
}

Definition at line 119 of file keys.h.

◆ MakeKeyBoundOpen()

template<typename... Ts>
KeyBound google::cloud::spanner::v1::MakeKeyBoundOpen ( Ts &&...  ts)

Returns an "open" KeyBound with a Key constructed from the given arguments.

Example
auto key_set = spanner::KeySet().AddRange(spanner::MakeKeyBoundOpen(0),

Definition at line 131 of file keys.h.

◆ MakeNullValue()

template<typename T >
Value google::cloud::spanner::v1::MakeNullValue ( )

Factory to construct a "null" Value of the specified type T.

This is equivalent to passing an optional<T> without a value to the constructor, though this factory may be easier to invoke and result in clearer code at the call site.

Definition at line 643 of file value.h.

◆ MakeReadOnlyTransaction()

Transaction google::cloud::spanner::v1::MakeReadOnlyTransaction ( Transaction::ReadOnlyOptions  opts = {})
inline

Create a read-only transaction configured with opts.

Note
This is a lazy evaluated operation. No RPCs are made as part of creating a Transaction object. Instead, the first request to the server (for example as part of a ExecuteQuery() call) will also create the transaction.

Definition at line 186 of file transaction.h.

◆ MakeReadWriteTransaction() [1/2]

Transaction google::cloud::spanner::v1::MakeReadWriteTransaction ( Transaction::ReadWriteOptions  opts = {})
inline

Create a read-write transaction configured with opts.

Note
This is a lazy evaluated operation. No RPCs are made as part of creating a Transaction object. Instead, the first request to the server (for example as part of a ExecuteQuery() call) will also create the transaction.

Definition at line 196 of file transaction.h.

◆ MakeReadWriteTransaction() [2/2]

Transaction google::cloud::spanner::v1::MakeReadWriteTransaction ( Transaction const &  txn,
Transaction::ReadWriteOptions  opts = {} 
)
inline

Create a read-write transaction configured with opts, and sharing lock priority with txn.

This should be used when rerunning an aborted transaction, so that the new attempt has a slightly better chance of success.

Definition at line 207 of file transaction.h.

◆ MakeReplaceMutation()

template<typename... Ts>
Mutation google::cloud::spanner::v1::MakeReplaceMutation ( std::string  table_name,
std::vector< std::string >  columns,
Ts &&...  values 
)

Creates a simple "replace" mutation for the values in values.

Example
void MakeReplaceMutation(google::cloud::spanner::Client client) {
namespace spanner = ::google::cloud::spanner;
auto commit = client.Commit(spanner::Mutations{
"Albums", {"SingerId", "AlbumId", "AlbumTitle", "MarketingBudget"}, 1,
1, "Go, Go, Go", 600000),
});
if (!commit) throw std::runtime_error(commit.status().message());
std::cout << "make-replace-mutation was successful\n";
}
See also
The Mutation class documentation for an overview of the Cloud Spanner mutation API
https://cloud.google.com/spanner/docs/modify-mutation-api for more information about the Cloud Spanner mutation API.

Definition at line 323 of file mutations.h.

◆ MakeTestRow() [1/2]

Row google::cloud::spanner::v1::MakeTestRow ( std::vector< std::pair< std::string, Value >>  pairs)

Creates a Row with the specified column names and values.

This overload accepts a vector of pairs, allowing the caller to specify both the column names and the Value that goes in each column.

This function is intended for application developers who are mocking the results of a Client::ExecuteQuery call.

Definition at line 36 of file row.cc.

◆ MakeTestRow() [2/2]

template<typename... Ts>
Row google::cloud::spanner::v1::MakeTestRow ( Ts &&...  ts)

Creates a Row with Values created from the given arguments and with auto-generated column names.

This overload accepts a variadic list of arguments that will be used to create the Values in the row. The column names will be implicitly generated, the first column being "0", the second "1", and so on, corresponding to the argument's position.

This function is intended for application developers who are mocking the results of a Client::ExecuteQuery call.

Definition at line 221 of file row.h.

◆ MakeTimestamp()

template<typename Duration >
StatusOr< Timestamp > google::cloud::spanner::v1::MakeTimestamp ( sys_time< Duration > const &  tp)

Construct a Timestamp from a std::chrono::time_point on the system clock.

May produce out-of-range errors, depending on the properties of Duration and the std::chrono::system_clock epoch. Duration::rep may not be wider than std::intmax_t.

Definition at line 194 of file timestamp.h.

◆ MakeUpdateMutation()

template<typename... Ts>
Mutation google::cloud::spanner::v1::MakeUpdateMutation ( std::string  table_name,
std::vector< std::string >  columns,
Ts &&...  values 
)

Creates a simple update mutation for the values in values.

Example
void MakeUpdateMutation(google::cloud::spanner::Client client) {
namespace spanner = ::google::cloud::spanner;
auto commit = client.Commit(spanner::Mutations{
"Albums", {"SingerId", "AlbumId", "MarketingBudget"}, 1, 1, 200000),
});
if (!commit) throw std::runtime_error(commit.status().message());
std::cout << "make-update-mutation was succesful\n";
}
See also
The Mutation class documentation for an overview of the Cloud Spanner mutation API
https://cloud.google.com/spanner/docs/modify-mutation-api for more information about the Cloud Spanner mutation API.

Definition at line 251 of file mutations.h.

◆ operator!=() [1/8]

bool google::cloud::spanner::v1::operator!= ( Backup const &  a,
Backup const &  b 
)

Definition at line 33 of file backup.cc.

◆ operator!=() [2/8]

bool google::cloud::spanner::v1::operator!= ( Instance const &  a,
Instance const &  b 
)

Definition at line 35 of file instance.cc.

◆ operator!=() [3/8]

bool google::cloud::spanner::v1::operator!= ( Database const &  a,
Database const &  b 
)

Definition at line 39 of file database.cc.

◆ operator!=() [4/8]

bool google::cloud::spanner::v1::operator!= ( ReadPartition const &  lhs,
ReadPartition const &  rhs 
)

Definition at line 46 of file read_partition.cc.

◆ operator!=() [5/8]

bool google::cloud::spanner::v1::operator!= ( ReadOptions const &  lhs,
ReadOptions const &  rhs 
)
inline

Definition at line 47 of file read_options.h.

◆ operator!=() [6/8]

bool google::cloud::spanner::v1::operator!= ( Date const &  a,
Date const &  b 
)
inline

Definition at line 57 of file date.h.

◆ operator!=() [7/8]

bool google::cloud::spanner::v1::operator!= ( PartitionOptions const &  a,
PartitionOptions const &  b 
)
inline

Definition at line 61 of file partition_options.h.

◆ operator!=() [8/8]

bool google::cloud::spanner::v1::operator!= ( RowStreamIterator const &  a,
RowStreamIterator const &  b 
)

Definition at line 112 of file row.cc.

◆ operator<()

bool google::cloud::spanner::v1::operator< ( Date const &  a,
Date const &  b 
)
inline

Definition at line 59 of file date.h.

◆ operator<<() [1/7]

std::ostream& google::cloud::spanner::v1::operator<< ( std::ostream &  os,
Backup const &  bn 
)

Definition at line 35 of file backup.cc.

◆ operator<<() [2/7]

std::ostream& google::cloud::spanner::v1::operator<< ( std::ostream &  os,
Instance const &  dn 
)

Definition at line 37 of file instance.cc.

◆ operator<<() [3/7]

std::ostream& google::cloud::spanner::v1::operator<< ( std::ostream &  os,
Database const &  dn 
)

Definition at line 41 of file database.cc.

◆ operator<<() [4/7]

std::ostream& google::cloud::spanner::v1::operator<< ( std::ostream &  os,
SqlStatement const &  stmt 
)
Warning
This is intended for debugging and human consumption only, not machine consumption, as the output format may change without notice.

Definition at line 58 of file sql_statement.cc.

◆ operator<<() [5/7]

std::ostream & google::cloud::spanner::v1::operator<< ( std::ostream &  os,
Date const &  date 
)

Definition at line 63 of file date.cc.

◆ operator<<() [6/7]

std::ostream& google::cloud::spanner::v1::operator<< ( std::ostream &  os,
Bytes const &  bytes 
)
Warning
This is intended for debugging and human consumption only, not machine consumption, as the output format may change without notice.

Definition at line 66 of file bytes.cc.

◆ operator<<() [7/7]

std::ostream& google::cloud::spanner::v1::operator<< ( std::ostream &  os,
Value const &  v 
)
Warning
This is intended for debugging and human consumption only, not machine consumption, as the output format may change without notice.
Example:
spanner::Value v{42};
std::cout << v << "\n";

Definition at line 196 of file value.cc.

◆ operator<=()

bool google::cloud::spanner::v1::operator<= ( Date const &  a,
Date const &  b 
)
inline

Definition at line 64 of file date.h.

◆ operator==() [1/14]

bool google::cloud::spanner::v1::operator== ( Mutation const &  lhs,
Mutation const &  rhs 
)

Definition at line 24 of file mutations.cc.

◆ operator==() [2/14]

bool google::cloud::spanner::v1::operator== ( Backup const &  a,
Backup const &  b 
)

Definition at line 29 of file backup.cc.

◆ operator==() [3/14]

bool google::cloud::spanner::v1::operator== ( Instance const &  a,
Instance const &  b 
)

Definition at line 31 of file instance.cc.

◆ operator==() [4/14]

bool google::cloud::spanner::v1::operator== ( QueryPartition const &  a,
QueryPartition const &  b 
)

Definition at line 32 of file query_partition.cc.

◆ operator==() [5/14]

bool google::cloud::spanner::v1::operator== ( Database const &  a,
Database const &  b 
)

Definition at line 35 of file database.cc.

◆ operator==() [6/14]

bool google::cloud::spanner::v1::operator== ( ReadPartition const &  lhs,
ReadPartition const &  rhs 
)

Definition at line 41 of file read_partition.cc.

◆ operator==() [7/14]

bool google::cloud::spanner::v1::operator== ( ReadOptions const &  lhs,
ReadOptions const &  rhs 
)
inline

Definition at line 43 of file read_options.h.

◆ operator==() [8/14]

bool google::cloud::spanner::v1::operator== ( KeyBound const &  a,
KeyBound const &  b 
)

Definition at line 46 of file keys.cc.

◆ operator==() [9/14]

bool google::cloud::spanner::v1::operator== ( Date const &  a,
Date const &  b 
)
inline

Definition at line 52 of file date.h.

◆ operator==() [10/14]

bool google::cloud::spanner::v1::operator== ( PartitionOptions const &  a,
PartitionOptions const &  b 
)
inline

Definition at line 56 of file partition_options.h.

◆ operator==() [11/14]

bool google::cloud::spanner::v1::operator== ( Row const &  a,
Row const &  b 
)

Definition at line 70 of file row.cc.

◆ operator==() [12/14]

bool google::cloud::spanner::v1::operator== ( KeySet const &  a,
KeySet const &  b 
)

Definition at line 70 of file keys.cc.

◆ operator==() [13/14]

bool google::cloud::spanner::v1::operator== ( RowStreamIterator const &  a,
RowStreamIterator const &  b 
)

Definition at line 104 of file row.cc.

◆ operator==() [14/14]

bool google::cloud::spanner::v1::operator== ( Value const &  a,
Value const &  b 
)

Definition at line 192 of file value.cc.

◆ operator>()

bool google::cloud::spanner::v1::operator> ( Date const &  a,
Date const &  b 
)
inline

Definition at line 68 of file date.h.

◆ operator>=()

bool google::cloud::spanner::v1::operator>= ( Date const &  a,
Date const &  b 
)
inline

Definition at line 66 of file date.h.

◆ PrintTo()

void google::cloud::spanner::v1::PrintTo ( Mutation const &  m,
std::ostream *  os 
)
Warning
This is intended for debugging and human consumption only, not machine consumption as the output format may change without notice.

Definition at line 29 of file mutations.cc.

◆ SerializeQueryPartition()

StatusOr< std::string > google::cloud::spanner::v1::SerializeQueryPartition ( QueryPartition const &  query_partition)

Serializes an instance of QueryPartition to a string of bytes.

The serialized string of bytes is suitable for writing to disk or transmission to another process.

Note
The serialized string may contain NUL and other non-printable characters. Therefore, callers should avoid formatted IO functions that may incorrectly reformat the string data.
Parameters
query_partition- instance to be serialized.
Example
namespace spanner = ::google::cloud::spanner;
google::cloud::StatusOr<std::string> serialized_partition =
if (!serialized_partition) {
throw std::runtime_error(serialized_partition.status().message());
}
std::string const& bytes = *serialized_partition;
// `bytes` contains the serialized data, which may contain NULs and other
// non-printable characters.
SendBinaryStringData(bytes);

Definition at line 39 of file query_partition.cc.

◆ SerializeReadPartition()

StatusOr< std::string > google::cloud::spanner::v1::SerializeReadPartition ( ReadPartition const &  read_partition)

Serializes an instance of ReadPartition to a string of bytes.

The serialized string of bytes is suitable for writing to disk or transmission to another process.

Note
The serialized string may contain NUL and other non-printable characters. Therefore, callers should avoid formatted IO functions that may incorrectly reformat the string data.
Parameters
read_partition- instance to be serialized.
Example
namespace spanner = ::google::cloud::spanner;
google::cloud::StatusOr<std::string> serialized_partition =
if (!serialized_partition) {
throw std::runtime_error(serialized_partition.status().message());
}
std::string const& bytes = *serialized_partition;
// `bytes` contains the serialized data, which may contain NULs and other
// non-printable characters.
SendBinaryStringData(bytes);

Definition at line 50 of file read_partition.cc.

◆ StreamOf()

template<typename Tuple , typename RowRange >
TupleStream<Tuple> google::cloud::spanner::v1::StreamOf ( RowRange &&  range)

A factory that creates a TupleStream<Tuple> by wrapping the given range.

The RowRange must be a range defined by RowStreamIterator objects.

void StreamOf(google::cloud::spanner::Client client) {
namespace spanner = ::google::cloud::spanner;
std::cout << "Querying the Singers table:\n";
auto query = client.ExecuteQuery(spanner::SqlStatement(
"SELECT SingerId, FirstName, LastName FROM Singers"));
using RowType = std::tuple<std::int64_t, std::string, std::string>;
for (auto& row : spanner::StreamOf<RowType>(query)) {
if (!row) throw std::runtime_error(row.status().message());
std::cout << " FirstName: " << std::get<0>(*row)
<< "\n LastName: " << std::get<1>(*row) << "\n";
}
std::cout << "end of results\n";
}
Note
ownership of the range is not transferred, so it must outlive the returned TupleStream.
Template Parameters
RowRangemust be a range defined by RowStreamIterators.

Definition at line 436 of file row.h.

◆ Version()

int constexpr google::cloud::spanner::v1::Version ( )

A single integer representing the Major/Minor/Patch version.

Definition at line 61 of file version.h.

◆ VersionMajor()

int constexpr google::cloud::spanner::v1::VersionMajor ( )

The Cloud spanner C++ Client major version.

Definition at line 48 of file version.h.

◆ VersionMinor()

int constexpr google::cloud::spanner::v1::VersionMinor ( )

The Cloud spanner C++ Client minor version.

Definition at line 53 of file version.h.

◆ VersionPatch()

int constexpr google::cloud::spanner::v1::VersionPatch ( )

The Cloud spanner C++ Client patch version.

Definition at line 58 of file version.h.

◆ VersionString()

std::string google::cloud::spanner::v1::VersionString ( )

The version as a string, in MAJOR.MINOR.PATCH+gitrev format.

Definition at line 24 of file version.cc.