Package com.google.cloud.spanner (6.74.0)

GitHub Repository

Client Classes

Client classes are the main entry point to using a package. They contain several variations of Java methods for each of the API's methods.

Client Description
com.google.cloud.spanner.BatchClient Interface for the Batch Client that is used to read data from a Cloud Spanner database. An instance of this is tied to a specific database.

BatchClient is useful when one wants to read or query a large amount of data from

com.google.cloud.spanner.DatabaseAdminClient Client to do admin operations on a Cloud Spanner Database.
com.google.cloud.spanner.DatabaseClient Interface for all the APIs that are used to read/write data into a Cloud Spanner database. An instance of this is tied to a specific database.
com.google.cloud.spanner.InstanceAdminClient Client to do admin operations on Cloud Spanner Instance and Instance Configs.

Classes

Class Description
com.google.cloud.spanner.AbstractLazyInitializer Generic AbstractLazyInitializer for any heavy-weight object that might throw an exception during initialization. The underlying object is initialized at most once.
com.google.cloud.spanner.AbstractStructReader Base class for assisting StructReader implementations.

This class implements the majority of the StructReader interface, leaving subclasses to implement core data access via the getTypeNameInternal() methods.

com.google.cloud.spanner.Backup Represents a Cloud Spanner database backup. Backup adds a layer of service related functionality over BackupInfo.
com.google.cloud.spanner.Backup.Builder
com.google.cloud.spanner.BackupId Represents an id of a Cloud Spanner backup resource.
com.google.cloud.spanner.BackupInfo Represents a Cloud Spanner database backup.
com.google.cloud.spanner.BackupInfo.Builder
com.google.cloud.spanner.BatchClientImpl Default implementation for Batch Client interface.
com.google.cloud.spanner.BatchTransactionId BatchTransactionId is unique identifier for BatchReadOnlyTransaction. It can be used to re-initialize a BatchReadOnlyTransaction on different machine or process by calling BatchClient#batchReadOnlyTransaction(BatchTransactionId).
com.google.cloud.spanner.BuiltInMetricsConstant
com.google.cloud.spanner.CommitResponse Represents a response from a commit operation.
com.google.cloud.spanner.CommitStats Commit statistics are returned by a read/write transaction if specifically requested by passing in Options#commitStats() to the transaction.
com.google.cloud.spanner.CompositeTracer
com.google.cloud.spanner.CompositeTracerFactory
com.google.cloud.spanner.Database Represents a Cloud Spanner database. Database adds a layer of service related functionality over DatabaseInfo.
com.google.cloud.spanner.Database.Builder
com.google.cloud.spanner.DatabaseId Represents an id of a Cloud Spanner database resource.
com.google.cloud.spanner.DatabaseInfo Represents a Cloud Spanner database.
com.google.cloud.spanner.DatabaseInfo.Builder
com.google.cloud.spanner.DatabaseRole A Cloud Spanner database role.
com.google.cloud.spanner.DatabaseRole.Builder
com.google.cloud.spanner.ForwardingAsyncResultSet Forwarding implementation of AsyncResultSet that forwards all calls to a delegate.
com.google.cloud.spanner.ForwardingResultSet Forwarding implementation of ResultSet that forwards all calls to a delegate.
com.google.cloud.spanner.ForwardingStructReader Forwarding implements of StructReader
com.google.cloud.spanner.Instance Represents a Cloud Spanner Instance. Instance adds a layer of service related functionality over InstanceInfo.
com.google.cloud.spanner.Instance.Builder Builder of Instance.
com.google.cloud.spanner.InstanceConfig Represents a Cloud Spanner instance config.InstanceConfig adds a layer of service related functionality over InstanceConfigInfo.
com.google.cloud.spanner.InstanceConfig.Builder Builder of InstanceConfig.
com.google.cloud.spanner.InstanceConfigId Returns id of a Cloud Spanner instance config.
com.google.cloud.spanner.InstanceConfigInfo Represents a Cloud Spanner instance config resource.
com.google.cloud.spanner.InstanceConfigInfo.Builder Builder for InstanceConfigInfo.
com.google.cloud.spanner.InstanceId Represents the resource name of a Cloud Spanner Instance.
com.google.cloud.spanner.InstanceInfo Represents a Cloud Spanner Instance.
com.google.cloud.spanner.InstanceInfo.Builder Builder for InstanceInfo.
com.google.cloud.spanner.IsRetryableInternalError
com.google.cloud.spanner.Key Represents a row key in a Cloud Spanner table or index. A key is a tuple of values constrained to the scalar Cloud Spanner types: currently these are BOOLEAN, INT64, FLOAT64, STRING, BYTES and TIMESTAMP. Values may be null where the table definition permits it.
com.google.cloud.spanner.Key.Builder Builder for Key instances.
com.google.cloud.spanner.KeyRange Represents a range of rows in a table or index.

