|
| 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