Skip to content

Commit 9195c5a

Browse files
committed
updated the test with identifiers parameter
1 parent 5bf14cb commit 9195c5a

File tree

3 files changed

+62
-26
lines changed

3 files changed

+62
-26
lines changed

src/Neo4jQueryAPI.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private function createProfileData(array $data): ProfiledQueryPlan
164164
rows: $mappedArguments['Rows' ?? null]
165165
);
166166

167-
167+
$identifiers = $data['identifiers'] ?? [];
168168
$profiledQueryPlan = new ProfiledQueryPlan(
169169
$data['dbHits'],
170170
$data['records'],
@@ -174,9 +174,11 @@ private function createProfileData(array $data): ProfiledQueryPlan
174174
$data['pageCacheHitRatio'],
175175
$data['time'],
176176
$data['operatorType'],
177-
$queryArguments
178-
);
177+
$queryArguments,
178+
children: [],
179+
identifiers: $identifiers
179180

181+
);
180182
// Process children recursively
181183
foreach ($data['children'] as $child) {
182184
$childQueryPlan = $this->createProfileData($child);

src/Objects/ProfiledQueryPlan.php

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Neo4j\QueryAPI\Objects;
44

5-
class ProfiledQueryPlan extends \Neo4j\QueryAPI\Objects\Bookmarks
5+
class ProfiledQueryPlan
66
{
77
private int $dbHits;
88
private int $records;
@@ -19,17 +19,23 @@ class ProfiledQueryPlan extends \Neo4j\QueryAPI\Objects\Bookmarks
1919
*/
2020
private array $children;
2121

22+
/**
23+
* @var string[]
24+
*/
25+
private array $identifiers;
26+
2227
public function __construct(
23-
?int $dbHits = 0, // Default to 0 if null
24-
?int $records = 0,
25-
?bool $hasPageCacheStats = false,
26-
?int $pageCacheHits = 0,
27-
?int $pageCacheMisses = 0,
28-
?float $pageCacheHitRatio = 0.0,
29-
?int $time = 0,
30-
?string $operatorType = '',
31-
ProfiledQueryPlanArguments $arguments,
32-
array $children = [] // Accept an array of children, default to empty array
28+
?int $dbHits ,
29+
?int $records ,
30+
?bool $hasPageCacheStats ,
31+
?int $pageCacheHits ,
32+
?int $pageCacheMisses ,
33+
?float $pageCacheHitRatio ,
34+
?int $time ,
35+
?string $operatorType,
36+
ProfiledQueryPlanArguments $arguments ,
37+
?array $children=[],
38+
array $identifiers=[] // Default to an empty array
3339
) {
3440
$this->dbHits = $dbHits ?? 0;
3541
$this->records = $records ?? 0;
@@ -41,6 +47,7 @@ public function __construct(
4147
$this->operatorType = $operatorType ?? '';
4248
$this->arguments = $arguments;
4349
$this->children = $children ?? [];
50+
$this->identifiers = $identifiers;
4451
}
4552

4653
public function getDbHits(): int
@@ -100,4 +107,25 @@ public function addChild(ProfiledQueryPlan|ProfiledQueryPlanArguments $child): v
100107
{
101108
$this->children[] = $child;
102109
}
110+
111+
/**
112+
* @return string[]
113+
*/
114+
public function getIdentifiers(): array
115+
{
116+
return $this->identifiers;
117+
}
118+
119+
/**
120+
* @param string[] $identifiers
121+
*/
122+
public function setIdentifiers(array $identifiers): void
123+
{
124+
$this->identifiers = $identifiers;
125+
}
126+
127+
public function addIdentifier(string $identifier): void
128+
{
129+
$this->identifiers[] = $identifier;
130+
}
103131
}

tests/resources/expected/complex-query-profile.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,10 @@
242242
id: 11,
243243
estimatedRows: 10.0,
244244
rows: 100
245-
)
245+
),identifiers: ["i"]
246246
)
247-
]
247+
],identifiers: ["i","j"]
248+
248249
),
249250
// CHILD #1.1.1.1.2: CartesianProduct@neo4j (id=5)
250251
new ProfiledQueryPlan(
@@ -337,9 +338,12 @@
337338
id: 9,
338339
estimatedRows: 1000.0,
339340
rows: 20000,
340-
)
341+
),identifiers: ["i","j","a"]
342+
343+
341344
)
342-
]
345+
],identifiers: ["i","j","a"]
346+
343347
),
344348
// CHILD #1.1.1.1.2.2: Filter@neo4j (id=6)
345349
new ProfiledQueryPlan(
@@ -401,20 +405,22 @@
401405
id: 7,
402406
estimatedRows: 1000.0,
403407
rows: 0
404-
)
408+
),identifiers: ["i","j","b"]
405409
)
406-
]
410+
],identifiers: ["i","j","b"]
407411
)
408-
]
412+
],identifiers: ["i","j","a","b"]
409413
)
410-
]
414+
],identifiers: ["i","j","a","b"]
411415
)
412-
]
416+
],
417+
418+
identifiers: ["i","j","a","b"]
413419
)
414-
]
420+
],identifiers: ["j","a","i","b","anon_0","anon_1"]
415421
)
416-
]
422+
],identifiers: ["j","a","i","b","anon_0","anon_1"]
417423
)
418-
]
424+
],identifiers: ["j","a","i","b","anon_0","anon_1"]
419425
)
420426
);

0 commit comments

Comments
 (0)