Package com.google.cloud.spanner (6.71.0)

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.

ClientDescription
com.google.cloud.spanner.BatchClientInterface 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.DatabaseAdminClientClient to do admin operations on a Cloud Spanner Database.
com.google.cloud.spanner.DatabaseClientInterface 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.InstanceAdminClientClient to do admin operations on Cloud Spanner Instance and Instance Configs.

Classes

ClassDescription
com.google.cloud.spanner.AbstractLazyInitializerGeneric 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.AbstractStructReaderBase 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.BackupRepresents 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.BackupIdRepresents an id of a Cloud Spanner backup resource.
com.google.cloud.spanner.BackupInfoRepresents a Cloud Spanner database backup.
com.google.cloud.spanner.BackupInfo.Builder
com.google.cloud.spanner.BatchClientImplDefault implementation for Batch Client interface.
com.google.cloud.spanner.BatchTransactionIdBatchTransactionId 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.CommitResponseRepresents a response from a commit operation.
com.google.cloud.spanner.CommitStatsCommit 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.DatabaseRepresents a Cloud Spanner database. Database adds a layer of service related functionality over DatabaseInfo.
com.google.cloud.spanner.Database.Builder
com.google.cloud.spanner.DatabaseIdRepresents an id of a Cloud Spanner database resource.
com.google.cloud.spanner.DatabaseInfoRepresents a Cloud Spanner database.
com.google.cloud.spanner.DatabaseInfo.Builder
com.google.cloud.spanner.DatabaseRoleA Cloud Spanner database role.
com.google.cloud.spanner.DatabaseRole.Builder
com.google.cloud.spanner.ForwardingAsyncResultSetForwarding implementation of AsyncResultSet that forwards all calls to a delegate.
com.google.cloud.spanner.ForwardingResultSetForwarding implementation of ResultSet that forwards all calls to a delegate.
com.google.cloud.spanner.ForwardingStructReaderForwarding implements of StructReader
com.google.cloud.spanner.InstanceRepresents a Cloud Spanner Instance. Instance adds a layer of service related functionality over InstanceInfo.
com.google.cloud.spanner.Instance.BuilderBuilder of Instance.
com.google.cloud.spanner.InstanceConfigRepresents a Cloud Spanner instance config.InstanceConfig adds a layer of service related functionality over InstanceConfigInfo.
com.google.cloud.spanner.InstanceConfig.BuilderBuilder of InstanceConfig.
com.google.cloud.spanner.InstanceConfigIdReturns id of a Cloud Spanner instance config.
com.google.cloud.spanner.InstanceConfigInfoRepresents a Cloud Spanner instance config resource.
com.google.cloud.spanner.InstanceConfigInfo.BuilderBuilder for InstanceConfigInfo.
com.google.cloud.spanner.InstanceIdRepresents the resource name of a Cloud Spanner Instance.
com.google.cloud.spanner.InstanceInfoRepresents a Cloud Spanner Instance.
com.google.cloud.spanner.InstanceInfo.BuilderBuilder for InstanceInfo.
com.google.cloud.spanner.IsRetryableInternalError
com.google.cloud.spanner.KeyRepresents 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.BuilderBuilder for Key instances.
com.google.cloud.spanner.KeyRangeRepresents 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.BuilderBuilder for KeyRange instances.
com.google.cloud.spanner.KeySetDefines 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.BuilderBuilder for KeySet instances.
com.google.cloud.spanner.LatencyTest
com.google.cloud.spanner.LazySpannerInitializerDefault implementation of AbstractLazyInitializer for a Spanner instance.
com.google.cloud.spanner.MutationRepresents 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.WriteBuilderBuilder for Op#INSERT, Op#INSERT_OR_UPDATE, Op#UPDATE, and Op#REPLACE mutations.
com.google.cloud.spanner.MutationGroupRepresents a group of Cloud Spanner mutations to be committed together.
com.google.cloud.spanner.OpenCensusSpan
com.google.cloud.spanner.OpenTelemetryContextKeysKeys for OpenTelemetry context variables that are used by the Spanner client library. Only intended for internal use.
com.google.cloud.spanner.OperationRepresents a long-running operation.
com.google.cloud.spanner.OptionsSpecifies options for various spanner operations
com.google.cloud.spanner.PartitionDefines 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.PartitionOptionsDefines 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.BuilderBuilder for PartitionOptions instance.
com.google.cloud.spanner.PartitionedDmlTransaction
com.google.cloud.spanner.ReplicaInfoRepresents a Cloud Spanner replica information.
com.google.cloud.spanner.ReplicaInfo.BuilderImpl
com.google.cloud.spanner.RestoreRepresents a restore operation of a Cloud Spanner backup.
com.google.cloud.spanner.Restore.Builder
com.google.cloud.spanner.RestoreInfoRepresents the restore information of a Cloud Spanner database.
com.google.cloud.spanner.ResultSetsUtility methods for working with com.google.cloud.spanner.ResultSet.
com.google.cloud.spanner.SessionPoolOptionsOptions for the session pool used by DatabaseClient.
com.google.cloud.spanner.SessionPoolOptions.BuilderBuilder for creating SessionPoolOptions.
com.google.cloud.spanner.SessionPoolOptionsHelperSimple 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.SpannerExceptionFactoryA 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.SpannerOptionsOptions for the Cloud Spanner service.
com.google.cloud.spanner.SpannerOptions.BuilderBuilder for SpannerOptions instances.
com.google.cloud.spanner.SpannerOptions.FixedCloseableExecutorProviderImplementation of CloseableExecutorProvider that uses a fixed single ScheduledExecutorService.
com.google.cloud.spanner.SpannerOptions.SpannerCallContextTimeoutConfiguratorHelper 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.StatementA 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.BuilderBuilder for Statement.
com.google.cloud.spanner.StructRepresents 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.BuilderBuilder for constructing non-NULL Struct instances.
com.google.cloud.spanner.ThreadFactoryUtilUtility class for creating a thread factory for daemon or virtual threads.
com.google.cloud.spanner.TimestampBoundDefines 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.TypeDescribes 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.StructFieldDescribes an individual field in a STRUCT type.
com.google.cloud.spanner.ValueRepresents 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.ValueBinderAn 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

