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

Contains all the Cloud Spanner C++ client types and functions. 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...
 
class  CommitOptions
 Set options on calls to spanner::Client::Commit(). More...
 
struct  CommitStats
 Statistics returned for a committed Transaction. More...
 
struct  CommitResult
 The result of committing a Transaction. 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  DefaultEncryption
 Use the per-operation default encryption: More...
 
class  GoogleEncryption
 Use Google default encryption. More...
 
class  CustomerManagedEncryption
 Use encryption with encryption_key. 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  Json
 A simple representation for the Spanner JSON type: a lightweight, text-based, language-independent data interchange format. 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...
 
class  Decimal
 A representation of the Spanner NUMERIC type: an exact decimal value with a maximum integer precision (kIntPrecision) and rounding to a maximum fractional precision (kFracPrecision). More...
 
struct  SpannerRetryPolicyOption
 Option for google::cloud::Options to set a spanner::RetryPolicy. More...
 
struct  SpannerBackoffPolicyOption
 Option for google::cloud::Options to set a spanner::BackoffPolicy. More...
 
struct  SpannerPollingPolicyOption
 Option for google::cloud::Options to set a spanner::PollingPolicy. More...
 
struct  SessionCreatorRoleOption
 Option for google::cloud::Options to set the database role used for session creation. More...
 
struct  SessionPoolMinSessionsOption
 Option for google::cloud::Options to set the minimum number of sessions to keep in the pool. More...
 
struct  SessionPoolMaxSessionsPerChannelOption
 Option for google::cloud::Options to set the maximum number of sessions to create on each channel. More...
 
struct  SessionPoolMaxIdleSessionsOption
 Option for google::cloud::Options to set the maximum number of sessions to keep in the pool in an idle state. More...
 
struct  SessionPoolActionOnExhaustionOption
 Option for google::cloud::Options to set the action to take when attempting to allocate a session when the pool is exhausted. More...
 
struct  SessionPoolKeepAliveIntervalOption
 Option for google::cloud::Options to set the interval at which we refresh sessions so they don't get collected by the backend GC. More...
 
struct  SessionPoolLabelsOption
 Option for google::cloud::Options to set the labels used when creating sessions within the pool. More...
 
struct  QueryOptimizerVersionOption
 Option for google::cloud::Options to set the optimizer version used in an SQL query. More...
 
struct  QueryOptimizerStatisticsPackageOption
 Option for google::cloud::Options to set the optimizer statistics package used in an SQL query. More...
 
struct  RequestPriorityOption
 Option for google::cloud::Options to set a spanner::RequestPriority. More...
 
struct  RequestTagOption
 Option for google::cloud::Options to set a per-request tag. More...
 
struct  ReadIndexNameOption
 Option for google::cloud::Options to set the name of an index on a database table. More...
 
struct  ReadRowLimitOption
 Option for google::cloud::Options to set a limit on the number of rows to yield from Client::Read(). More...
 
struct  StreamingResumabilityBufferSizeOption
 Option for google::cloud::Options to set a limit on how much data will be buffered to guarantee resumability of a streaming read or SQL query. More...
 
struct  PartitionSizeOption
 Option for google::cloud::Options to set the desired partition size to be generated by Client::PartitionRead() or PartitionQuery(). More...
 
struct  PartitionsMaximumOption
 Option for google::cloud::Options to set the desired maximum number of partitions to return from Client::PartitionRead() or PartitionQuery(). More...
 
struct  TransactionTagOption
 Option for google::cloud::Options to set a per-transaction tag. More...
 
struct  CommitReturnStatsOption
 Option for google::cloud::Options to return additional statistics about the committed transaction in a spanner::CommitResult. More...
 
struct  PartitionOptions
 Options passed to Client::PartitionRead or Client::PartitionQuery. More...
 
struct  PartitionedDmlResult
 The result of executing a Partitioned DML query. 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  RowStream
 Represents the stream of Rows returned from spanner::Client::Read() or spanner::Client::ExecuteQuery(). More...
 
class  DmlResult
 Represents the result of a data modifying operation using spanner::Client::ExecuteDml(). More...
 
class  ProfileQueryResult
 Represents the stream of Rows and profile stats returned from spanner::Client::ProfileQuery(). More...
 
class  ProfileDmlResult
 Represents the result and profile stats of a data modifying operation using spanner::Client::ProfileDml(). More...
 
class  Row
 A Row is a sequence of columns each with a name and an associated Value. More...
 
class  RowStreamIterator
 A RowStreamIterator is an Input Iterator (see below) that returns a sequence of StatusOr<Row> objects. 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  TupleStream
 A TupleStream<Tuple> defines a range that parses Tuple objects from the given range of RowStreamIterators. 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...
 
struct  CommitTimestamp
 A sentinel type used to update a commit timestamp column. More...
 
class  Transaction
 The representation of a Cloud Spanner transaction. 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 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 >
 An input range to stream all the databases in a Cloud Spanner instance. More...
 
using ListBackupOperationsRange = google::cloud::internal::PaginationRange< google::longrunning::Operation >
 An input range to stream backup operations in Cloud Spanner instance. More...
 
using ListDatabaseOperationsRange = google::cloud::internal::PaginationRange< google::longrunning::Operation >
 An input range to stream database operations in Cloud Spanner instance. More...
 
using ListBackupsRange = ::google::cloud::internal::PaginationRange< google::spanner::admin::database::v1::Backup >
 An input range to stream backups in Cloud Spanner instance. More...
 
