예제 #1
0
 public function testIndexInputWithFilters()
 {
     $filters = KeyFilters::filter()->endsWith('Silva');
     $namespace = new RiakNamespace('bucket_type', 'bucket_name');
     $input = new BucketInput($namespace, $filters);
     $this->assertSame($namespace, $input->getNamespace());
     $this->assertSame($filters, $input->getFilters());
     $this->assertEquals('{"bucket":["bucket_type","bucket_name"],"key_filters":[["ends_with","Silva"]]}', json_encode($input));
 }
예제 #2
0
 public function testBuildCommand()
 {
     $filters = KeyFilters::filter()->startsWith('2005');
     $builder = BucketMapReduce::builder($this->namespace, KeyFilters::filter())->withNamespace($this->namespace)->withKeyFilter($filters)->withLinkPhase('bucket-name', 'link')->withMapPhase(new ErlangFunction('module', 'map_func1'))->withReducePhase(new ErlangFunction('module', 'red_func1'));
     $command = $builder->build();
     $spec = $command->getSpecification();
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\Specification', $spec);
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\BucketMapReduce', $command);
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\Input\\BucketInput', $spec->getInput());
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\KeyFilters', $spec->getInput()->getFilters());
     $this->assertSame($this->namespace, $spec->getInput()->getNamespace());
     $this->assertSame($filters, $spec->getInput()->getFilters());
     $this->assertCount(3, $spec->getPhases());
 }
예제 #3
0
 public function testIndexMapReduceMatch()
 {
     $map = $this->createMapFunction();
     $filter = KeyFilters::filter()->between('10', '19', false);
     $reduce = new ErlangFunction('riak_kv_mapreduce', 'reduce_sum');
     $command = BucketMapReduce::builder()->withMapPhase($map, null, false)->withReducePhase($reduce, null, true)->withNamespace($this->namespace)->withKeyFilter($filter)->build();
     $result = $this->client->execute($command);
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\Response\\BucketMapReduceResponse', $result);
     $iterator = $result->getIterator();
     $values = iterator_to_array($iterator);
     $this->assertCount(1, $values);
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\Response\\MapReduceEntry', $values[0]);
     $this->assertEquals([116], $values[0]->getResponse());
     $this->assertEquals(1, $values[0]->getPhase());
 }
예제 #4
0
 public function testJsonEncodeNotMatch()
 {
     $filter = KeyFilters::filter()->not(KeyFilters::filter()->matches('solution'));
     $this->assertEquals('[["not",[["matches","solution"]]]]', json_encode($filter));
 }