InterfaceDescription
com.google.cloud.spanner.AsyncResultSetInterface for result sets returned by async query methods.
com.google.cloud.spanner.AsyncResultSet.ReadyCallbackInterface for receiving asynchronous callbacks when new data is ready. See AsyncResultSet#setCallback(Executor, ReadyCallback).
com.google.cloud.spanner.AsyncRunner
com.google.cloud.spanner.AsyncRunner.AsyncWorkFunctional interface for executing a read/write transaction asynchronously that returns a result of type R.
com.google.cloud.spanner.AsyncTransactionManagerAn 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.AsyncTransactionFunctionEach 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.AsyncTransactionStepAsyncTransactionStep 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.CommitTimestampFutureApiFuture 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.TransactionContextFutureApiFuture that returns a TransactionContext and that supports chaining of multiple TransactionContextFutures to form a transaction.
com.google.cloud.spanner.BatchReadOnlyTransactionBatchReadOnlyTransaction 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.AdminApiOptionMarker interface to mark options applicable to operations in admin API.
com.google.cloud.spanner.Options.CreateAdminApiOptionMarker interface to mark options applicable to Create operations in admin API.
com.google.cloud.spanner.Options.CreateUpdateDeleteAdminApiOptionMarker interface to mark options applicable to Create, Update and Delete operations in admin API.
com.google.cloud.spanner.Options.DeleteAdminApiOptionMarker interface to mark options applicable to Delete operations in admin API.
com.google.cloud.spanner.Options.ListOptionMarker interface to mark options applicable to list operations in admin API.
com.google.cloud.spanner.Options.QueryOptionMarker interface to mark options applicable to query operation.
com.google.cloud.spanner.Options.ReadAndQueryOptionMarker interface to mark options applicable to both Read and Query operations
com.google.cloud.spanner.Options.ReadOptionMarker interface to mark options applicable to read operation
com.google.cloud.spanner.Options.ReadQueryUpdateTransactionOptionMarker interface to mark options applicable to Read, Query, Update and Write operations
com.google.cloud.spanner.Options.TransactionOptionMarker interface to mark options applicable to write operations
com.google.cloud.spanner.Options.UpdateAdminApiOptionMarker interface to mark options applicable to Update operations in admin API.
com.google.cloud.spanner.Options.UpdateOptionMarker interface to mark options applicable to update operation.
com.google.cloud.spanner.Options.UpdateTransactionOptionMarker interface to mark options applicable to Update and Write operations
com.google.cloud.spanner.ProtobufResultSetInterface for ResultSets that can return a protobuf value.
com.google.cloud.spanner.ReadContextA 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.ReadOnlyTransactionA 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.ResultSetProvides 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.SessionA 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.SpannerAn 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 ing session resources and exhausting session quota.
com.google.cloud.spanner.SpannerFactoryFactory to create instance of Spanner.
com.google.cloud.spanner.SpannerOptions.CallContextConfiguratorCallContextConfigurator 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.CallCredentialsProviderInterface that can be used to provide CallCredentials to SpannerOptions.
com.google.cloud.spanner.SpannerOptions.CloseableExecutorProviderExecutorProvider that is used for AsyncResultSet.
com.google.cloud.spanner.SpannerOptions.SpannerEnvironmentThe environment to read configuration values from. The default implementation uses environment variables.
com.google.cloud.spanner.StructReaderA 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.TransactionContextContext 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.TransactionManagerAn 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.TransactionRunnerAn 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.TransactionCallableA unit of work to be performed in the context of a transaction.

