Google Cloud Spanner C++ Client 2.13.0
A C++ Client Library for Google Cloud Spanner
Loading...
Searching...
No Matches
Public Member Functions | List of all members
google::cloud::spanner::ProfileDmlResult Class Reference

Represents the result and profile stats of a data modifying operation using spanner::Client::ProfileDml(). More...

#include <google/cloud/spanner/results.h>

Public Member Functions

 ProfileDmlResult ()=default
 
 ProfileDmlResult (std::unique_ptr< ResultSourceInterface > source)
 
 ProfileDmlResult (ProfileDmlResult &&)=default
 
ProfileDmlResultoperator= (ProfileDmlResult &&)=default
 
std::int64_t RowsModified () const
 Returns the number of rows modified by the DML statement. More...
 
absl::optional< std::unordered_map< std::string, std::string > > ExecutionStats () const
 Returns a collection of key value pair statistics for the SQL statement execution. More...
 
absl::optional< spanner::ExecutionPlanExecutionPlan () const
 Returns the plan of execution for the SQL statement. More...
 

Detailed Description

Represents the result and profile stats of a data modifying operation using spanner::Client::ProfileDml().

This class encapsulates the result of a Cloud Spanner DML operation, i.e., INSERT, UPDATE, or DELETE.

Note
ProfileDmlResult returns the number of rows modified, execution statistics, and query plan.
Example:
auto commit_result = client.Commit(
[&client,
auto update = client.ProfileDml(
std::move(txn),
"UPDATE Albums SET MarketingBudget = MarketingBudget * 2"
" WHERE SingerId = 1 AND AlbumId = 1"));
if (!update) return std::move(update).status();
dml_result = *std::move(update);
});
if (!commit_result) throw std::move(commit_result).status();
// Stats only available after statement has been executed.
std::cout << "Rows modified: " << dml_result.RowsModified();
auto execution_stats = dml_result.ExecutionStats();
if (execution_stats) {
for (auto const& stat : *execution_stats) {
std::cout << stat.first << ":\t" << stat.second << "\n";
}
}
Represents the result and profile stats of a data modifying operation using spanner::Client::ProfileD...
Definition: results.h:244
absl::optional< std::unordered_map< std::string, std::string > > ExecutionStats() const
Returns a collection of key value pair statistics for the SQL statement execution.
std::int64_t RowsModified() const
Returns the number of rows modified by the DML statement.
Represents a potentially parameterized SQL statement.
Definition: sql_statement.h:51
The representation of a Cloud Spanner transaction.
Definition: transaction.h:58
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

Constructor & Destructor Documentation

◆ ProfileDmlResult() [1/3]

google::cloud::spanner::ProfileDmlResult::ProfileDmlResult ( )
default

◆ ProfileDmlResult() [2/3]

google::cloud::spanner::ProfileDmlResult::ProfileDmlResult ( std::unique_ptr< ResultSourceInterface source)
inlineexplicit

◆ ProfileDmlResult() [3/3]

google::cloud::spanner::ProfileDmlResult::ProfileDmlResult ( ProfileDmlResult &&  )
default

Member Function Documentation

◆ ExecutionPlan()

absl::optional< spanner::ExecutionPlan > google::cloud::spanner::ProfileDmlResult::ExecutionPlan ( ) const

Returns the plan of execution for the SQL statement.

◆ ExecutionStats()

absl::optional< std::unordered_map< std::string, std::string > > google::cloud::spanner::ProfileDmlResult::ExecutionStats ( ) const

Returns a collection of key value pair statistics for the SQL statement execution.

Note
Only available when the SQL statement is executed.

◆ operator=()

ProfileDmlResult & google::cloud::spanner::ProfileDmlResult::operator= ( ProfileDmlResult &&  )
default

◆ RowsModified()

std::int64_t google::cloud::spanner::ProfileDmlResult::RowsModified ( ) const

Returns the number of rows modified by the DML statement.

Note
Partitioned DML only provides a lower bound of the rows modified, all other DML statements provide an exact count.