using Date = ::absl::CivilDay
 Represents a date in the proleptic Gregorian calendar as a triple of year, month (1-12), and day (1-31). More...
 
using EncryptionConfig = absl::variant< DefaultEncryption, GoogleEncryption, CustomerManagedEncryption >
 Specify the encryption configuration for any of the following operations: More...
 
using IamUpdater = ::google::cloud::IamUpdater
 Type alias for google::cloud::IamUpdater. More...
 
using ListInstancesRange = ::google::cloud::internal::PaginationRange< google::spanner::admin::instance::v1::Instance >
 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 >
 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 = spanner_internal::WriteMutationBuilder< spanner_internal::InsertOp >
 A helper class to construct "insert" mutations. More...
 
using UpdateMutationBuilder = spanner_internal::WriteMutationBuilder< spanner_internal::UpdateOp >
 A helper class to construct "update" mutations. More...
 
using InsertOrUpdateMutationBuilder = spanner_internal::WriteMutationBuilder< spanner_internal::InsertOrUpdateOp >
 A helper class to construct "insert_or_update" mutations. More...
 
using ReplaceMutationBuilder = spanner_internal::WriteMutationBuilder< spanner_internal::ReplaceOp >
 A helper class to construct "replace" mutations. More...
 
using DeleteMutationBuilder = spanner_internal::DeleteMutationBuilder
 A helper class to construct "delete" mutations. More...
 
using SpannerPolicyOptionList = OptionList< spanner::SpannerRetryPolicyOption, SpannerBackoffPolicyOption, SpannerPollingPolicyOption >
 List of all "policy" options. More...
 
using SessionPoolOptionList = OptionList< SessionCreatorRoleOption, SessionPoolMinSessionsOption, SessionPoolMaxSessionsPerChannelOption, SessionPoolMaxIdleSessionsOption, SessionPoolActionOnExhaustionOption, SessionPoolKeepAliveIntervalOption, SessionPoolLabelsOption >
 List of all SessionPool options. More...
 
using RequestOptionList = OptionList< RequestPriorityOption, RequestTagOption >
 List of Request options for client::ExecuteBatchDml(). More...
 
using PollingPolicy = ::google::cloud::PollingPolicy
 
template<typename Retry = LimitedTimeRetryPolicy, typename Backoff = ExponentialBackoffPolicy>
using GenericPollingPolicy = ::google::cloud::GenericPollingPolicy< Retry, Backoff >
 
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::TraitBasedRetryPolicy< spanner_internal::SafeGrpcRetry >
 The base class for retry policies. More...
 
using LimitedTimeRetryPolicy = ::google::cloud::internal::LimitedTimeRetryPolicy< spanner_internal::SafeGrpcRetry >
 A retry policy that limits based on time. More...
 
using LimitedErrorCountRetryPolicy = google::cloud::internal::LimitedErrorCountRetryPolicy< spanner_internal::SafeGrpcRetry >
 A retry policy that limits the number of times a request can fail. More...
 
using TransactionRerunPolicy = ::google::cloud::internal::TraitBasedRetryPolicy< spanner_internal::SafeTransactionRerun >
 The base class for transaction rerun policies. More...
 
using LimitedTimeTransactionRerunPolicy = google::cloud::internal::LimitedTimeRetryPolicy< spanner_internal::SafeTransactionRerun >
 A transaction rerun policy that limits the duration of the rerun loop. More...
 
using LimitedErrorCountTransactionRerunPolicy = google::cloud::internal::LimitedErrorCountRetryPolicy< spanner_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...
 
using Numeric = Decimal< DecimalMode::kGoogleSQL >
 Most users only need the Numeric or PgNumeric specializations of Decimal. More...
 
using PgNumeric = Decimal< DecimalMode::kPostgreSQL >
 Most users only need the Numeric or PgNumeric specializations of Decimal. More...
 

Enumerations

enum class  DecimalMode { kGoogleSQL , kPostgreSQL }
 
enum class  ActionOnExhaustion { kBlock , kFail }
 Action to take when the session pool is exhausted. More...
 
enum class  RequestPriority { kLow , kMedium , kHigh }
 

Functions

StatusOr< BackupMakeBackup (std::string const &full_name)
 Constructs a Backup from the given full_name. More...
 
std::shared_ptr< spanner::ConnectionMakeConnection (spanner::Database const &db, Options opts={})
 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=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...
 
StatusOr< DatabaseMakeDatabase (std::string const &full_name)
 Constructs a Database from the given full_name. More...
 
std::shared_ptr< spanner::DatabaseAdminConnectionMakeDatabaseAdminConnection (Options opts={})
 Returns a DatabaseAdminConnection object that can be used for interacting with Cloud Spanner's admin APIs. More...
 
std::shared_ptr< DatabaseAdminConnectionMakeDatabaseAdminConnection (ConnectionOptions const &options)
 Returns a 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 a DatabaseAdminConnection object that can be used for interacting with Cloud Spanner's admin APIs. More...
 
StatusOr< InstanceMakeInstance (std::string const &full_name)
 Constructs an Instance from the given full_name. More...
 
std::shared_ptr< spanner::InstanceAdminConnectionMakeInstanceAdminConnection (Options opts={})
 Returns an InstanceAdminConnection object that can be used for interacting with Cloud Spanner's admin APIs. More...
 
std::shared_ptr< InstanceAdminConnectionMakeInstanceAdminConnection (ConnectionOptions const &options)
 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...
 
