-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(spanner): make ResultSourceInterface
public
#11636
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,24 +27,49 @@ | |
|
||
namespace google { | ||
namespace cloud { | ||
namespace spanner_internal { | ||
namespace spanner { | ||
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN | ||
|
||
/** | ||
* Defines the interface for `RowStream` implementations. | ||
* | ||
* The `RowStream` class represents a stream of `Rows` returned from | ||
* `spanner::Client::Read()` or `spanner::Client::ExecuteQuery()`. There are | ||
* different implementations depending the the RPC. Applications can also | ||
* mock this class when testing their code and mocking the `spanner::Client` | ||
* behavior. | ||
*/ | ||
class ResultSourceInterface { | ||
public: | ||
virtual ~ResultSourceInterface() = default; | ||
// Returns OK Status with an empty Row to indicate end-of-stream. | ||
|
||
/** | ||
* Returns the next row in the stream. | ||
* | ||
* @return if the stream is interrupted due to a failure the | ||
* `StatusOr<spanner::Row>` contains the error. If the | ||
*/ | ||
virtual StatusOr<spanner::Row> NextRow() = 0; | ||
|
||
/** | ||
* Returns metadata about the result set, such as the field types and the | ||
* transaction id created by the request. | ||
* | ||
* @see https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#resultsetmetadata | ||
* for more information. | ||
*/ | ||
virtual absl::optional<google::spanner::v1::ResultSetMetadata> Metadata() = 0; | ||
|
||
/** | ||
* Returns statiscs about the result set, such as the number of rows returned, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/statiscs/statistics/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/rows returned/rows/ perhaps? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
* or the query plan used to compute the results. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/or/and/? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
* | ||
* @see https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#resultsetstats | ||
* for more information. | ||
*/ | ||
virtual absl::optional<google::spanner::v1::ResultSetStats> Stats() const = 0; | ||
}; | ||
|
||
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END | ||
} // namespace spanner_internal | ||
|
||
namespace spanner { | ||
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN | ||
|
||
/** | ||
* Contains a hierarchical representation of the operations the database server | ||
* performs in order to execute a particular SQL statement. | ||
|
@@ -74,8 +99,7 @@ using ExecutionPlan = ::google::spanner::v1::QueryPlan; | |
class RowStream { | ||
public: | ||
RowStream() = default; | ||
explicit RowStream( | ||
std::unique_ptr<spanner_internal::ResultSourceInterface> source) | ||
explicit RowStream(std::unique_ptr<ResultSourceInterface> source) | ||
: source_(std::move(source)) {} | ||
|
||
// This class is movable but not copyable. | ||
|
@@ -102,7 +126,7 @@ class RowStream { | |
absl::optional<Timestamp> ReadTimestamp() const; | ||
|
||
private: | ||
std::unique_ptr<spanner_internal::ResultSourceInterface> source_; | ||
std::unique_ptr<ResultSourceInterface> source_; | ||
}; | ||
|
||
/** | ||
|
@@ -120,8 +144,7 @@ class RowStream { | |
class DmlResult { | ||
public: | ||
DmlResult() = default; | ||
explicit DmlResult( | ||
std::unique_ptr<spanner_internal::ResultSourceInterface> source) | ||
explicit DmlResult(std::unique_ptr<ResultSourceInterface> source) | ||
: source_(std::move(source)) {} | ||
|
||
// This class is movable but not copyable. | ||
|
@@ -137,7 +160,7 @@ class DmlResult { | |
std::int64_t RowsModified() const; | ||
|
||
private: | ||
std::unique_ptr<spanner_internal::ResultSourceInterface> source_; | ||
std::unique_ptr<ResultSourceInterface> source_; | ||
}; | ||
|
||
/** | ||
|
@@ -161,8 +184,7 @@ class DmlResult { | |
class ProfileQueryResult { | ||
public: | ||
ProfileQueryResult() = default; | ||
explicit ProfileQueryResult( | ||
std::unique_ptr<spanner_internal::ResultSourceInterface> source) | ||
explicit ProfileQueryResult(std::unique_ptr<ResultSourceInterface> source) | ||
: source_(std::move(source)) {} | ||
|
||
// This class is movable but not copyable. | ||
|
@@ -201,7 +223,7 @@ class ProfileQueryResult { | |
absl::optional<spanner::ExecutionPlan> ExecutionPlan() const; | ||
|
||
private: | ||
std::unique_ptr<spanner_internal::ResultSourceInterface> source_; | ||
std::unique_ptr<ResultSourceInterface> source_; | ||
}; | ||
|
||
/** | ||
|
@@ -220,8 +242,7 @@ class ProfileQueryResult { | |
class ProfileDmlResult { | ||
public: | ||
ProfileDmlResult() = default; | ||
explicit ProfileDmlResult( | ||
std::unique_ptr<spanner_internal::ResultSourceInterface> source) | ||
explicit ProfileDmlResult(std::unique_ptr<ResultSourceInterface> source) | ||
: source_(std::move(source)) {} | ||
|
||
// This class is movable but not copyable. | ||
|
@@ -251,11 +272,21 @@ class ProfileDmlResult { | |
absl::optional<spanner::ExecutionPlan> ExecutionPlan() const; | ||
|
||
private: | ||
std::unique_ptr<spanner_internal::ResultSourceInterface> source_; | ||
std::unique_ptr<ResultSourceInterface> source_; | ||
}; | ||
|
||
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END | ||
} // namespace spanner | ||
|
||
namespace spanner_internal { | ||
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN | ||
|
||
/// @deprecated Prefer using `spanner::ResultSourceInterface` directly. | ||
using ResultSourceInterface = spanner::ResultSourceInterface; | ||
|
||
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END | ||
} // namespace spanner_internal | ||
|
||
} // namespace cloud | ||
} // namespace google | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"If the ..."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed