1 | <?php |
||
26 | final class Space |
||
27 | { |
||
28 | public const VSPACE_ID = 281; |
||
29 | public const VINDEX_ID = 289; |
||
30 | |||
31 | private $handler; |
||
32 | private $id; |
||
33 | private $indexes = []; |
||
34 | |||
35 | 20 | public function __construct(Handler $handler, int $id) |
|
40 | |||
41 | public function getId() : int |
||
42 | { |
||
43 | return $this->id; |
||
44 | } |
||
45 | |||
46 | 20 | public function select(array $key = [], $index = 0, int $limit = \PHP_INT_MAX &0xffffffff, int $offset = 0, int $iteratorType = IteratorTypes::EQ) : array |
|
47 | { |
||
48 | 20 | if (\is_string($index)) { |
|
49 | $index = $this->getIndexIdByName($index); |
||
50 | } |
||
51 | |||
52 | 20 | $request = new Select($this->id, $index, $key, $offset, $limit, $iteratorType); |
|
53 | |||
54 | 20 | return $this->handler->handle($request)->getBodyField(IProto::DATA); |
|
55 | } |
||
56 | |||
57 | 2 | public function insert(array $values) : array |
|
63 | |||
64 | public function replace(array $values) : array |
||
65 | { |
||
66 | $request = new Replace($this->id, $values); |
||
67 | |||
68 | return $this->handler->handle($request)->getBodyField(IProto::DATA); |
||
69 | } |
||
70 | |||
71 | 2 | public function update(array $key, array $operations, $index = 0) : array |
|
81 | |||
82 | public function upsert(array $values, array $operations) : array |
||
83 | { |
||
84 | $request = new Upsert($this->id, $values, $operations); |
||
85 | |||
86 | return $this->handler->handle($request)->getBodyField(IProto::DATA); |
||
87 | } |
||
88 | |||
89 | 8 | public function delete(array $key, $index = 0) : array |
|
99 | |||
100 | public function flushIndexes() : void |
||
101 | { |
||
102 | $this->indexes = []; |
||
103 | } |
||
104 | |||
105 | 2 | private function getIndexIdByName(string $indexName) : int |
|
120 | } |
||
121 |