Class BackendConnection (0.15.0)

public class BackendConnection

This class emulates a backend PostgreSQL connection. Statements are buffered in memory until a flush/sync is received. This makes it possible to batch multiple statements together before sending these to Cloud Spanner. This class also keeps track of the transaction status of the connection.

Inheritance

java.lang.Object > BackendConnection

Static Fields

TRANSACTION_ABORTED_ERROR

public static final String TRANSACTION_ABORTED_ERROR
Field Value
TypeDescription
String

Methods

analyze(AbstractStatementParser.ParsedStatement parsedStatement, Statement statement)

public ListenableFuture<StatementResult> analyze(AbstractStatementParser.ParsedStatement parsedStatement, Statement statement)
Parameters
NameDescription
parsedStatementParsedStatement
statementcom.google.cloud.spanner.Statement
Returns
TypeDescription
com.google.common.util.concurrent.ListenableFuture<StatementResult>

execute(AbstractStatementParser.ParsedStatement parsedStatement, Statement statement, Function<Statement,Statement> statementBinder)

public Future<StatementResult> execute(AbstractStatementParser.ParsedStatement parsedStatement, Statement statement, Function<Statement,Statement> statementBinder)

Buffers the given statement for execution on the backend connection when the next flush/sync message is received. The returned future will contain the result of the statement when execution has finished.

Parameters
NameDescription
parsedStatementParsedStatement
statementcom.google.cloud.spanner.Statement
statementBinderFunction<com.google.cloud.spanner.Statement,com.google.cloud.spanner.Statement>
Returns
TypeDescription
Future<StatementResult>

execute(TruncateStatement truncateStatement)

public Future<StatementResult> execute(TruncateStatement truncateStatement)
Parameter
NameDescription
truncateStatementTruncateStatement
Returns
TypeDescription
Future<StatementResult>

execute(VacuumStatement vacuumStatement)

public Future<StatementResult> execute(VacuumStatement vacuumStatement)
Parameter
NameDescription
vacuumStatementVacuumStatement
Returns
TypeDescription
Future<StatementResult>

executeCopy(AbstractStatementParser.ParsedStatement parsedStatement, Statement statement, CopyDataReceiver copyDataReceiver, MutationWriter mutationWriter, ExecutorService executor)

public Future<StatementResult> executeCopy(AbstractStatementParser.ParsedStatement parsedStatement, Statement statement, CopyDataReceiver copyDataReceiver, MutationWriter mutationWriter, ExecutorService executor)

Buffers the given COPY operation for execution on the backend connection when the next flush/sync message is received. The returned future will contain the result of the COPY operation when execution has finished.

Parameters
NameDescription
parsedStatementParsedStatement
statementcom.google.cloud.spanner.Statement
copyDataReceiverCopyDataReceiver
mutationWriterMutationWriter
executorExecutorService
Returns
TypeDescription
Future<StatementResult>

executeCopyOut(AbstractStatementParser.ParsedStatement parsedStatement, Statement statement)

public Future<StatementResult> executeCopyOut(AbstractStatementParser.ParsedStatement parsedStatement, Statement statement)
Parameters
NameDescription
parsedStatementParsedStatement
statementcom.google.cloud.spanner.Statement
Returns
TypeDescription
Future<StatementResult>

getConnectionState()

public BackendConnection.ConnectionState getConnectionState()

Returns the current connection state.

Returns
TypeDescription
BackendConnection.ConnectionState

getCurrentDatabase()

public String getCurrentDatabase()

Returns the id of the database that this connection uses.

Returns
TypeDescription
String

getCurrentSchema()

public String getCurrentSchema()

Returns the current schema that is used by this BackendConnection.

Returns
TypeDescription
String

getSessionState()

public SessionState getSessionState()

Returns the session state of this connection.

Returns
TypeDescription
SessionState

getSpannerConnection()

public Connection getSpannerConnection()

Returns the Spanner connection used by this BackendConnection.

Returns
TypeDescription
Connection

initSessionSetting(String name, String value)

public void initSessionSetting(String name, String value)

Sets the initial value of a pg_settings setting for this connection. This method should only be called during startup with values that come from the connection request.

Parameters
NameDescription
nameString
valueString