Google Cloud Spanner C++ Client  1.32.0
A C++ Client Library for Google Cloud Spanner
Public Member Functions | List of all members
google::cloud::spanner::v1::ProfileQueryResult Class Reference

Represents the stream of Rows and profile stats returned from spanner::Client::ProfileQuery(). More...

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

Public Member Functions

 ProfileQueryResult ()=default
 
 ProfileQueryResult (std::unique_ptr< spanner_internal::ResultSourceInterface > source)
 
 ProfileQueryResult (ProfileQueryResult &&)=default
 
ProfileQueryResultoperator= (ProfileQueryResult &&)=default
 
RowStreamIterator begin ()
 Returns a RowStreamIterator defining the beginning of this result set. More...
 
RowStreamIterator end ()
 Returns a RowStreamIterator defining the end of this result set. More...
 
absl::optional< TimestampReadTimestamp () const
 Retrieves the timestamp at which the read occurred. 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 stream of Rows and profile stats returned from spanner::Client::ProfileQuery().

This is a range defined by the Input Iterators returned from its begin() and end() members. Callers may directly iterate the ProfileQueryResult instance, which will return a sequence of StatusOr<Row> objects.

For convenience, callers may wrap instances in a StreamOf<std::tuple<...>> object, which will automatically parse each Row into a std::tuple with the specified types.

Example:
namespace spanner = ::google::cloud::spanner;
"SELECT AlbumId, AlbumTitle, MarketingBudget"
" FROM Albums"
" WHERE AlbumTitle >= 'Aardvark' AND AlbumTitle < 'Goo'");
auto profile_query_result = client.ProfileQuery(std::move(select));
for (auto const& row : profile_query_result) {
if (!row) throw std::runtime_error(row.status().message());
// Discard rows for brevity in this example.
}
// Stats are only available after all rows from the result have been read.
auto execution_stats = profile_query_result.ExecutionStats();
if (execution_stats) {
for (auto const& stat : *execution_stats) {
std::cout << stat.first << ":\t" << stat.second << "\n";
}
}
Represents a potentially parameterized SQL statement.
Definition: sql_statement.h:51
Contains all the Cloud Spanner C++ client types and functions.
Definition: backup.cc:21

Definition at line 157 of file results.h.

Constructor & Destructor Documentation

◆ ProfileQueryResult() [1/3]

google::cloud::spanner::v1::ProfileQueryResult::ProfileQueryResult ( )
default

◆ ProfileQueryResult() [2/3]

google::cloud::spanner::v1::ProfileQueryResult::ProfileQueryResult ( std::unique_ptr< spanner_internal::ResultSourceInterface >  source)
inlineexplicit

Definition at line 160 of file results.h.

◆ ProfileQueryResult() [3/3]

google::cloud::spanner::v1::ProfileQueryResult::ProfileQueryResult ( ProfileQueryResult &&  )
default

Member Function Documentation

◆ begin()

RowStreamIterator google::cloud::spanner::v1::ProfileQueryResult::begin ( )
inline

Returns a RowStreamIterator defining the beginning of this result set.

Definition at line 169 of file results.h.

◆ end()

RowStreamIterator google::cloud::spanner::v1::ProfileQueryResult::end ( )
inline

Returns a RowStreamIterator defining the end of this result set.

Definition at line 175 of file results.h.

◆ ExecutionPlan()

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

Returns the plan of execution for the SQL statement.

Definition at line 90 of file results.cc.

◆ ExecutionStats()

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

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

Note
Only available when the statement is executed and all results have been read.

Definition at line 86 of file results.cc.

◆ operator=()

ProfileQueryResult& google::cloud::spanner::v1::ProfileQueryResult::operator= ( ProfileQueryResult &&  )
default

◆ ReadTimestamp()

absl::optional< Timestamp > google::cloud::spanner::v1::ProfileQueryResult::ReadTimestamp ( ) const

Retrieves the timestamp at which the read occurred.

Note
Only available if a read-only transaction was used.

Definition at line 73 of file results.cc.