Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
| IndexNamespace | |
100.00% |
7 / 7 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| upsert | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| query | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| fetch | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| delete | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| update | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Mbvb1223\Pinecone\Data; |
| 6 | |
| 7 | class IndexNamespace |
| 8 | { |
| 9 | private DataPlane $dataPlane; |
| 10 | private string $namespace; |
| 11 | |
| 12 | public function __construct(DataPlane $dataPlane, string $namespace) |
| 13 | { |
| 14 | $this->dataPlane = $dataPlane; |
| 15 | $this->namespace = $namespace; |
| 16 | } |
| 17 | |
| 18 | public function upsert(array $vectors): array |
| 19 | { |
| 20 | return $this->dataPlane->upsert($vectors, $this->namespace); |
| 21 | } |
| 22 | |
| 23 | public function query( |
| 24 | array $vector = [], |
| 25 | ?string $id = null, |
| 26 | int $topK = 10, |
| 27 | ?array $filter = null, |
| 28 | bool $includeValues = false, |
| 29 | bool $includeMetadata = true |
| 30 | ): array { |
| 31 | return $this->dataPlane->query($vector, $id, $topK, $filter, $this->namespace, $includeValues, $includeMetadata); |
| 32 | } |
| 33 | |
| 34 | public function fetch(array $ids): array |
| 35 | { |
| 36 | return $this->dataPlane->fetch($ids, $this->namespace); |
| 37 | } |
| 38 | |
| 39 | public function delete(array $ids = [], ?array $filter = null, bool $deleteAll = false): array |
| 40 | { |
| 41 | return $this->dataPlane->delete($ids, $filter, $this->namespace, $deleteAll); |
| 42 | } |
| 43 | |
| 44 | public function update(string $id, array $values = [], ?array $setMetadata = null): array |
| 45 | { |
| 46 | return $this->dataPlane->update($id, $values, $setMetadata, $this->namespace); |
| 47 | } |
| 48 | } |