Пример #1
0
 public static function fromBsonP3($bson)
 {
     $result = new VTSplitQueryPart();
     if (array_key_exists('Query', $bson)) {
         $result->query = VTBoundQuery::fromBsonP3($bson['Query']);
     }
     if (array_key_exists('KeyRangePart', $bson) && $bson['KeyRangePart']) {
         $result->keyRangePart = VTSplitQueryKeyRangePart::fromBsonP3($bson['KeyRangePart']);
     }
     if (array_key_exists('ShardPart', $bson) && $bson['ShardPart']) {
         $result->shardPart = VTSplitQueryShardPart::fromBsonP3($bson['ShardPart']);
     }
     if (array_key_exists('Size', $bson)) {
         $result->size = $bson['Size'];
     }
     return $result;
 }
Пример #2
0
 public function splitQuery(VTContext $ctx, $keyspace, $query, array $bind_vars, $split_column, $split_count)
 {
     $req = array('Keyspace' => $keyspace, 'Query' => VTBoundQuery::buildBsonP3($query, $bind_vars), 'SplitColumn' => $split_column, 'SplitCount' => $split_count);
     if ($ctx->getCallerId()) {
         $req['CallerId'] = $ctx->getCallerId()->toBsonP3();
     }
     $resp = $this->client->call($ctx, 'VTGateP3.SplitQuery', $req)->reply;
     $results = array();
     if (array_key_exists('Splits', $resp)) {
         foreach ($resp['Splits'] as $split) {
             $results[] = VTSplitQueryPart::fromBsonP3($split);
         }
     }
     return $results;
 }
Пример #3
0
 public function testBoundQuery()
 {
     $expected = array('Sql' => 'test query', 'BindVariables' => array('bytes' => array('Type' => VTBindVariable::TYPE_BYTES, 'ValueBytes' => new MongoBinData('hello')), 'int' => array('Type' => VTBindVariable::TYPE_INT, 'ValueInt' => 123), 'uint_from_int' => array('Type' => VTBindVariable::TYPE_UINT, 'ValueUint' => 345), 'uint_from_string' => array('Type' => VTBindVariable::TYPE_UINT, 'ValueUint' => new MongoInt64('678')), 'float' => array('Type' => VTBindVariable::TYPE_FLOAT, 'ValueFloat' => 1.5)));
     $actual = VTBoundQuery::buildBsonP3('test query', array('bytes' => 'hello', 'int' => 123, 'uint_from_int' => new VTUnsignedInt(345), 'uint_from_string' => new VTUnsignedInt('678'), 'float' => 1.5));
     $this->assertEquals($expected, $actual);
 }
Пример #4
0
 public function toBsonP3()
 {
     return array('Query' => VTBoundQuery::buildBsonP3($this->query, $this->vars), 'Keyspace' => $this->keyspace, 'KeyspaceIds' => VTKeyspaceId::buildBsonP3Array($this->keyspaceIds));
 }
Пример #5
0
 private function callExecute(VTContext $ctx, $query, array $bind_vars, $tablet_type, $method, $req = array())
 {
     $req['Query'] = VTBoundQuery::buildBsonP3($query, $bind_vars);
     $req['TabletType'] = $tablet_type;
     if ($ctx->getCallerId()) {
         $req['CallerId'] = $ctx->getCallerId()->toBsonP3();
     }
     $resp = $this->client->call($ctx, $method, $req)->reply;
     VTProto::checkError($resp);
     return new VTQueryResult($resp['Result']);
 }