std::ostream & operator<< (std::ostream &os, Json const &json)
 Outputs a JSON-formatted string to the provided stream. More...
 
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...
 
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...
 
template<DecimalMode Mode>
StatusOr< Decimal< Mode > > MakeDecimal (std::string s)
 Construction from a string, in decimal fixed- or floating-point formats. More...
 
template<DecimalMode Mode>
StatusOr< Decimal< Mode > > MakeDecimal (double d)
 Construction from a double. More...
 
template<typename T , DecimalMode Mode, typename std::enable_if< std::numeric_limits< T >::is_integer, int >::type = 0>
StatusOr< Decimal< Mode > > MakeDecimal (T i, int exponent=0)
 Construction from an integer i, scaled by 10^exponent. More...
 
template<DecimalMode Mode>
double ToDouble (Decimal< Mode > const &d)
 Conversion to the closest double value, with possible loss of precision. More...
 
bool operator== (PartitionOptions const &a, PartitionOptions const &b)
 
bool operator!= (PartitionOptions const &a, PartitionOptions const &b)
 
Options ToOptions (PartitionOptions const &)
 Converts PartitionOptions to common Options. More...
 
PartitionOptions ToPartitionOptions (Options const &)
 Converts common Options to PartitionOptions. More...
 
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)
 
Options ToOptions (ReadOptions const &)
 Converts ReadOptions to common Options. More...
 
ReadOptions ToReadOptions (Options const &)
 Converts common Options to ReadOptions. More...
 
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...
 
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(*range.begin())>::type
 Returns the only row from a range that contains exactly one row. More...
 
StatusOr< TimestampMakeTimestamp (absl::Time)
 Construct a Timestamp from an absl::Time. More...
 
StatusOr< TimestampMakeTimestamp (protobuf::Timestamp const &)
 Construct a Timestamp from a google::protobuf::Timestamp. More...
 
template<typename Duration >
StatusOr< TimestampMakeTimestamp (sys_time< Duration > const &tp)
 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...
 
template<typename T >
Value MakeNullValue ()
 Factory to construct a "null" Value of the specified type T. More...
 
constexpr int VersionMajor ()
 The Cloud spanner C++ Client major version. More...
 
constexpr int VersionMinor ()
 The Cloud spanner C++ Client minor version. More...
 
constexpr int VersionPatch ()
 The Cloud spanner C++ Client patch version. More...
 
constexpr int Version ()
 A single integer representing the Major/Minor/Patch version. More...
 
std::string VersionString ()
 The version as a string, in MAJOR.MINOR.PATCH+gitrev format. More...
 
Relational operators
bool operator== (Json const &lhs, Json const &rhs)
 
bool operator!= (Json const &lhs, Json const &rhs)
 
template<typename T , DecimalMode Mode, typename std::enable_if< std::numeric_limits< T >::is_integer &&!std::numeric_limits< T >::is_signed, int >::type = 0>
StatusOr< T > ToInteger (Decimal< Mode > const &d, int exponent=0)
 Conversion to the nearest integer value, scaled by 10^exponent. More...
 
StatusOr< NumericMakeNumeric (std::string s)
 MakeNumeric() factory functions for Numeric. More...
 
StatusOr< NumericMakeNumeric (double d)
 MakeNumeric() factory functions for Numeric. More...
 
template<typename T , typename std::enable_if< std::numeric_limits< T >::is_integer, int >::type = 0>
StatusOr< NumericMakeNumeric (T i, int exponent=0)
 MakeNumeric() factory functions for Numeric. More...
 
StatusOr< PgNumericMakePgNumeric (std::string s)
 MakePgNumeric() factory functions for PgNumeric. More...
 
StatusOr< PgNumericMakePgNumeric (double d)
 MakePgNumeric() factory functions for PgNumeric. More...
 
template<typename T , typename std::enable_if< std::numeric_limits< T >::is_integer, int >::type = 0>
StatusOr< PgNumericMakePgNumeric (T i, int exponent=0)
 MakePgNumeric() factory functions for PgNumeric. More...
 

Detailed Description

Contains all the Cloud Spanner C++ client types and functions.

Typedef Documentation

◆ BackoffPolicy

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

The base class for backoff policies.

Definition at line 27 of file backoff_policy.h.

◆ ConnectionOptions

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 45 of file connection_options.h.

◆ Date

using google::cloud::spanner::Date = typedef ::absl::CivilDay

Represents a date in the proleptic Gregorian calendar as a triple of year, month (1-12), and day (1-31).

We use absl::CivilDay to represent a "date". Direct use of absl::CivilDay is recommended. This alias exists for backward compatibility.

See also
https://abseil.io/docs/cpp/guides/time#civil-times

Definition at line 36 of file date.h.

◆ DeleteMutationBuilder

using google::cloud::spanner::DeleteMutationBuilder = typedef spanner_internal::DeleteMutationBuilder

A helper class to construct "delete" mutations.

Example
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";
}
Performs database client operations on Spanner.
Definition: client.h:124
StatusOr< CommitResult > Commit(std::function< StatusOr< Mutations >(Transaction)> const &mutator, std::unique_ptr< TransactionRerunPolicy > rerun_policy, std::unique_ptr< BackoffPolicy > backoff_policy, Options opts={})
Commits a read-write transaction.
std::vector< Mutation > Mutations
An ordered sequence of mutations to pass to Client::Commit() or return from the Client::Commit() muta...
Definition: mutations.h:99
spanner_internal::DeleteMutationBuilder DeleteMutationBuilder
A helper class to construct "delete" mutations.
Definition: mutations.h:355
Key MakeKey(Ts &&... ts)
Constructs a Key from the given arguments.
Definition: keys.h:51
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 355 of file mutations.h.