Enums

EnumDescription
com.google.cloud.spanner.AsyncResultSet.CallbackResponse
com.google.cloud.spanner.AsyncResultSet.CursorStateResponse code from tryNext().
com.google.cloud.spanner.BackupInfo.StateState of the backup.
com.google.cloud.spanner.DatabaseInfo.DatabaseFieldRepresent an updatable field in a Cloud Spanner database.
com.google.cloud.spanner.DatabaseInfo.StateState of the database.
com.google.cloud.spanner.DecodeModeSpecifies how and when to decode a value from protobuf to a plain Java object.
com.google.cloud.spanner.Dialect
com.google.cloud.spanner.ErrorCodeEnumerates the major types of error that the Cloud Spanner service can produce. These codes are accessible via SpannerException#getErrorCode().
com.google.cloud.spanner.InstanceConfigInfo.InstanceConfigFieldRepresent an updatable field in Cloud Spanner InstanceConfig.
com.google.cloud.spanner.InstanceConfigInfo.StateType of the Instance config.
com.google.cloud.spanner.InstanceConfigInfo.TypeType of the Instance config.
com.google.cloud.spanner.InstanceInfo.InstanceFieldRepresent an updatable field in Cloud Spanner instance.
com.google.cloud.spanner.InstanceInfo.StateState of the Instance.
com.google.cloud.spanner.KeyRange.EndpointDefines whether a range includes or excludes its endpoint keys.
com.google.cloud.spanner.Mutation.OpEnumerates the types of mutation that can be applied.
com.google.cloud.spanner.Options.RpcPriorityPriority 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.QueryAnalyzeModeUsed to specify the mode in which the query should be analyzed by ReadContext#analyzeQuery(Statement,QueryAnalyzeMode).
com.google.cloud.spanner.ReplicaInfo.ReplicaTypeIndicates 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.RestoreSourceTypeSource of the restore information.
com.google.cloud.spanner.TimestampBound.ModeThe type of timestamp bound. See the class documentation of TimestampBound for a detailed discussion of the various modes.
com.google.cloud.spanner.TransactionManager.TransactionStateState of the transaction manager.
com.google.cloud.spanner.Type.CodeEnumerates the categories of types.

Exceptions

ExceptionDescription
com.google.cloud.spanner.AbortedDueToConcurrentModificationExceptionException 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.AbortedExceptionException 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.AdminRequestsPerMinuteExceededExceptionException thrown by Cloud Spanner the number of administrative requests per minute has been exceeded.
com.google.cloud.spanner.DatabaseNotFoundExceptionException 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.InstanceNotFoundExceptionException 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.SessionNotFoundExceptionException 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.SpannerExceptionBase exception type for all exceptions produced by the Cloud Spanner service.
com.google.cloud.spanner.SpannerException.ResourceNotFoundExceptionBase exception type for NOT_FOUND exceptions for known resource types.