Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
| IndexNamespace | |
100.00% |
8 / 8 |
|
100.00% |
7 / 7 |
7 | |
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 | |||
| listVectorIds | |
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 | /** |
| 19 | * @param array<int, array{id: string, values: array<float>, sparseValues?: array{indices: array<int>, values: array<float>}, metadata?: array<string, mixed>}> $vectors |
| 20 | * @return array<string, mixed> |
| 21 | */ |
| 22 | public function upsert(array $vectors): array |
| 23 | { |
| 24 | return $this->dataPlane->upsert($vectors, $this->namespace); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * @param array<float> $vector |
| 29 | * @param array<string, mixed>|null $filter Metadata filter expression |
| 30 | * @param array{indices: array<int>, values: array<float>}|null $sparseVector |
| 31 | * @return array<string, mixed> |
| 32 | */ |
| 33 | public function query( |
| 34 | array $vector = [], |
| 35 | ?string $id = null, |
| 36 | int $topK = 10, |
| 37 | ?array $filter = null, |
| 38 | bool $includeValues = false, |
| 39 | bool $includeMetadata = true, |
| 40 | ?array $sparseVector = null, |
| 41 | ): array { |
| 42 | return $this->dataPlane->query($vector, $id, $topK, $filter, $this->namespace, $includeValues, $includeMetadata, $sparseVector); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * @param array<int, string> $ids |
| 47 | * @return array<string, array<string, mixed>> |
| 48 | */ |
| 49 | public function fetch(array $ids): array |
| 50 | { |
| 51 | return $this->dataPlane->fetch($ids, $this->namespace); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * @param array<int, string> $ids |
| 56 | * @param array<string, mixed>|null $filter Metadata filter expression |
| 57 | * @return array<string, mixed> |
| 58 | */ |
| 59 | public function delete(array $ids = [], ?array $filter = null, bool $deleteAll = false): array |
| 60 | { |
| 61 | return $this->dataPlane->delete($ids, $filter, $this->namespace, $deleteAll); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * @param array<float> $values |
| 66 | * @param array<string, mixed>|null $setMetadata |
| 67 | * @param array{indices: array<int>, values: array<float>}|null $sparseValues |
| 68 | * @return array<string, mixed> |
| 69 | */ |
| 70 | public function update(string $id, array $values = [], ?array $setMetadata = null, ?array $sparseValues = null): array |
| 71 | { |
| 72 | return $this->dataPlane->update($id, $values, $setMetadata, $this->namespace, $sparseValues); |
| 73 | } |
| 74 | |
| 75 | /** @return array<string, mixed> */ |
| 76 | public function listVectorIds(?string $prefix = null, ?int $limit = null, ?string $paginationToken = null): array |
| 77 | { |
| 78 | return $this->dataPlane->listVectorIds($prefix, $limit, $paginationToken, $this->namespace); |
| 79 | } |
| 80 | } |