1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752
// This file is @generated by prost-build.
/// Arrow schema.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ArrowSchema {
/// IPC serialized Arrow schema.
#[prost(bytes = "bytes", tag = "1")]
pub serialized_schema: ::prost::bytes::Bytes,
}
/// Arrow RecordBatch.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ArrowRecordBatch {
/// IPC serialized Arrow RecordBatch.
#[prost(bytes = "bytes", tag = "1")]
pub serialized_record_batch: ::prost::bytes::Bytes,
/// The count of rows in the returning block.
#[prost(int64, tag = "2")]
pub row_count: i64,
}
/// Avro schema.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AvroSchema {
/// Json serialized schema, as described at
/// <https://avro.apache.org/docs/1.8.1/spec.html>
#[prost(string, tag = "1")]
pub schema: ::prost::alloc::string::String,
}
/// Avro rows.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AvroRows {
/// Binary serialized rows in a block.
#[prost(bytes = "bytes", tag = "1")]
pub serialized_binary_rows: ::prost::bytes::Bytes,
/// The count of rows in the returning block.
#[prost(int64, tag = "2")]
pub row_count: i64,
}
/// Options dictating how we read a table.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TableReadOptions {
/// Optional. The names of the fields in the table to be returned. If no
/// field names are specified, then all fields in the table are returned.
///
/// Nested fields -- the child elements of a STRUCT field -- can be selected
/// individually using their fully-qualified names, and will be returned as
/// record fields containing only the selected nested fields. If a STRUCT
/// field is specified in the selected fields list, all of the child elements
/// will be returned.
///
/// As an example, consider a table with the following schema:
///
/// {
/// "name": "struct_field",
/// "type": "RECORD",
/// "mode": "NULLABLE",
/// "fields": [
/// {
/// "name": "string_field1",
/// "type": "STRING",
/// . "mode": "NULLABLE"
/// },
/// {
/// "name": "string_field2",
/// "type": "STRING",
/// "mode": "NULLABLE"
/// }
/// ]
/// }
///
/// Specifying "struct_field" in the selected fields list will result in a
/// read session schema with the following logical structure:
///
/// struct_field {
/// string_field1
/// string_field2
/// }
///
/// Specifying "struct_field.string_field1" in the selected fields list will
/// result in a read session schema with the following logical structure:
///
/// struct_field {
/// string_field1
/// }
///
/// The order of the fields in the read session schema is derived from the
/// table schema and does not correspond to the order in which the fields are
/// specified in this list.
#[prost(string, repeated, tag = "1")]
pub selected_fields: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Optional. SQL text filtering statement, similar to a WHERE clause in
/// a SQL query. Aggregates are not supported.
///
/// Examples: "int_field > 5"
/// "date_field = CAST('2014-9-27' as DATE)"
/// "nullable_field is not NULL"
/// "st_equals(geo_field, st_geofromtext("POINT(2, 2)"))"
/// "numeric_field BETWEEN 1.0 AND 5.0"
///
/// Restricted to a maximum length for 1 MB.
#[prost(string, tag = "2")]
pub row_restriction: ::prost::alloc::string::String,
}
/// Table reference that includes just the 3 strings needed to identify a table.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TableReference {
/// The assigned project ID of the project.
#[prost(string, tag = "1")]
pub project_id: ::prost::alloc::string::String,
/// The ID of the dataset in the above project.
#[prost(string, tag = "2")]
pub dataset_id: ::prost::alloc::string::String,
/// The ID of the table in the above dataset.
#[prost(string, tag = "3")]
pub table_id: ::prost::alloc::string::String,
}
/// All fields in this message optional.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct TableModifiers {
/// The snapshot time of the table. If not set, interpreted as now.
#[prost(message, optional, tag = "1")]
pub snapshot_time: ::core::option::Option<::prost_types::Timestamp>,
}
/// Information about a single data stream within a read session.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Stream {
/// Name of the stream, in the form
/// `projects/{project_id}/locations/{location}/streams/{stream_id}`.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
/// Expresses a point within a given stream using an offset position.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StreamPosition {
/// Identifier for a given Stream.
#[prost(message, optional, tag = "1")]
pub stream: ::core::option::Option<Stream>,
/// Position in the stream.
#[prost(int64, tag = "2")]
pub offset: i64,
}
/// Information returned from a `CreateReadSession` request.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadSession {
/// Unique identifier for the session, in the form
/// `projects/{project_id}/locations/{location}/sessions/{session_id}`.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// Time at which the session becomes invalid. After this time, subsequent
/// requests to read this Session will return errors.
#[prost(message, optional, tag = "2")]
pub expire_time: ::core::option::Option<::prost_types::Timestamp>,
/// Streams associated with this session.
#[prost(message, repeated, tag = "4")]
pub streams: ::prost::alloc::vec::Vec<Stream>,
/// Table that this ReadSession is reading from.
#[prost(message, optional, tag = "7")]
pub table_reference: ::core::option::Option<TableReference>,
/// Any modifiers which are applied when reading from the specified table.
#[prost(message, optional, tag = "8")]
pub table_modifiers: ::core::option::Option<TableModifiers>,
/// The strategy to use for distributing data among the streams.
#[prost(enumeration = "ShardingStrategy", tag = "9")]
pub sharding_strategy: i32,
/// The schema for the read. If read_options.selected_fields is set, the
/// schema may be different from the table schema as it will only contain
/// the selected fields.
#[prost(oneof = "read_session::Schema", tags = "5, 6")]
pub schema: ::core::option::Option<read_session::Schema>,
}
/// Nested message and enum types in `ReadSession`.
pub mod read_session {
/// The schema for the read. If read_options.selected_fields is set, the
/// schema may be different from the table schema as it will only contain
/// the selected fields.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Schema {
/// Avro schema.
#[prost(message, tag = "5")]
AvroSchema(super::AvroSchema),
/// Arrow schema.
#[prost(message, tag = "6")]
ArrowSchema(super::ArrowSchema),
}
}
/// Creates a new read session, which may include additional options such as
/// requested parallelism, projection filters and constraints.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateReadSessionRequest {
/// Required. Reference to the table to read.
#[prost(message, optional, tag = "1")]
pub table_reference: ::core::option::Option<TableReference>,
/// Required. String of the form `projects/{project_id}` indicating the
/// project this ReadSession is associated with. This is the project that will
/// be billed for usage.
#[prost(string, tag = "6")]
pub parent: ::prost::alloc::string::String,
/// Any modifiers to the Table (e.g. snapshot timestamp).
#[prost(message, optional, tag = "2")]
pub table_modifiers: ::core::option::Option<TableModifiers>,
/// Initial number of streams. If unset or 0, we will
/// provide a value of streams so as to produce reasonable throughput. Must be
/// non-negative. The number of streams may be lower than the requested number,
/// depending on the amount parallelism that is reasonable for the table and
/// the maximum amount of parallelism allowed by the system.
///
/// Streams must be read starting from offset 0.
#[prost(int32, tag = "3")]
pub requested_streams: i32,
/// Read options for this session (e.g. column selection, filters).
#[prost(message, optional, tag = "4")]
pub read_options: ::core::option::Option<TableReadOptions>,
/// Data output format. Currently default to Avro.
/// DATA_FORMAT_UNSPECIFIED not supported.
#[prost(enumeration = "DataFormat", tag = "5")]
pub format: i32,
/// The strategy to use for distributing data among multiple streams. Currently
/// defaults to liquid sharding.
#[prost(enumeration = "ShardingStrategy", tag = "7")]
pub sharding_strategy: i32,
}
/// Requesting row data via `ReadRows` must provide Stream position information.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadRowsRequest {
/// Required. Identifier of the position in the stream to start reading from.
/// The offset requested must be less than the last row read from ReadRows.
/// Requesting a larger offset is undefined.
#[prost(message, optional, tag = "1")]
pub read_position: ::core::option::Option<StreamPosition>,
}
/// Progress information for a given Stream.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct StreamStatus {
/// Number of estimated rows in the current stream. May change over time as
/// different readers in the stream progress at rates which are relatively fast
/// or slow.
#[prost(int64, tag = "1")]
pub estimated_row_count: i64,
/// A value in the range \[0.0, 1.0\] that represents the fraction of rows
/// assigned to this stream that have been processed by the server. In the
/// presence of read filters, the server may process more rows than it returns,
/// so this value reflects progress through the pre-filtering rows.
///
/// This value is only populated for sessions created through the BALANCED
/// sharding strategy.
#[prost(float, tag = "2")]
pub fraction_consumed: f32,
/// Represents the progress of the current stream.
#[prost(message, optional, tag = "4")]
pub progress: ::core::option::Option<Progress>,
/// Whether this stream can be split. For sessions that use the LIQUID sharding
/// strategy, this value is always false. For BALANCED sessions, this value is
/// false when enough data have been read such that no more splits are possible
/// at that point or beyond. For small tables or streams that are the result of
/// a chain of splits, this value may never be true.
#[prost(bool, tag = "3")]
pub is_splittable: bool,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Progress {
/// The fraction of rows assigned to the stream that have been processed by the
/// server so far, not including the rows in the current response message.
///
/// This value, along with `at_response_end`, can be used to interpolate the
/// progress made as the rows in the message are being processed using the
/// following formula: `at_response_start + (at_response_end -
/// at_response_start) * rows_processed_from_response / rows_in_response`.
///
/// Note that if a filter is provided, the `at_response_end` value of the
/// previous response may not necessarily be equal to the `at_response_start`
/// value of the current response.
#[prost(float, tag = "1")]
pub at_response_start: f32,
/// Similar to `at_response_start`, except that this value includes the rows in
/// the current response.
#[prost(float, tag = "2")]
pub at_response_end: f32,
}
/// Information on if the current connection is being throttled.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct ThrottleStatus {
/// How much this connection is being throttled.
/// 0 is no throttling, 100 is completely throttled.
#[prost(int32, tag = "1")]
pub throttle_percent: i32,
}
/// Response from calling `ReadRows` may include row data, progress and
/// throttling information.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadRowsResponse {
/// Number of serialized rows in the rows block. This value is recorded here,
/// in addition to the row_count values in the output-specific messages in
/// `rows`, so that code which needs to record progress through the stream can
/// do so in an output format-independent way.
#[prost(int64, tag = "6")]
pub row_count: i64,
/// Estimated stream statistics.
#[prost(message, optional, tag = "2")]
pub status: ::core::option::Option<StreamStatus>,
/// Throttling status. If unset, the latest response still describes
/// the current throttling status.
#[prost(message, optional, tag = "5")]
pub throttle_status: ::core::option::Option<ThrottleStatus>,
/// Row data is returned in format specified during session creation.
#[prost(oneof = "read_rows_response::Rows", tags = "3, 4")]
pub rows: ::core::option::Option<read_rows_response::Rows>,
/// The schema for the read. If read_options.selected_fields is set, the
/// schema may be different from the table schema as it will only contain
/// the selected fields. This schema is equivalent to the one returned by
/// CreateSession. This field is only populated in the first ReadRowsResponse
/// RPC.
#[prost(oneof = "read_rows_response::Schema", tags = "7, 8")]
pub schema: ::core::option::Option<read_rows_response::Schema>,
}
/// Nested message and enum types in `ReadRowsResponse`.
pub mod read_rows_response {
/// Row data is returned in format specified during session creation.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Rows {
/// Serialized row data in AVRO format.
#[prost(message, tag = "3")]
AvroRows(super::AvroRows),
/// Serialized row data in Arrow RecordBatch format.
#[prost(message, tag = "4")]
ArrowRecordBatch(super::ArrowRecordBatch),
}
/// The schema for the read. If read_options.selected_fields is set, the
/// schema may be different from the table schema as it will only contain
/// the selected fields. This schema is equivalent to the one returned by
/// CreateSession. This field is only populated in the first ReadRowsResponse
/// RPC.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Schema {
/// Output only. Avro schema.
#[prost(message, tag = "7")]
AvroSchema(super::AvroSchema),
/// Output only. Arrow schema.
#[prost(message, tag = "8")]
ArrowSchema(super::ArrowSchema),
}
}
/// Information needed to request additional streams for an established read
/// session.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchCreateReadSessionStreamsRequest {
/// Required. Must be a non-expired session obtained from a call to
/// CreateReadSession. Only the name field needs to be set.
#[prost(message, optional, tag = "1")]
pub session: ::core::option::Option<ReadSession>,
/// Required. Number of new streams requested. Must be positive.
/// Number of added streams may be less than this, see CreateReadSessionRequest
/// for more information.
#[prost(int32, tag = "2")]
pub requested_streams: i32,
}
/// The response from `BatchCreateReadSessionStreams` returns the stream
/// identifiers for the newly created streams.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchCreateReadSessionStreamsResponse {
/// Newly added streams.
#[prost(message, repeated, tag = "1")]
pub streams: ::prost::alloc::vec::Vec<Stream>,
}
/// Request information for invoking `FinalizeStream`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FinalizeStreamRequest {
/// Required. Stream to finalize.
#[prost(message, optional, tag = "2")]
pub stream: ::core::option::Option<Stream>,
}
/// Request information for `SplitReadStream`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SplitReadStreamRequest {
/// Required. Stream to split.
#[prost(message, optional, tag = "1")]
pub original_stream: ::core::option::Option<Stream>,
/// A value in the range (0.0, 1.0) that specifies the fractional point at
/// which the original stream should be split. The actual split point is
/// evaluated on pre-filtered rows, so if a filter is provided, then there is
/// no guarantee that the division of the rows between the new child streams
/// will be proportional to this fractional value. Additionally, because the
/// server-side unit for assigning data is collections of rows, this fraction
/// will always map to to a data storage boundary on the server side.
#[prost(float, tag = "2")]
pub fraction: f32,
}
/// Response from `SplitReadStream`.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SplitReadStreamResponse {
/// Primary stream, which contains the beginning portion of
/// |original_stream|. An empty value indicates that the original stream can no
/// longer be split.
#[prost(message, optional, tag = "1")]
pub primary_stream: ::core::option::Option<Stream>,
/// Remainder stream, which contains the tail of |original_stream|. An empty
/// value indicates that the original stream can no longer be split.
#[prost(message, optional, tag = "2")]
pub remainder_stream: ::core::option::Option<Stream>,
}
/// Data format for input or output data.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum DataFormat {
/// Data format is unspecified.
Unspecified = 0,
/// Avro is a standard open source row based file format.
/// See <https://avro.apache.org/> for more details.
Avro = 1,
/// Arrow is a standard open source column-based message format.
/// See <https://arrow.apache.org/> for more details.
Arrow = 3,
}
impl DataFormat {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
DataFormat::Unspecified => "DATA_FORMAT_UNSPECIFIED",
DataFormat::Avro => "AVRO",
DataFormat::Arrow => "ARROW",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"DATA_FORMAT_UNSPECIFIED" => Some(Self::Unspecified),
"AVRO" => Some(Self::Avro),
"ARROW" => Some(Self::Arrow),
_ => None,
}
}
}
/// Strategy for distributing data among multiple streams in a read session.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ShardingStrategy {
/// Same as LIQUID.
Unspecified = 0,
/// Assigns data to each stream based on the client's read rate. The faster the
/// client reads from a stream, the more data is assigned to the stream. In
/// this strategy, it's possible to read all data from a single stream even if
/// there are other streams present.
Liquid = 1,
/// Assigns data to each stream such that roughly the same number of rows can
/// be read from each stream. Because the server-side unit for assigning data
/// is collections of rows, the API does not guarantee that each stream will
/// return the same number or rows. Additionally, the limits are enforced based
/// on the number of pre-filtering rows, so some filters can lead to lopsided
/// assignments.
Balanced = 2,
}
impl ShardingStrategy {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
ShardingStrategy::Unspecified => "SHARDING_STRATEGY_UNSPECIFIED",
ShardingStrategy::Liquid => "LIQUID",
ShardingStrategy::Balanced => "BALANCED",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"SHARDING_STRATEGY_UNSPECIFIED" => Some(Self::Unspecified),
"LIQUID" => Some(Self::Liquid),
"BALANCED" => Some(Self::Balanced),
_ => None,
}
}
}
/// Generated client implementations.
pub mod big_query_storage_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// BigQuery storage API.
///
/// The BigQuery storage API can be used to read data stored in BigQuery.
///
/// The v1beta1 API is not yet officially deprecated, and will go through a full
/// deprecation cycle (https://cloud.google.com/products#product-launch-stages)
/// before the service is turned down. However, new code should use the v1 API
/// going forward.
#[derive(Debug, Clone)]
pub struct BigQueryStorageClient<T> {
inner: tonic::client::Grpc<T>,
}
impl<T> BigQueryStorageClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> BigQueryStorageClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
BigQueryStorageClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Creates a new read session. A read session divides the contents of a
/// BigQuery table into one or more streams, which can then be used to read
/// data from the table. The read session also specifies properties of the
/// data to be read, such as a list of columns or a push-down filter describing
/// the rows to be returned.
///
/// A particular row can be read by at most one stream. When the caller has
/// reached the end of each stream in the session, then all the data in the
/// table has been read.
///
/// Read sessions automatically expire 6 hours after they are created and do
/// not require manual clean-up by the caller.
pub async fn create_read_session(
&mut self,
request: impl tonic::IntoRequest<super::CreateReadSessionRequest>,
) -> std::result::Result<tonic::Response<super::ReadSession>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.cloud.bigquery.storage.v1beta1.BigQueryStorage/CreateReadSession",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.cloud.bigquery.storage.v1beta1.BigQueryStorage",
"CreateReadSession",
),
);
self.inner.unary(req, path, codec).await
}
/// Reads rows from the table in the format prescribed by the read session.
/// Each response contains one or more table rows, up to a maximum of 10 MiB
/// per response; read requests which attempt to read individual rows larger
/// than this will fail.
///
/// Each request also returns a set of stream statistics reflecting the
/// estimated total number of rows in the read stream. This number is computed
/// based on the total table size and the number of active streams in the read
/// session, and may change as other streams continue to read data.
pub async fn read_rows(
&mut self,
request: impl tonic::IntoRequest<super::ReadRowsRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::ReadRowsResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.cloud.bigquery.storage.v1beta1.BigQueryStorage/ReadRows",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.cloud.bigquery.storage.v1beta1.BigQueryStorage",
"ReadRows",
),
);
self.inner.server_streaming(req, path, codec).await
}
/// Creates additional streams for a ReadSession. This API can be used to
/// dynamically adjust the parallelism of a batch processing task upwards by
/// adding additional workers.
pub async fn batch_create_read_session_streams(
&mut self,
request: impl tonic::IntoRequest<super::BatchCreateReadSessionStreamsRequest>,
) -> std::result::Result<
tonic::Response<super::BatchCreateReadSessionStreamsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.cloud.bigquery.storage.v1beta1.BigQueryStorage/BatchCreateReadSessionStreams",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.cloud.bigquery.storage.v1beta1.BigQueryStorage",
"BatchCreateReadSessionStreams",
),
);
self.inner.unary(req, path, codec).await
}
/// Causes a single stream in a ReadSession to gracefully stop. This
/// API can be used to dynamically adjust the parallelism of a batch processing
/// task downwards without losing data.
///
/// This API does not delete the stream -- it remains visible in the
/// ReadSession, and any data processed by the stream is not released to other
/// streams. However, no additional data will be assigned to the stream once
/// this call completes. Callers must continue reading data on the stream until
/// the end of the stream is reached so that data which has already been
/// assigned to the stream will be processed.
///
/// This method will return an error if there are no other live streams
/// in the Session, or if SplitReadStream() has been called on the given
/// Stream.
pub async fn finalize_stream(
&mut self,
request: impl tonic::IntoRequest<super::FinalizeStreamRequest>,
) -> std::result::Result<tonic::Response<()>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.cloud.bigquery.storage.v1beta1.BigQueryStorage/FinalizeStream",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.cloud.bigquery.storage.v1beta1.BigQueryStorage",
"FinalizeStream",
),
);
self.inner.unary(req, path, codec).await
}
/// Splits a given read stream into two Streams. These streams are referred to
/// as the primary and the residual of the split. The original stream can still
/// be read from in the same manner as before. Both of the returned streams can
/// also be read from, and the total rows return by both child streams will be
/// the same as the rows read from the original stream.
///
/// Moreover, the two child streams will be allocated back to back in the
/// original Stream. Concretely, it is guaranteed that for streams Original,
/// Primary, and Residual, that Original[0-j] = Primary[0-j] and
/// Original[j-n] = Residual[0-m] once the streams have been read to
/// completion.
///
/// This method is guaranteed to be idempotent.
pub async fn split_read_stream(
&mut self,
request: impl tonic::IntoRequest<super::SplitReadStreamRequest>,
) -> std::result::Result<
tonic::Response<super::SplitReadStreamResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.cloud.bigquery.storage.v1beta1.BigQueryStorage/SplitReadStream",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"google.cloud.bigquery.storage.v1beta1.BigQueryStorage",
"SplitReadStream",
),
);
self.inner.unary(req, path, codec).await
}
}
}