◆ EncryptionConfig

Specify the encryption configuration for any of the following operations:

Definition at line 60 of file encryption_config.h.

◆ ExecutionPlan

using google::cloud::spanner::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");
};
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");
}
Status const & status() const &
std::string const & message() const
::google::spanner::v1::QueryPlan ExecutionPlan
Contains a hierarchical representation of the operations the database server performs in order to exe...
Definition: results.h:57
Transaction MakeReadOnlyTransaction(Transaction::ReadOnlyOptions opts={})
Create a read-only transaction configured with opts.
Definition: transaction.h:180

Definition at line 57 of file results.h.

◆ ExponentialBackoffPolicy

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

A truncated exponential backoff policy with randomized periods.

Definition at line 30 of file backoff_policy.h.

◆ GenericPollingPolicy

template<typename Retry = LimitedTimeRetryPolicy, typename Backoff = ExponentialBackoffPolicy>
using google::cloud::spanner::GenericPollingPolicy = typedef ::google::cloud::GenericPollingPolicy<Retry, Backoff>

Definition at line 33 of file polling_policy.h.

◆ IamUpdater

Type alias for google::cloud::IamUpdater.

Used in the SetIamPolicy() read-modify-write cycle of the Spanner admin clients, DatabaseAdminClient and InstanceAdminClient, in order to avoid race conditions.

The updater is called with a recently fetched policy, and should either return an empty optional if no changes are required, or return a new policy to be set. In the latter case the control loop will always set the etag of the new policy to that of the recently fetched one. A failure to update then indicates a race, and the process will repeat.

Definition at line 39 of file iam_updater.h.

◆ InsertMutationBuilder

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

A helper class to construct "insert" mutations.

Example
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";
}
spanner_internal::WriteMutationBuilder< spanner_internal::InsertOp > InsertMutationBuilder
A helper class to construct "insert" mutations.
Definition: mutations.h:214
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 213 of file mutations.h.

◆ InsertOrUpdateMutationBuilder

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

A helper class to construct "insert_or_update" mutations.

Example
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";
}
spanner_internal::WriteMutationBuilder< spanner_internal::InsertOrUpdateOp > InsertOrUpdateMutationBuilder
A helper class to construct "insert_or_update" mutations.
Definition: mutations.h:284
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 283 of file mutations.h.

◆ Key

using google::cloud::spanner::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 42 of file keys.h.

◆ LimitedErrorCountRetryPolicy

using google::cloud::spanner::LimitedErrorCountRetryPolicy = typedef google::cloud::internal::LimitedErrorCountRetryPolicy< spanner_internal::SafeGrpcRetry>

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

Definition at line 72 of file retry_policy.h.

◆ LimitedErrorCountTransactionRerunPolicy

using google::cloud::spanner::LimitedErrorCountTransactionRerunPolicy = typedef google::cloud::internal::LimitedErrorCountRetryPolicy< spanner_internal::SafeTransactionRerun>

A transaction rerun policy that limits the number of failures.

Definition at line 86 of file retry_policy.h.

◆ LimitedTimeRetryPolicy

using google::cloud::spanner::LimitedTimeRetryPolicy = typedef ::google::cloud::internal::LimitedTimeRetryPolicy< spanner_internal::SafeGrpcRetry>

A retry policy that limits based on time.

Definition at line 67 of file retry_policy.h.

◆ LimitedTimeTransactionRerunPolicy

using google::cloud::spanner::LimitedTimeTransactionRerunPolicy = typedef google::cloud::internal::LimitedTimeRetryPolicy< spanner_internal::SafeTransactionRerun>

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

Definition at line 81 of file retry_policy.h.

◆ ListBackupOperationsRange

using google::cloud::spanner::ListBackupOperationsRange = typedef google::cloud::internal::PaginationRange<google::longrunning::Operation>

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 63 of file database_admin_connection.h.

◆ ListBackupsRange

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

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 87 of file database_admin_connection.h.

◆ ListDatabaseOperationsRange

using google::cloud::spanner::ListDatabaseOperationsRange = typedef google::cloud::internal::PaginationRange<google::longrunning::Operation>

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::ListDatabaseRange = typedef ::google::cloud::internal::PaginationRange< google::spanner::admin::database::v1::Database>

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 51 of file database_admin_connection.h.

◆ ListInstanceConfigsRange

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

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::ListInstancesRange = typedef ::google::cloud::internal::PaginationRange< google::spanner::admin::instance::v1::Instance>

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 45 of file instance_admin_connection.h.

◆ Mutations

using google::cloud::spanner::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 99 of file mutations.h.

◆ Numeric

Most users only need the Numeric or PgNumeric specializations of Decimal.

For example:

auto n = spanner::MakeNumeric(42).value();
assert(n.ToString() == "42");
assert(spanner::ToInteger<int>(n).value() == 42);
StatusOr< Numeric > MakeNumeric(std::string s)
MakeNumeric() factory functions for Numeric.
Definition: numeric.h:396

Definition at line 388 of file numeric.h.

◆ PgNumeric

Most users only need the Numeric or PgNumeric specializations of Decimal.

For example:

auto n = spanner::MakeNumeric(42).value();
assert(n.ToString() == "42");
assert(spanner::ToInteger<int>(n).value() == 42);

Definition at line 389 of file numeric.h.

◆ PollingPolicy

