Skip to content

Commit bd9704f

Browse files
authored
feat(bigtable): implement bigtable::ResultSourceInterface (#15575)
* feat(bigtable): implement bigtable::ResultSourceInterface
1 parent 01fb63e commit bd9704f

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

google/cloud/bigtable/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ add_library(
234234
read_modify_write_rule.h
235235
resource_names.cc
236236
resource_names.h
237+
results.h
237238
retry_policy.h
238239
row.h
239240
row_key.h

google/cloud/bigtable/google_cloud_cpp_bigtable.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ google_cloud_cpp_bigtable_hdrs = [
120120
"query_row.h",
121121
"read_modify_write_rule.h",
122122
"resource_names.h",
123+
"results.h",
123124
"retry_policy.h",
124125
"row.h",
125126
"row_key.h",

google/cloud/bigtable/results.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_RESULTS_H
16+
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_RESULTS_H
17+
18+
#include "google/cloud/bigtable/query_row.h"
19+
#include "google/cloud/bigtable/version.h"
20+
#include "google/cloud/status_or.h"
21+
22+
namespace google {
23+
namespace cloud {
24+
namespace bigtable {
25+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
26+
27+
/**
28+
* Defines the interface for `RowStream` implementations.
29+
*
30+
* The `RowStream` class represents a stream of `Rows` returned from
31+
* `bigtable::Table::ReadRows()`. There are
32+
* different implementations depending the the RPC. Applications can also
33+
* mock this class when testing their code and mocking the `bigtable::Table`
34+
* behavior.
35+
*/
36+
class ResultSourceInterface {
37+
public:
38+
virtual ~ResultSourceInterface() = default;
39+
40+
/**
41+
* Returns the next row in the stream.
42+
*
43+
* @return if the stream is interrupted due to a failure the
44+
* `StatusOr<bigtable::QueryRow>` contains the error. The function returns
45+
* a successful `StatusOr<>` with a `bigtable::QueryRow` with an empty
46+
* row_key() to indicate end-of-stream.
47+
*/
48+
virtual StatusOr<bigtable::QueryRow> NextRow() = 0;
49+
50+
/**
51+
* Returns metadata about the result set.
52+
*/
53+
virtual absl::optional<google::bigtable::v2::ResultSetMetadata>
54+
Metadata() = 0;
55+
};
56+
57+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
58+
} // namespace bigtable
59+
} // namespace cloud
60+
} // namespace google
61+
62+
#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_RESULTS_H

0 commit comments

Comments
 (0)