@@ -38,7 +38,7 @@ limitations under the License.
3838#include " arrow/buffer.h"
3939#include " arrow/io/memory.h"
4040#include " arrow/ipc/api.h"
41- #include " google/cloud/bigquery/storage/v1beta1 /storage.grpc.pb.h"
41+ #include " google/cloud/bigquery/storage/v1 /storage.grpc.pb.h"
4242#include " tensorflow/core/framework/dataset.h"
4343#include " tensorflow/core/framework/resource_mgr.h"
4444#include " tensorflow/core/framework/tensor.h"
@@ -50,18 +50,18 @@ limitations under the License.
5050
5151namespace tensorflow {
5252
53- namespace apiv1beta1 = ::google::cloud::bigquery::storage::v1beta1 ;
53+ namespace apiv1 = ::google::cloud::bigquery::storage::v1 ;
5454static constexpr int kMaxReceiveMessageSize = -1 ; // Disabled
5555
5656Status GrpcStatusToTfStatus (const ::grpc::Status &status);
5757string GrpcStatusToString (const ::grpc::Status &status);
5858Status GetDataFormat (string data_format_str,
59- apiv1beta1 ::DataFormat *data_format);
59+ apiv1 ::DataFormat *data_format);
6060
6161class BigQueryClientResource : public ResourceBase {
6262 public:
6363 explicit BigQueryClientResource (
64- std::function<std::unique_ptr<apiv1beta1::BigQueryStorage ::Stub>(
64+ std::function<std::unique_ptr<apiv1::BigQueryRead ::Stub>(
6565 const string &read_stream)>
6666 stub_factory)
6767 : stub_factory_(stub_factory) {}
@@ -80,10 +80,10 @@ class BigQueryClientResource : public ResourceBase {
8080 args.SetString (" read_stream" , read_stream);
8181 auto channel = ::grpc::CreateCustomChannel (server_name, creds, args);
8282 VLOG (3 ) << " Creating GRPC channel" ;
83- return absl::make_unique<apiv1beta1::BigQueryStorage ::Stub>(channel);
83+ return absl::make_unique<apiv1::BigQueryRead ::Stub>(channel);
8484 }) {}
8585
86- apiv1beta1::BigQueryStorage ::Stub *GetStub (const string &read_stream)
86+ apiv1::BigQueryRead ::Stub *GetStub (const string &read_stream)
8787 TF_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
8888 if (stubs_.find (read_stream) == stubs_.end ()) {
8989 auto stub = stub_factory_ (read_stream);
@@ -95,11 +95,11 @@ class BigQueryClientResource : public ResourceBase {
9595 string DebugString () const override { return " BigQueryClientResource" ; }
9696
9797 private:
98- std::function<std::unique_ptr<apiv1beta1::BigQueryStorage ::Stub>(
98+ std::function<std::unique_ptr<apiv1::BigQueryRead ::Stub>(
9999 const string &)>
100100 stub_factory_;
101101 mutex mu_;
102- std::unordered_map<string, std::unique_ptr<apiv1beta1::BigQueryStorage ::Stub>>
102+ std::unordered_map<string, std::unique_ptr<apiv1::BigQueryRead ::Stub>>
103103 stubs_ TF_GUARDED_BY (mu_);
104104};
105105
@@ -156,11 +156,9 @@ class BigQueryReaderDatasetIteratorBase : public DatasetIterator<Dataset> {
156156 return OkStatus ();
157157 }
158158
159- apiv1beta1::ReadRowsRequest readRowsRequest;
160- readRowsRequest.mutable_read_position ()->mutable_stream ()->set_name (
161- this ->dataset ()->stream ());
162- readRowsRequest.mutable_read_position ()->set_offset (
163- this ->dataset ()->offset ());
159+ apiv1::ReadRowsRequest readRowsRequest;
160+ readRowsRequest.set_read_stream (this ->dataset ()->stream ());
161+ readRowsRequest.set_offset (this ->dataset ()->offset ());
164162
165163 read_rows_context_ = absl::make_unique<::grpc::ClientContext>();
166164 // The deadline is for the entire ReadRows (not a single message receipt),
@@ -169,14 +167,14 @@ class BigQueryReaderDatasetIteratorBase : public DatasetIterator<Dataset> {
169167 std::chrono::hours (24 ));
170168 read_rows_context_->AddMetadata (
171169 " x-goog-request-params" ,
172- absl::StrCat (" read_position.stream.name =" ,
173- readRowsRequest.read_position (). stream (). name ()));
170+ absl::StrCat (" read_stream =" ,
171+ readRowsRequest.read_stream ()));
174172
175173 VLOG (3 ) << " getting reader, stream: "
176- << readRowsRequest.read_position (). stream (). DebugString ();
174+ << readRowsRequest.read_stream ();
177175 reader_ = this ->dataset ()
178176 ->client_resource ()
179- ->GetStub (readRowsRequest.read_position (). stream (). name ())
177+ ->GetStub (readRowsRequest.read_stream ())
180178 ->ReadRows (read_rows_context_.get (), readRowsRequest);
181179
182180 return OkStatus ();
@@ -191,9 +189,9 @@ class BigQueryReaderDatasetIteratorBase : public DatasetIterator<Dataset> {
191189 int current_row_index_ = 0 ;
192190 mutex mu_;
193191 std::unique_ptr<::grpc::ClientContext> read_rows_context_ TF_GUARDED_BY (mu_);
194- std::unique_ptr<::grpc::ClientReader<apiv1beta1 ::ReadRowsResponse>> reader_
192+ std::unique_ptr<::grpc::ClientReader<apiv1 ::ReadRowsResponse>> reader_
195193 TF_GUARDED_BY (mu_);
196- std::unique_ptr<apiv1beta1 ::ReadRowsResponse> response_ TF_GUARDED_BY (mu_);
194+ std::unique_ptr<apiv1 ::ReadRowsResponse> response_ TF_GUARDED_BY (mu_);
197195};
198196
199197// BigQuery reader for Arrow serialized data.
@@ -213,11 +211,11 @@ class BigQueryReaderArrowDatasetIterator
213211 TF_EXCLUSIVE_LOCKS_REQUIRED(this ->mu_) override {
214212 if (this ->response_ && this ->response_ ->has_arrow_record_batch () &&
215213 this ->current_row_index_ <
216- this ->response_ ->arrow_record_batch (). row_count ()) {
214+ this ->response_ ->row_count ()) {
217215 return OkStatus ();
218216 }
219217
220- this ->response_ = absl::make_unique<apiv1beta1 ::ReadRowsResponse>();
218+ this ->response_ = absl::make_unique<apiv1 ::ReadRowsResponse>();
221219 if (!this ->reader_ ->Read (this ->response_ .get ())) {
222220 *end_of_sequence = true ;
223221 return GrpcStatusToTfStatus (this ->reader_ ->Finish ());
@@ -315,11 +313,11 @@ class BigQueryReaderAvroDatasetIterator
315313 Status EnsureHasRow (bool *end_of_sequence)
316314 TF_EXCLUSIVE_LOCKS_REQUIRED(this ->mu_) override {
317315 if (this ->response_ &&
318- this ->current_row_index_ < this ->response_ ->avro_rows (). row_count ()) {
316+ this ->current_row_index_ < this ->response_ ->row_count ()) {
319317 return OkStatus ();
320318 }
321319
322- this ->response_ = absl::make_unique<apiv1beta1 ::ReadRowsResponse>();
320+ this ->response_ = absl::make_unique<apiv1 ::ReadRowsResponse>();
323321 VLOG (3 ) << " calling read" ;
324322 if (!this ->reader_ ->Read (this ->response_ .get ())) {
325323 VLOG (3 ) << " no data" ;
0 commit comments