Definition at line 29 of file polling_policy.h.

◆ ReplaceMutationBuilder

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

A helper class to construct "replace" mutations.

Example
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";
}
spanner_internal::WriteMutationBuilder< spanner_internal::ReplaceOp > ReplaceMutationBuilder
A helper class to construct "replace" mutations.
Definition: mutations.h:321
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 320 of file mutations.h.

◆ RequestOptionList

List of Request options for client::ExecuteBatchDml().

Definition at line 271 of file options.h.

◆ RetryPolicy

using google::cloud::spanner::RetryPolicy = typedef ::google::cloud::internal::TraitBasedRetryPolicy< spanner_internal::SafeGrpcRetry>

The base class for retry policies.

Definition at line 63 of file retry_policy.h.

◆ SessionPoolOptionList

List of all SessionPool options.

Pass to spanner::MakeConnection().

Definition at line 164 of file options.h.

◆ SpannerPolicyOptionList

List of all "policy" options.

Definition at line 83 of file options.h.

◆ sys_time

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

Convenience alias.

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

Definition at line 37 of file timestamp.h.

◆ 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::TransactionRerunPolicy = typedef ::google::cloud::internal::TraitBasedRetryPolicy< spanner_internal::SafeTransactionRerun>

The base class for transaction rerun policies.

Definition at line 77 of file retry_policy.h.

◆ UpdateMutationBuilder

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

A helper class to construct "update" mutations.

Example
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";
}
spanner_internal::WriteMutationBuilder< spanner_internal::UpdateOp > UpdateMutationBuilder
A helper class to construct "update" mutations.
Definition: mutations.h:249
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 248 of file mutations.h.

Enumeration Type Documentation

◆ ActionOnExhaustion

Action to take when the session pool is exhausted.

Enumerator
kBlock 
kFail 

Definition at line 128 of file options.h.

◆ DecimalMode

Enumerator
kGoogleSQL 
kPostgreSQL 

Definition at line 39 of file numeric.h.

◆ RequestPriority

Enumerator
kLow 
kMedium 
kHigh 

Definition at line 26 of file request_priority.h.

Function Documentation

◆ DeserializeQueryPartition()

StatusOr<QueryPartition> google::cloud::spanner::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
ReceiveQueryPartitionFromRemoteMachine() {
std::string serialized_partition = Receive();
serialized_partition);
}
StatusOr< QueryPartition > DeserializeQueryPartition(std::string const &serialized_query_partition)
Deserializes the provided string into a QueryPartition.

◆ DeserializeReadPartition()

StatusOr<ReadPartition> google::cloud::spanner::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
ReceiveReadPartitionFromRemoteMachine() {
std::string serialized_partition = Receive();
serialized_partition);
}
StatusOr< ReadPartition > DeserializeReadPartition(std::string const &serialized_read_partition)
Deserializes the provided string into a ReadPartition.

◆ GetSingularRow()

template<typename RowRange >
auto google::cloud::spanner::GetSingularRow ( RowRange  range) -> typename std::decay<decltype(*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.

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";
}
RowStream ExecuteQuery(SqlStatement statement, Options opts={})
Executes a SQL query.
auto GetSingularRow(RowRange range) -> typename std::decay< decltype(*range.begin())>::type
Returns the only row from a range that contains exactly one row.
Definition: row.h:467

Definition at line 467 of file row.h.

◆ MakeBackup()

StatusOr<Backup> google::cloud::spanner::MakeBackup ( std::string const &  full_name)

Constructs a Backup from the given full_name.

Returns a non-OK Status if full_name is improperly formed.

◆ MakeConnection() [1/3]

std::shared_ptr<Connection> google::cloud::spanner::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.

Note
Prefer using the MakeConnection() overload that accepts google::cloud::Options.
See also
Connection
Parameters
dbSee Database.
connection_optionsconfigure the Connection created by this function.
session_pool_options(optional) configure the SessionPool created by the Connection.
Note
Prefer using the MakeConnection() overload that accepts google::cloud::Options.
Parameters
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.
Example
namespace spanner = ::google::cloud::spanner;
[](std::string const& project_id, std::string const& instance_id,
std::string const& database_id) {
// Use a truncated exponential backoff with jitter to wait between
// retries:
// https://en.wikipedia.org/wiki/Exponential_backoff
// https://cloud.google.com/storage/docs/exponential-backoff
auto client = spanner::Client(spanner::MakeConnection(
spanner::Database(project_id, instance_id, database_id),
.set<spanner::SpannerRetryPolicyOption>(
std::make_shared<spanner::LimitedTimeRetryPolicy>(
/*maximum_duration=*/std::chrono::minutes(25)))
.set<spanner::SpannerBackoffPolicyOption>(
std::make_shared<spanner::ExponentialBackoffPolicy>(
/*initial_delay=*/std::chrono::seconds(2),
/*maximum_delay=*/std::chrono::minutes(10),
/*scaling=*/1.5))));
auto rows =
client.ExecuteQuery(spanner::SqlStatement("SELECT 'Hello World'"));
for (auto const& row : spanner::StreamOf<std::tuple<std::string>>(rows)) {
if (!row) throw std::runtime_error(row.status().message());
std::cout << std::get<0>(*row) << "\n";
}
}
Options & set(ValueTypeT< T > v)
std::shared_ptr< spanner::Connection > MakeConnection(spanner::Database const &db, Options opts={})
Returns a Connection object that can be used for interacting with Spanner.
TupleStream< Tuple > StreamOf(RowRange &&range)
A factory that creates a TupleStream<Tuple> by wrapping the given range.
Definition: row.h:446

