Skip to content

Commit 70f0a5a

Browse files
authored
Merge pull request #49 from hkulekci/value-could-be-zero
OptimizersConfig parameter values could be zero
2 parents f458617 + ea162fc commit 70f0a5a

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

src/Models/Request/CollectionConfig/OptimizersConfig.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,28 +110,28 @@ public function setMaxOptimizationThreads(?int $maxOptimizationThreads): Optimiz
110110
public function toArray(): array
111111
{
112112
$data = [];
113-
if ($this->deletedThreshold) {
113+
if ($this->deletedThreshold !== null) {
114114
$data['deleted_threshold'] = $this->deletedThreshold;
115115
}
116-
if ($this->vacuumMinVectorNumber) {
116+
if ($this->vacuumMinVectorNumber !== null) {
117117
$data['vacuum_min_vector_number'] = $this->vacuumMinVectorNumber;
118118
}
119-
if ($this->defaultSegmentNumber) {
119+
if ($this->defaultSegmentNumber !== null) {
120120
$data['default_segment_number'] = $this->defaultSegmentNumber;
121121
}
122-
if ($this->maxSegmentSize) {
122+
if ($this->maxSegmentSize !== null) {
123123
$data['max_segment_size'] = $this->maxSegmentSize;
124124
}
125-
if ($this->memmapThreshold) {
125+
if ($this->memmapThreshold !== null) {
126126
$data['memmap_threshold'] = $this->memmapThreshold;
127127
}
128-
if ($this->indexingThreshold) {
128+
if ($this->indexingThreshold !== null) {
129129
$data['indexing_threshold'] = $this->indexingThreshold;
130130
}
131-
if ($this->flushIntervalSec) {
131+
if ($this->flushIntervalSec !== null) {
132132
$data['flush_interval_sec'] = $this->flushIntervalSec;
133133
}
134-
if ($this->maxOptimizationThreads) {
134+
if ($this->maxOptimizationThreads !== null) {
135135
$data['max_optimization_threads'] = $this->maxOptimizationThreads;
136136
}
137137

tests/Unit/Models/Request/CollectionConfig/OptimizerConfigTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,30 @@ public function testBasic(): void
1818
$this->assertEquals([], $config->toArray());
1919
}
2020

21+
public function testWithValueZero(): void
22+
{
23+
$config = (new OptimizersConfig())
24+
->setDeletedThreshold(0)
25+
->setVacuumMinVectorNumber(0)
26+
->setDefaultSegmentNumber(0)
27+
->setMaxSegmentSize(0)
28+
->setMemmapThreshold(0)
29+
->setIndexingThreshold(0)
30+
->setFlushIntervalSec(0)
31+
->setMaxOptimizationThreads(0);
32+
33+
$this->assertEquals([
34+
'deleted_threshold' => 0.0,
35+
'vacuum_min_vector_number' => 0,
36+
'default_segment_number' => 0,
37+
'max_segment_size' => 0,
38+
'memmap_threshold' => 0,
39+
'indexing_threshold' => 0,
40+
'flush_interval_sec' => 0,
41+
'max_optimization_threads' => 0,
42+
], $config->toArray());
43+
}
44+
2145
public function testWithIndexingThreshold(): void
2246
{
2347
$config = (new OptimizersConfig())->setIndexingThreshold(10);

0 commit comments

Comments
 (0)