Google Cloud Spanner C++ Client  1.42.0
A C++ Client Library for Google Cloud Spanner
Public Member Functions | List of all members
google::cloud::spanner::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;
spanner::SqlStatement select(
"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";
}
}

Definition at line 158 of file results.h.

Constructor & Destructor Documentation

◆ ProfileQueryResult() [1/3]

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

◆ ProfileQueryResult() [2/3]

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

Definition at line 161 of file results.h.

◆ ProfileQueryResult() [3/3]

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

Member Function Documentation

◆ begin()

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

Returns a RowStreamIterator defining the beginning of this result set.

Definition at line 170 of file results.h.

◆ end()

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

Returns a RowStreamIterator defining the end of this result set.

Definition at line 176 of file results.h.

◆ ExecutionPlan()

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

Returns the plan of execution for the SQL statement.

◆ ExecutionStats()

absl::optional<std::unordered_map<std::string, std::string> > google::cloud::spanner::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.

◆ operator=()

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

◆ ReadTimestamp()

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

Retrieves the timestamp at which the read occurred.

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