Esempio n. 1
0
 /**
  * fetch reads and returns the next VTQueryResult from the stream.
  *
  * If there are no more results and the stream has finished successfully,
  * it returns FALSE.
  */
 public function fetch()
 {
     $resp = $this->client->streamNext($this->ctx);
     if ($resp === FALSE) {
         return FALSE;
     }
     VTProto::checkError($resp->reply);
     return VTQueryResult::fromBsonP3($resp->reply['Result']);
 }
Esempio n. 2
0
 public function executeBatchKeyspaceIds(VTContext $ctx, array $bound_keyspace_id_queries, $tablet_type, $as_transaction)
 {
     $request = new \vtgate\ExecuteBatchKeyspaceIdsRequest();
     VTProto::addQueries($request, $bound_keyspace_id_queries);
     $request->setTabletType($tablet_type);
     $request->setAsTransaction($as_transaction);
     if ($ctx->getCallerId()) {
         $request->setCallerId($ctx->getCallerId());
     }
     $response = $this->client->executeBatchKeyspaceIds($ctx, $request);
     VTProto::checkError($response);
     $results = array();
     foreach ($response->getResultsList() as $result) {
         $results[] = new VTCursor($result);
     }
     return $results;
 }
Esempio n. 3
0
 public function executeBatchKeyspaceIds(VTContext $ctx, array $bound_keyspace_id_queries, $tablet_type = \topodata\TabletType::MASTER, $as_transaction = TRUE)
 {
     if (!$this->inTransaction()) {
         throw new VTException('execute called while not in transaction.');
     }
     $request = new \vtgate\ExecuteBatchKeyspaceIdsRequest();
     $request->setSession($this->session);
     VTProto::addQueries($request, $bound_keyspace_id_queries);
     $request->setTabletType($tablet_type);
     $request->setAsTransaction($as_transaction);
     if ($ctx->getCallerId()) {
         $request->setCallerId($ctx->getCallerId());
     }
     $response = $this->client->executeBatchKeyspaceIds($ctx, $request);
     $this->session = $response->getSession();
     VTProto::checkError($response);
     $results = array();
     foreach ($response->getResultsList() as $result) {
         $results[] = new VTCursor($result);
     }
     return $results;
 }
Esempio n. 4
0
 private function callExecuteBatch(VTContext $ctx, $queries, $tablet_type, $as_transaction, $method, $req = array())
 {
     $req['Queries'] = $queries;
     $req['TabletType'] = $tablet_type;
     $req['AsTransaction'] = $as_transaction;
     if ($ctx->getCallerId()) {
         $req['CallerId'] = $ctx->getCallerId()->toBsonP3();
     }
     $resp = $this->client->call($ctx, $method, $req)->reply;
     VTProto::checkError($resp);
     $results = array();
     foreach ($resp['Results'] as $result) {
         $results[] = new VTQueryResult($result);
     }
     return $results;
 }