◆ MakeConnection() [2/3]

std::shared_ptr<Connection> google::cloud::spanner::MakeConnection ( Database const &  db,
ConnectionOptions const &  connection_options,
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.

Note
Prefer using the MakeConnection() overload that accepts google::cloud::Options.
See also
Connection
Parameters
dbSee Database.
connection_optionsconfigure the Connection created by this function.
session_pool_options(optional) configure the SessionPool created by the Connection.

◆ MakeConnection() [3/3]

std::shared_ptr<spanner::Connection> google::cloud::spanner::MakeConnection ( spanner::Database const &  db,
Options  opts = {} 
)

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

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

The optional opts argument may be used to configure aspects of the returned Connection. Expected options are any of the types in the following option lists.

Note
Unrecognized options will be ignored. To debug issues with options set GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes in the environment and unexpected options will be logged.
See also
Connection
Parameters
dbSee Database.
opts(optional) Configure the Connection created by this function.

◆ MakeDatabase()

StatusOr<Database> google::cloud::spanner::MakeDatabase ( std::string const &  full_name)

Constructs a Database from the given full_name.

Returns a non-OK Status if full_name is improperly formed.

◆ MakeDatabaseAdminConnection() [1/3]

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

Returns a 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.

Note
Prefer using the MakeDatabaseAdminConnection() overload that accepts google::cloud::Options.
See also
DatabaseAdminConnection
Parameters
optionsconfigure the DatabaseAdminConnection created by this function.

◆ MakeDatabaseAdminConnection() [2/3]

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

Returns a 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.

Note
Prefer using the MakeDatabaseAdminConnection() overload that accepts google::cloud::Options.
Parameters
optionsconfigure 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 =
/*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();
std::move(retry_policy))
.set<
std::move(backoff_policy))
.set<
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.FullName())) {
if (!db) throw std::runtime_error(db.status().message());
std::cout << db->name() << "\n";
}
std::cout << "End of available databases\n";
}
::google::cloud::internal::LimitedTimeRetryPolicy< spanner_admin_internal::DatabaseAdminRetryTraits > DatabaseAdminLimitedTimeRetryPolicy
std::shared_ptr< DatabaseAdminConnection > MakeDatabaseAdminConnection(Options options={})
A factory function to construct an object of type DatabaseAdminConnection.
google::cloud::internal::ExponentialBackoffPolicy ExponentialBackoffPolicy
A truncated exponential backoff policy with randomized periods.
::google::cloud::internal::LimitedTimeRetryPolicy< spanner_internal::SafeGrpcRetry > LimitedTimeRetryPolicy
A retry policy that limits based on time.
Definition: retry_policy.h:69

◆ MakeDatabaseAdminConnection() [3/3]

std::shared_ptr<spanner::DatabaseAdminConnection> google::cloud::spanner::MakeDatabaseAdminConnection ( Options  opts = {})

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

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

The optional opts argument may be used to configure aspects of the returned DatabaseAdminConnection. Expected options are any of types in the following option lists.

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

◆ MakeDecimal() [1/3]

template<DecimalMode Mode>
StatusOr<Decimal<Mode> > google::cloud::spanner::MakeDecimal ( double  d)

Construction from a double.

Fails on NaN or any argument outside the NUMERIC value range (including infinities). If the argument has more than kFracPrecision digits after the decimal point it will be rounded, with halfway cases rounding away from zero.

Definition at line 246 of file numeric.h.

◆ MakeDecimal() [2/3]

template<DecimalMode Mode>
StatusOr<Decimal<Mode> > google::cloud::spanner::MakeDecimal ( std::string  s)

Construction from a string, in decimal fixed- or floating-point formats.

  • [-+]?[0-9]+(.[0-9]*)?([eE][-+]?[0-9]+)?
  • [-+]?.[0-9]+([eE][-+]?[0-9]+)?
  • [Nn][Aa][Nn] // "not a number" for kPostgreSQL mode

For example, "0", "-999", "3.141592654", "299792458", "6.02214076e23", etc. There must be digits either before or after any decimal point.

Fails on syntax errors or if the conversion would yield a value outside the NUMERIC range. If the argument has more than kFracPrecision digits after the decimal point it will be rounded, with halfway cases rounding away from zero.

Definition at line 233 of file numeric.h.

◆ MakeDecimal() [3/3]

template<typename T , DecimalMode Mode, typename std::enable_if< std::numeric_limits< T >::is_integer, int >::type = 0>
StatusOr<Decimal<Mode> > google::cloud::spanner::MakeDecimal ( i,
int  exponent = 0 
)

Construction from an integer i, scaled by 10^exponent.

Fails on any (scaled) argument outside the NUMERIC value range.

Definition at line 260 of file numeric.h.

◆ MakeDeleteMutation()

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

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

Example
namespace spanner = ::google::cloud::spanner;
auto commit = client.Commit(spanner::Mutations{
});
if (!commit) throw std::runtime_error(commit.status().message());
std::cout << "make-delete-mutation was successful\n";
}
static KeySet All()
Returns a KeySet that represents the set of "All" keys for the index.
Definition: keys.h:165
Mutation MakeDeleteMutation(std::string table_name, KeySet keys)
Creates a simple "delete" mutation for the values in keys.
Definition: mutations.h:369
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 369 of file mutations.h.

◆ MakeInsertMutation()

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

Creates a simple insert mutation for the values in values.

Example
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, absl::CivilDay(2017, 10, 5), 11000,
spanner::CommitTimestamp{})
.EmplaceRow(1, 19, absl::CivilDay(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";
}
Mutation MakeInsertMutation(std::string table_name, std::vector< std::string > columns, Ts &&... values)
Creates a simple insert mutation for the values in values.
Definition: mutations.h:229
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 229 of file mutations.h.

◆ MakeInsertOrUpdateMutation()

template<typename... Ts>
Mutation google::cloud::spanner::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
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";
}
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.
Definition: mutations.h:299
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 299 of file mutations.h.

◆ MakeInstance()

StatusOr<Instance> google::cloud::spanner::MakeInstance ( std::string const &  full_name)

Constructs an Instance from the given full_name.

Returns a non-OK Status if full_name is improperly formed.

◆ MakeInstanceAdminConnection() [1/3]

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

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.

Note
Prefer using the MakeInstanceAdminConnection() overload that accepts google::cloud::Options.
See also
InstanceAdminConnection
Parameters
optionsconfigure the InstanceAdminConnection created by this function.

◆ MakeInstanceAdminConnection() [2/3]

std::shared_ptr<InstanceAdminConnection> google::cloud::spanner::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.

Note
Prefer using the MakeInstanceAdminConnection() overload that accepts google::cloud::Options.
Parameters
optionsconfigure 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 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) {
// 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 =
/*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();
std::move(retry_policy))
.set<
std::move(backoff_policy))
.set<
std::move(polling_policy)));
// Use the client as usual.
std::cout << "Available configs for project " << project_id << "\n";
auto project = google::cloud::Project(project_id);
for (auto const& cfg : client.ListInstanceConfigs(project.FullName())) {
if (!cfg) throw std::runtime_error(cfg.status().message());
std::cout << cfg->name() << "\n";
}
std::cout << "End of available configs\n";
}
std::shared_ptr< InstanceAdminConnection > MakeInstanceAdminConnection(Options options={})
A factory function to construct an object of type InstanceAdminConnection.
::google::cloud::internal::LimitedTimeRetryPolicy< spanner_admin_internal::InstanceAdminRetryTraits > InstanceAdminLimitedTimeRetryPolicy

◆ MakeInstanceAdminConnection() [3/3]

std::shared_ptr<spanner::InstanceAdminConnection> google::cloud::spanner::MakeInstanceAdminConnection ( Options  opts = {})

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; instead it should be given to a InstanceAdminClient instance.

The optional opts argument may be used to configure aspects of the returned InstanceAdminConnection. Expected options are any of the types in the following option lists.

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

◆ MakeKey()

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

Constructs a Key from the given arguments.

Example
auto delete_albums = spanner::DeleteMutationBuilder(
"Albums", spanner::KeySet()
.AddKey(spanner::MakeKey(2, 1))
.AddKey(spanner::MakeKey(2, 3)))
.Build();

Definition at line 51 of file keys.h.

◆ MakeKeyBoundClosed()

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

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

Example
auto delete_singers_range =
"Singers", spanner::KeySet().AddRange(spanner::MakeKeyBoundClosed(3),
.Build();
KeyBound MakeKeyBoundClosed(Ts &&... ts)
Returns a "closed" KeyBound with a Key constructed from the given arguments.
Definition: keys.h:124
KeyBound MakeKeyBoundOpen(Ts &&... ts)
Returns an "open" KeyBound with a Key constructed from the given arguments.
Definition: keys.h:136

Definition at line 124 of file keys.h.

◆ MakeKeyBoundOpen()

template<typename... Ts>
KeyBound google::cloud::spanner::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 136 of file keys.h.

◆ MakeNullValue()

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

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

This is equivalent to passing an absl::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 674 of file value.h.

◆ MakeNumeric() [1/3]

StatusOr<Numeric> google::cloud::spanner::MakeNumeric ( double  d)
inline

MakeNumeric() factory functions for Numeric.

Definition at line 399 of file numeric.h.

◆ MakeNumeric() [2/3]

StatusOr<Numeric> google::cloud::spanner::MakeNumeric ( std::string  s)
inline

MakeNumeric() factory functions for Numeric.

Definition at line 396 of file numeric.h.

◆ MakeNumeric() [3/3]

template<typename T , typename std::enable_if< std::numeric_limits< T >::is_integer, int >::type = 0>
StatusOr<Numeric> google::cloud::spanner::MakeNumeric ( i,
int  exponent = 0 
)

MakeNumeric() factory functions for Numeric.

Definition at line 404 of file numeric.h.

◆ MakePgNumeric() [1/3]

StatusOr<PgNumeric> google::cloud::spanner::MakePgNumeric ( double  d)
inline

MakePgNumeric() factory functions for PgNumeric.

Definition at line 416 of file numeric.h.

◆ MakePgNumeric() [2/3]

StatusOr<PgNumeric> google::cloud::spanner::MakePgNumeric ( std::string  s)
inline

MakePgNumeric() factory functions for PgNumeric.

Definition at line 413 of file numeric.h.

◆ MakePgNumeric() [3/3]

template<typename T , typename std::enable_if< std::numeric_limits< T >::is_integer, int >::type = 0>
StatusOr<PgNumeric> google::cloud::spanner::MakePgNumeric ( i,
int  exponent = 0 
)

MakePgNumeric() factory functions for PgNumeric.

Definition at line 421 of file numeric.h.

◆ MakeReadOnlyTransaction()

Transaction google::cloud::spanner::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 180 of file transaction.h.

◆ MakeReadWriteTransaction() [1/2]

Transaction google::cloud::spanner::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 201 of file transaction.h.

◆ MakeReadWriteTransaction() [2/2]

Transaction google::cloud::spanner::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 190 of file transaction.h.

◆ MakeReplaceMutation()

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

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

Example
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";
}
Mutation MakeReplaceMutation(std::string table_name, std::vector< std::string > columns, Ts &&... values)
Creates a simple "replace" mutation for the values in values.
Definition: mutations.h:336
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 336 of file mutations.h.

◆ MakeTestRow() [1/2]

Row google::cloud::spanner::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.

◆ MakeTestRow() [2/2]

template<typename... Ts>
Row google::cloud::spanner::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 228 of file row.h.

◆ MakeTimestamp() [1/3]

StatusOr<Timestamp> google::cloud::spanner::MakeTimestamp ( absl::Time  )

Construct a Timestamp from an absl::Time.

May produce out-of-range errors if the given time is beyond the range supported by Timestamp (see class comments above).

◆ MakeTimestamp() [2/3]

StatusOr<Timestamp> google::cloud::spanner::MakeTimestamp ( protobuf::Timestamp const &  )

Construct a Timestamp from a google::protobuf::Timestamp.

May produce out-of-range errors if the given protobuf is beyond the range supported by Timestamp (which a valid protobuf never will).

◆ MakeTimestamp() [3/3]

template<typename Duration >
StatusOr<Timestamp> google::cloud::spanner::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::int64_t. Requires that Duration::period is no more precise than std::nano.

Definition at line 179 of file timestamp.h.

◆ MakeUpdateMutation()

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

Creates a simple update mutation for the values in values.

Example
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 successful\n";
}
Mutation MakeUpdateMutation(std::string table_name, std::vector< std::string > columns, Ts &&... values)
Creates a simple update mutation for the values in values.
Definition: mutations.h:264
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 264 of file mutations.h.

◆ operator!=() [1/3]

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

Definition at line 74 of file json.h.

◆ operator!=() [2/3]

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

Definition at line 64 of file partition_options.h.

◆ operator!=() [3/3]

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

Definition at line 63 of file read_options.h.

◆ operator<<()

std::ostream& google::cloud::spanner::operator<< ( std::ostream &  os,
Json const &  json 
)
inline

Outputs a JSON-formatted string to the provided stream.

Definition at line 80 of file json.h.

◆ operator==() [1/3]

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

Definition at line 71 of file json.h.

◆ operator==() [2/3]

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

Definition at line 59 of file partition_options.h.

◆ operator==() [3/3]

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

Definition at line 57 of file read_options.h.

◆ SerializeQueryPartition()

StatusOr<std::string> google::cloud::spanner::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);
StatusOr< std::string > SerializeQueryPartition(QueryPartition const &query_partition)
Serializes an instance of QueryPartition to a string of bytes.

◆ SerializeReadPartition()

StatusOr<std::string> google::cloud::spanner::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);
StatusOr< std::string > SerializeReadPartition(ReadPartition const &read_partition)
Serializes an instance of ReadPartition to a string of bytes.

◆ StreamOf()

template<typename Tuple , typename RowRange >
TupleStream<Tuple> google::cloud::spanner::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.

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 446 of file row.h.

◆ ToDouble()

template<DecimalMode Mode>
double google::cloud::spanner::ToDouble ( Decimal< Mode > const &  d)

Conversion to the closest double value, with possible loss of precision.

Always succeeds (i.e., can never overflow, assuming a double can hold values up to 10^(kIntPrecision+1)).

Definition at line 272 of file numeric.h.

◆ ToInteger()

template<typename T , DecimalMode Mode, typename std::enable_if< std::numeric_limits< T >::is_integer &&!std::numeric_limits< T >::is_signed, int >::type = 0>
StatusOr< T > google::cloud::spanner::ToInteger ( Decimal< Mode > const &  d,
int  exponent = 0 
)

Conversion to the nearest integer value, scaled by 10^exponent.

Rounds halfway cases away from zero. Fails when the destination type cannot hold that value.

Example
auto d =
spanner::MakeDecimal<spanner::DecimalMode::kGoogleSQL>(123456789, -2)
.value();
assert(d.ToString() == "1234567.89");
assert(spanner::ToInteger<int>(d).value() == 1234568);
assert(spanner::ToInteger<int>(d, 2).value() == 123456789);

Definition at line 298 of file numeric.h.

◆ ToOptions() [1/2]

Options google::cloud::spanner::ToOptions ( PartitionOptions const &  )

Converts PartitionOptions to common Options.

◆ ToOptions() [2/2]

Options google::cloud::spanner::ToOptions ( ReadOptions const &  )

Converts ReadOptions to common Options.

◆ ToPartitionOptions()

PartitionOptions google::cloud::spanner::ToPartitionOptions ( Options const &  )

Converts common Options to PartitionOptions.

◆ ToReadOptions()

ReadOptions google::cloud::spanner::ToReadOptions ( Options const &  )

Converts common Options to ReadOptions.

◆ Version()

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

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

Definition at line 68 of file version.h.

◆ VersionMajor()

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

The Cloud spanner C++ Client major version.

Definition at line 55 of file version.h.

◆ VersionMinor()

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

The Cloud spanner C++ Client minor version.

Definition at line 60 of file version.h.

◆ VersionPatch()

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

The Cloud spanner C++ Client patch version.

Definition at line 65 of file version.h.

◆ VersionString()

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

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