|
19 | 19 | // Includes the autoloader for libraries installed with composer |
20 | 20 | require __DIR__ . '/vendor/autoload.php'; |
21 | 21 |
|
22 | | -use Google\Cloud\BigQuery\Storage\V1\BigQueryReadClient; |
| 22 | +use Google\Cloud\BigQuery\Storage\V1\Client\BigQueryReadClient; |
| 23 | +use Google\Cloud\BigQuery\Storage\V1\CreateReadSessionRequest; |
23 | 24 | use Google\Cloud\BigQuery\Storage\V1\DataFormat; |
| 25 | +use Google\Cloud\BigQuery\Storage\V1\ReadRowsRequest; |
24 | 26 | use Google\Cloud\BigQuery\Storage\V1\ReadSession; |
25 | 27 | use Google\Cloud\BigQuery\Storage\V1\ReadSession\TableModifiers; |
26 | 28 | use Google\Cloud\BigQuery\Storage\V1\ReadSession\TableReadOptions; |
|
62 | 64 | } |
63 | 65 |
|
64 | 66 | try { |
65 | | - $session = $client->createReadSession( |
66 | | - $project, |
67 | | - $readSession, |
68 | | - [ |
69 | | - // We'll use only a single stream for reading data from the table. |
70 | | - // However, if you wanted to fan out multiple readers you could do so |
71 | | - // by having a reader process each individual stream. |
72 | | - 'maxStreamCount' => 1 |
73 | | - ] |
74 | | - ); |
75 | | - $stream = $client->readRows($session->getStreams()[0]->getName()); |
| 67 | + $createReadSessionRequest = (new CreateReadSessionRequest()) |
| 68 | + ->setParent($project) |
| 69 | + ->setReadSession($readSession) |
| 70 | + ->setMaxStreamCount(1); |
| 71 | + $session = $client->createReadSession($createReadSessionRequest); |
| 72 | + $readRowsRequest = (new ReadRowsRequest()) |
| 73 | + ->setReadStream($session->getStreams()[0]->getName()); |
| 74 | + $stream = $client->readRows($readRowsRequest); |
76 | 75 | // Do any local processing by iterating over the responses. The |
77 | 76 | // google-cloud-bigquery-storage client reconnects to the API after any |
78 | 77 | // transient network errors or timeouts. |
|
0 commit comments