Google Cloud Bigtable C++ Client 2.13.0
A C++ Client Library for Google Cloud Bigtable
Loading...
Searching...
No Matches
row_reader.h
1// Copyright 2017 Google Inc.
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_ROW_READER_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_ROW_READER_H
17
18#include "google/cloud/bigtable/data_client.h"
19#include "google/cloud/bigtable/filters.h"
20#include "google/cloud/bigtable/internal/readrowsparser.h"
21#include "google/cloud/bigtable/internal/row_reader_impl.h"
22#include "google/cloud/bigtable/metadata_update_policy.h"
23#include "google/cloud/bigtable/row_set.h"
24#include "google/cloud/bigtable/rpc_backoff_policy.h"
25#include "google/cloud/bigtable/rpc_retry_policy.h"
26#include "google/cloud/bigtable/version.h"
27#include "google/cloud/internal/call_context.h"
28#include "google/cloud/stream_range.h"
29
30namespace google {
31namespace cloud {
32namespace bigtable {
33GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
34class RowReader;
35GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
36} // namespace bigtable
37namespace bigtable_internal {
38GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
39bigtable::RowReader MakeRowReader(std::shared_ptr<RowReaderImpl> impl);
40GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
41} // namespace bigtable_internal
42namespace bigtable {
43GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
44
45/**
46 * Object returned by Table::ReadRows(), enumerates rows in the response.
47 *
48 * @par Thread-safety
49 * Two threads operating concurrently on the same instance of this class or the
50 * iterators obtained from it are **not** guaranteed to work.
51 *
52 * Iterate over the results of ReadRows() using the STL idioms.
53 */
54class RowReader {
55 public:
56 /**
57 * A constant for the magic value that means "no limit, get all rows".
58 *
59 * Zero is used as a magic value that means "get all rows" in the
60 * Cloud Bigtable RPC protocol.
61 */
62 // NOLINTNEXTLINE(readability-identifier-naming)
63 static std::int64_t constexpr NO_ROWS_LIMIT = 0;
64
65 /// Default constructs an empty RowReader.
66 RowReader();
67
69 RowReader(std::shared_ptr<DataClient> client, std::string table_name,
70 RowSet row_set, std::int64_t rows_limit, Filter filter,
71 std::unique_ptr<RPCRetryPolicy> retry_policy,
72 std::unique_ptr<RPCBackoffPolicy> backoff_policy,
73 MetadataUpdatePolicy metadata_update_policy,
74 std::unique_ptr<internal::ReadRowsParserFactory> parser_factory);
75
77 RowReader(std::shared_ptr<DataClient> client, std::string app_profile_id,
78 std::string table_name, RowSet row_set, std::int64_t rows_limit,
79 Filter filter, std::unique_ptr<RPCRetryPolicy> retry_policy,
80 std::unique_ptr<RPCBackoffPolicy> backoff_policy,
81 MetadataUpdatePolicy metadata_update_policy,
82 std::unique_ptr<internal::ReadRowsParserFactory> parser_factory);
83
84 RowReader(RowReader&&) = default;
85
86 ~RowReader() = default;
87
88 using iterator = StreamRange<Row>::iterator;
89
90 /**
91 * Input iterator over rows in the response.
92 *
93 * The returned iterator is a single-pass input iterator that reads
94 * rows from the RowReader when incremented. The first row may be
95 * read when the iterator is constructed.
96 *
97 * Creating, and particularly incrementing, multiple iterators on
98 * the same RowReader is unsupported and can produce incorrect
99 * results.
100 *
101 * Retry and backoff policies are honored.
102 */
103 iterator begin();
104
105 /// End iterator over the rows in the response.
106 iterator end();
107
108 /**
109 * Gracefully terminate a streaming read.
110 *
111 * Invalidates iterators.
112 */
113 void Cancel();
114
115 private:
116 friend RowReader bigtable_internal::MakeRowReader(
117 std::shared_ptr<bigtable_internal::RowReaderImpl>);
118 explicit RowReader(std::shared_ptr<bigtable_internal::RowReaderImpl> impl)
119 : impl_(std::move(impl)) {}
120
121 google::cloud::internal::CallContext call_context_;
122 StreamRange<Row> stream_;
123 std::shared_ptr<bigtable_internal::RowReaderImpl> impl_;
124};
125
126GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
127} // namespace bigtable
128namespace bigtable_internal {
129GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
130
131inline bigtable::RowReader MakeRowReader(std::shared_ptr<RowReaderImpl> impl) {
132 return bigtable::RowReader(std::move(impl));
133}
134
135GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
136} // namespace bigtable_internal
137} // namespace cloud
138} // namespace google
139
140#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_ROW_READER_H
Connects to Cloud Bigtable's data manipulation APIs.
Definition: data_client.h:66
Define the interfaces to create filter expressions.
Definition: filters.h:52
MetadataUpdatePolicy holds supported metadata and setup ClientContext.
Definition: metadata_update_policy.h:76
Define the interface for controlling how the Bigtable client backsoff from failed RPC operations.
Definition: rpc_backoff_policy.h:44
Define the interface for controlling how the Bigtable client retries RPC operations.
Definition: rpc_retry_policy.h:78
Object returned by Table::ReadRows(), enumerates rows in the response.
Definition: row_reader.h:54
void Cancel()
Gracefully terminate a streaming read.
RowReader(RowReader &&)=default
RowReader()
Default constructs an empty RowReader.
iterator begin()
Input iterator over rows in the response.
iterator end()
End iterator over the rows in the response.
RowReader(std::shared_ptr< DataClient > client, std::string app_profile_id, std::string table_name, RowSet row_set, std::int64_t rows_limit, Filter filter, std::unique_ptr< RPCRetryPolicy > retry_policy, std::unique_ptr< RPCBackoffPolicy > backoff_policy, MetadataUpdatePolicy metadata_update_policy, std::unique_ptr< internal::ReadRowsParserFactory > parser_factory)
RowReader(std::shared_ptr< DataClient > client, std::string table_name, RowSet row_set, std::int64_t rows_limit, Filter filter, std::unique_ptr< RPCRetryPolicy > retry_policy, std::unique_ptr< RPCBackoffPolicy > backoff_policy, MetadataUpdatePolicy metadata_update_policy, std::unique_ptr< internal::ReadRowsParserFactory > parser_factory)
static std::int64_t constexpr NO_ROWS_LIMIT
A constant for the magic value that means "no limit, get all rows".
Definition: row_reader.h:63
Represent a (possibly non-continuous) set of row keys.
Definition: row_set.h:33
The in-memory representation of a Bigtable row.
Definition: row.h:34
Contains all the Cloud Bigtable C++ client APIs.
Definition: admin_client.h:28
#define GOOGLE_CLOUD_CPP_BIGTABLE_ROW_READER_CTOR_DEPRECATED()
Definition: version.h:28