A range has a start key and an end key. These keys can be open or closed, indicating if the range includes rows with that key.

com.google.cloud.spanner.KeyRange.Builder Builder for KeyRange instances.
com.google.cloud.spanner.KeySet Defines a collection of Cloud Spanner keys and/or key ranges. All the keys are expected to be in the same table or index. The keys need not be sorted in any particular way.

If the same key is specified multiple times in the set (for example if two ranges, two keys,

com.google.cloud.spanner.KeySet.Builder Builder for KeySet instances.
com.google.cloud.spanner.LatencyTest
com.google.cloud.spanner.LazySpannerInitializer Default implementation of AbstractLazyInitializer for a Spanner instance.
com.google.cloud.spanner.Mutation Represents an individual table modification to be applied to Cloud Spanner.

The types of mutation that can be created are defined by Op. To construct a mutation, use one of the builder methods. For example, to create a mutation that will insert a value of "x"

com.google.cloud.spanner.Mutation.WriteBuilder Builder for Op#INSERT, Op#INSERT_OR_UPDATE, Op#UPDATE, and Op#REPLACE mutations.
com.google.cloud.spanner.MutationGroup Represents a group of Cloud Spanner mutations to be committed together.
com.google.cloud.spanner.OpenCensusSpan
com.google.cloud.spanner.OpenTelemetryContextKeys Keys for OpenTelemetry context variables that are used by the Spanner client library. Only intended for internal use.
com.google.cloud.spanner.Operation Represents a long-running operation.
com.google.cloud.spanner.Options Specifies options for various spanner operations
com.google.cloud.spanner.Partition Defines the segments of data to be read in a batch read/query context. They can be serialized and processed across several different machines or processes.
com.google.cloud.spanner.PartitionOptions Defines the configuration for the number and size of partitions returned from BatchReadOnlyTransaction#partitionRead, BatchReadOnlyTransaction#partitionReadUsingIndex and BatchReadOnlyTransaction#partitionQuery

Note: these options may not be honored based on the other parameters in the request.

com.google.cloud.spanner.PartitionOptions.Builder Builder for PartitionOptions instance.
com.google.cloud.spanner.PartitionedDmlTransaction
com.google.cloud.spanner.ReplicaInfo Represents a Cloud Spanner replica information.
com.google.cloud.spanner.ReplicaInfo.BuilderImpl
com.google.cloud.spanner.Restore Represents a restore operation of a Cloud Spanner backup.
com.google.cloud.spanner.Restore.Builder
com.google.cloud.spanner.RestoreInfo Represents the restore information of a Cloud Spanner database.
com.google.cloud.spanner.ResultSets Utility methods for working with com.google.cloud.spanner.ResultSet.
com.google.cloud.spanner.SessionPoolOptions Options for the session pool used by DatabaseClient.
com.google.cloud.spanner.SessionPoolOptions.Builder Builder for creating SessionPoolOptions.
com.google.cloud.spanner.SessionPoolOptionsHelper Simple helper class to get access to a package-private method in the com.google.cloud.spanner.SessionPoolOptions.
com.google.cloud.spanner.SpannerApiFutures
com.google.cloud.spanner.SpannerExceptionFactory A factory for creating instances of SpannerException and its subtypes. All creation of these exceptions is directed through the factory. This ensures that particular types of errors are always expressed as the same concrete exception type. For example, exceptions of type ErrorCode#ABORTED are always represented by AbortedException.
com.google.cloud.spanner.SpannerOptions Options for the Cloud Spanner service.
com.google.cloud.spanner.SpannerOptions.Builder Builder for SpannerOptions instances.
com.google.cloud.spanner.SpannerOptions.FixedCloseableExecutorProvider Implementation of CloseableExecutorProvider that uses a fixed single ScheduledExecutorService.
com.google.cloud.spanner.SpannerOptions.SpannerCallContextTimeoutConfigurator Helper class to configure timeouts for specific Spanner RPCs. The SpannerCallContextTimeoutConfigurator must be set as a value on the Context using the SpannerOptions#CALL_CONTEXT_CONFIGURATOR_KEY key.

Example usage:

com.google.cloud.spanner.SpannerRpcMetrics
com.google.cloud.spanner.Statement A SQL statement and optional bound parameters that can be executed in a ReadContext.

The SQL query string can contain parameter placeholders. A parameter placeholder consists of @ followed by the parameter name. Parameter names consist of any combination of

com.google.cloud.spanner.Statement.Builder Builder for Statement.
com.google.cloud.spanner.Struct Represents a non-NULL value of Type.Code#STRUCT. Such values are a tuple of named and typed columns, where individual columns may be null. Individual rows from a read or query operation can be considered as structs; ResultSet#getCurrentRowAsStruct() allows an immutable struct to be created from the row that the result set is currently positioned over.
com.google.cloud.spanner.Struct.Builder Builder for constructing non-NULL Struct instances.
com.google.cloud.spanner.ThreadFactoryUtil Utility class for creating a thread factory for daemon or virtual threads.
com.google.cloud.spanner.TimestampBound Defines how Cloud Spanner will choose a timestamp for a read-only transaction or a single read/query.

The types of timestamp bound are:

com.google.cloud.spanner.Type Describes a type in the Cloud Spanner type system. Types can either be primitive (for example, INT64 and STRING) or composite (for example, ARRAY<INT64> or STRUCT<INT64,STRING>).
com.google.cloud.spanner.Type.StructField Describes an individual field in a STRUCT type.
com.google.cloud.spanner.Value Represents a value to be consumed by the Cloud Spanner API. A value can be NULL or non-NULL; regardless, values always have an associated type.

The Value API is optimized for construction, since this is the majority use-case when

com.google.cloud.spanner.ValueBinder An interface for binding a Value in some context. Users of the Cloud Spanner client library never create a ValueBinder directly; instead this interface is returned from other parts of the library involved in Value construction. For example, Mutation.WriteBuilder#set(String) returns a binder to bind a column value, and Statement#bind(String) returns a binder to bind a parameter to a value.

Interfaces

Interface Description
com.google.cloud.spanner.AsyncResultSet Interface for result sets returned by async query methods.
com.google.cloud.spanner.AsyncResultSet.ReadyCallback Interface for receiving asynchronous callbacks when new data is ready. See AsyncResultSet#setCallback(Executor, ReadyCallback).
com.google.cloud.spanner.AsyncRunner
com.google.cloud.spanner.AsyncRunner.AsyncWork Functional interface for executing a read/write transaction asynchronously that returns a result of type R.
com.google.cloud.spanner.AsyncTransactionManager An interface for managing the life cycle of a read write transaction including all its retries. See TransactionContext for a description of transaction semantics.

At any point in time there can be at most one active transaction in this manager. When that

com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionFunction Each step in a transaction chain is defined by an AsyncTransactionFunction. It receives a TransactionContext and the output value of the previous transaction step as its input parameters. The method should return an ApiFuture that will return the result of this step.
com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionStep AsyncTransactionStep is returned by TransactionContextFuture#then(AsyncTransactionFunction, Executor) and AsyncTransactionStep#then(AsyncTransactionFunction, Executor) and allows transaction steps that should be executed serially to be chained together. Each step can contain one or more statements that may execute in parallel.
com.google.cloud.spanner.AsyncTransactionManager.CommitTimestampFuture ApiFuture that returns the commit Timestamp of a Cloud Spanner transaction that is executed using an AsyncTransactionManager. This future is returned by the call to AsyncTransactionStep#commitAsync() of the last step in the transaction.
com.google.cloud.spanner.AsyncTransactionManager.TransactionContextFuture ApiFuture that returns a TransactionContext and that supports chaining of multiple TransactionContextFutures to form a transaction.
com.google.cloud.spanner.BatchReadOnlyTransaction BatchReadOnlyTransaction can be configured to read at timestamps in the past and allows for exporting arbitrarily large amounts of data from Cloud Spanner databases. This is a read only transaction which additionally allows to partition a read or query request. Read/query request can then be executed independently over each partition while observing the same snapshot of the
com.google.cloud.spanner.Options.AdminApiOption Marker interface to mark options applicable to operations in admin API.
com.google.cloud.spanner.Options.CreateAdminApiOption Marker interface to mark options applicable to Create operations in admin API.
com.google.cloud.spanner.Options.CreateUpdateDeleteAdminApiOption Marker interface to mark options applicable to Create, Update and Delete operations in admin API.
com.google.cloud.spanner.Options.DeleteAdminApiOption Marker interface to mark options applicable to Delete operations in admin API.
com.google.cloud.spanner.Options.ListOption Marker interface to mark options applicable to list operations in admin API.
com.google.cloud.spanner.Options.QueryOption Marker interface to mark options applicable to query operation.
com.google.cloud.spanner.Options.ReadAndQueryOption Marker interface to mark options applicable to both Read and Query operations
com.google.cloud.spanner.Options.ReadOption Marker interface to mark options applicable to read operation
com.google.cloud.spanner.Options.ReadQueryUpdateTransactionOption Marker interface to mark options applicable to Read, Query, Update and Write operations
com.google.cloud.spanner.Options.TransactionOption Marker interface to mark options applicable to write operations
com.google.cloud.spanner.Options.UpdateAdminApiOption Marker interface to mark options applicable to Update operations in admin API.
com.google.cloud.spanner.Options.UpdateOption Marker interface to mark options applicable to update operation.
com.google.cloud.spanner.Options.UpdateTransactionOption Marker interface to mark options applicable to Update and Write operations
com.google.cloud.spanner.ProtobufResultSet Interface for ResultSets that can return a protobuf value.
com.google.cloud.spanner.ReadContext A concurrency context in which to run a read or SQL statement. All ReadContexts are implicitly bound to a Session and therefore a particular Database.
com.google.cloud.spanner.ReadOnlyTransaction A transaction type that provides guaranteed consistency across several reads, but does not allow writes. Snapshot read-only transactions can be configured to read at timestamps in the past. Snapshot read-only transactions do not need to be committed.
com.google.cloud.spanner.ResultSet Provides access to the data returned by a Cloud Spanner read or query. ResultSet allows a single row to be inspected at a time through the methods from the StructReader interface, in the order that the rows were returned by the read or query. The result set can be positioned over the next row, if one exists, by calling #next(); this method returns false
com.google.cloud.spanner.Session A Session can be used to perform transactions that read and/or modify data in a Cloud Spanner database.

Sessions can only execute one transaction at a time. To execute multiple concurrent

com.google.cloud.spanner.Spanner An interface for Cloud Spanner. Typically, there would only be one instance of this for the lifetime of the application which must be closed by invoking #close() when it is no longer needed. Failure to do so may result in leaking session resources and exhausting session quota.
com.google.cloud.spanner.SpannerFactory Factory to create instance of Spanner.
com.google.cloud.spanner.SpannerOptions.CallContextConfigurator CallContextConfigurator can be used to modify the ApiCallContext for one or more specific RPCs. This can be used to set specific timeout value for RPCs or use specific CallCredentials for an RPC. The CallContextConfigurator must be set as a value on the Context using the SpannerOptions#CALL_CONTEXT_CONFIGURATOR_KEY key.
com.google.cloud.spanner.SpannerOptions.CallCredentialsProvider Interface that can be used to provide CallCredentials to SpannerOptions.
com.google.cloud.spanner.SpannerOptions.CloseableExecutorProvider ExecutorProvider that is used for AsyncResultSet.
com.google.cloud.spanner.SpannerOptions.SpannerEnvironment The environment to read configuration values from. The default implementation uses environment variables.
com.google.cloud.spanner.StructReader A base interface for reading the fields of a STRUCT. The Cloud Spanner yields StructReader instances as one of the subclasses ResultSet or Struct, most commonly as the result of a read or query operation. At any point in time, a StructReader provides access to a single tuple of data comprising multiple typed columns. Each column may have
com.google.cloud.spanner.TransactionContext Context for a single attempt of a locking read-write transaction. This type of transaction is the only way to write data into Cloud Spanner; Session#write(Iterable) and Session#writeAtLeastOnce(Iterable) use transactions internally. These transactions rely on pessimistic locking and, if necessary, two-phase commit. Locking read-write transactions may abort, requiring the application to retry. However, the interface exposed by TransactionRunner eliminates the need for applications to write retry loops explicitly.
com.google.cloud.spanner.TransactionManager An interface for managing the life cycle of a read write transaction including all its retries. See TransactionContext for a description of transaction semantics.

At any point in time there can be at most one active transaction in this manager. When that

com.google.cloud.spanner.TransactionRunner An interface for executing a body of work in the context of a read-write transaction, with retries for transaction aborts. See TransactionContext for a description of transaction semantics. TransactionRunner instances are obtained by calling DatabaseClient#readWriteTransaction(TransactionOption...).
com.google.cloud.spanner.TransactionRunner.TransactionCallable A unit of work to be performed in the context of a transaction.

Enums

Enum Description
com.google.cloud.spanner.AsyncResultSet.CallbackResponse
com.google.cloud.spanner.AsyncResultSet.CursorState Response code from tryNext().
com.google.cloud.spanner.BackupInfo.State State of the backup.
com.google.cloud.spanner.DatabaseInfo.DatabaseField Represent an updatable field in a Cloud Spanner database.
com.google.cloud.spanner.DatabaseInfo.State State of the database.
com.google.cloud.spanner.DecodeMode Specifies how and when to decode a value from protobuf to a plain Java object.
com.google.cloud.spanner.Dialect
com.google.cloud.spanner.ErrorCode Enumerates the major types of error that the Cloud Spanner service can produce. These codes are accessible via SpannerException#getErrorCode().
com.google.cloud.spanner.InstanceConfigInfo.InstanceConfigField Represent an updatable field in Cloud Spanner InstanceConfig.
com.google.cloud.spanner.InstanceConfigInfo.State Type of the Instance config.
com.google.cloud.spanner.InstanceConfigInfo.Type Type of the Instance config.
com.google.cloud.spanner.InstanceInfo.InstanceField Represent an updatable field in Cloud Spanner instance.
com.google.cloud.spanner.InstanceInfo.State State of the Instance.
com.google.cloud.spanner.KeyRange.Endpoint Defines whether a range includes or excludes its endpoint keys.
com.google.cloud.spanner.Mutation.Op Enumerates the types of mutation that can be applied.
com.google.cloud.spanner.Options.RpcOrderBy OrderBy for an RPC invocation. The default orderby is #PRIMARY_KEY. This enum can be used to control the order in which rows are returned from a read.
com.google.cloud.spanner.Options.RpcPriority Priority for an RPC invocation. The default priority is #HIGH. This enum can be used to set a lower priority for a specific RPC invocation.
com.google.cloud.spanner.ReadContext.QueryAnalyzeMode Used to specify the mode in which the query should be analyzed by ReadContext#analyzeQuery(Statement,QueryAnalyzeMode).
com.google.cloud.spanner.ReplicaInfo.ReplicaType Indicates the type of the replica. See the replica types documentation at https://cloud.google.com/spanner/docs/replication#replica_types for more details.
com.google.cloud.spanner.RestoreInfo.RestoreSourceType Source of the restore information.
com.google.cloud.spanner.TimestampBound.Mode The type of timestamp bound. See the class documentation of TimestampBound for a detailed discussion of the various modes.
com.google.cloud.spanner.TransactionManager.TransactionState State of the transaction manager.
com.google.cloud.spanner.Type.Code Enumerates the categories of types.

Exceptions

Exception Description
com.google.cloud.spanner.AbortedDueToConcurrentModificationException Exception thrown by a Connection when a database operation detects that a transaction has aborted and an internal retry failed because of a concurrent modification. This type of error has its own subclass since it is often necessary to handle this specific kind of aborted exceptions differently to other types of errors.
com.google.cloud.spanner.AbortedException Exception thrown by Cloud Spanner when an operation detects that a transaction has aborted. This type of error has its own subclass since it is often necessary to handle aborted differently to other types of errors, most typically by retrying the transaction.
com.google.cloud.spanner.AdminRequestsPerMinuteExceededException Exception thrown by Cloud Spanner the number of administrative requests per minute has been exceeded.
com.google.cloud.spanner.DatabaseNotFoundException Exception thrown by Cloud Spanner when an operation detects that the database that is being used no longer exists. This type of error has its own subclass as it is a condition that should cause the client library to stop trying to send RPCs to the backend until the user has taken action.
com.google.cloud.spanner.InstanceNotFoundException Exception thrown by Cloud Spanner when an operation detects that the instance that is being used no longer exists. This type of error has its own subclass as it is a condition that should cause the client library to stop trying to send RPCs to the backend until the user has taken action.
com.google.cloud.spanner.IsSslHandshakeException
com.google.cloud.spanner.SessionNotFoundException Exception thrown by Cloud Spanner when an operation detects that the session that is being used is no longer valid. This type of error has its own subclass as it is a condition that should normally be hidden from the user, and the client library should try to fix this internally.
com.google.cloud.spanner.SpannerBatchUpdateException
com.google.cloud.spanner.SpannerException Base exception type for all exceptions produced by the Cloud Spanner service.
com.google.cloud.spanner.SpannerException.ResourceNotFoundException Base exception type for NOT_FOUND exceptions for known resource types.