Skip to content

Commit adf3167

Browse files
author
Илья
committed
Remove Protobuf dependency
1 parent ae60dd1 commit adf3167

File tree

8 files changed

+388
-82
lines changed

8 files changed

+388
-82
lines changed

src/QueryResult.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace YdbPlatform\Ydb;
44

55
use DateTime;
6+
use YdbPlatform\Ydb\QueryStats\QueryStats;
67

78
class QueryResult
89
{

src/QueryStats.php

Lines changed: 0 additions & 82 deletions
This file was deleted.

src/QueryStats/CompilationStats.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace YdbPlatform\Ydb\QueryStats;
4+
5+
class CompilationStats
6+
{
7+
/**
8+
* @var \Ydb\TableStats\CompilationStats
9+
*/
10+
protected $compilationStats;
11+
12+
public function __construct(\Ydb\TableStats\CompilationStats $compilationStats)
13+
{
14+
$this->compilationStats = $compilationStats;
15+
}
16+
17+
/**
18+
* @return bool
19+
*/
20+
public function getFromCache(): bool
21+
{
22+
return $this->compilationStats->getFromCache();
23+
}
24+
25+
/**
26+
* @return int|string
27+
*/
28+
public function getDurationUs()
29+
{
30+
return $this->compilationStats->getDurationUs();
31+
}
32+
33+
/**
34+
* @return int|string
35+
*/
36+
public function getCpuTimeUs()
37+
{
38+
return $this->compilationStats->getCpuTimeUs();
39+
}
40+
}

src/QueryStats/OperationStats.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace YdbPlatform\Ydb\QueryStats;
4+
5+
class OperationStats
6+
{
7+
8+
public function __construct(\Ydb\TableStats\OperationStats $operationStats)
9+
{
10+
$this->operationStats = $operationStats;
11+
}
12+
13+
/**
14+
* @return int|string
15+
*/
16+
public function getRows()
17+
{
18+
return $this->operationStats->getRows();
19+
}
20+
21+
/**
22+
* @return int|string
23+
*/
24+
public function getBytes()
25+
{
26+
return $this->operationStats->getBytes();
27+
}
28+
}

src/QueryStats/QueryPhaseStats.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespace YdbPlatform\Ydb\QueryStats;
4+
5+
class QueryPhaseStats
6+
{
7+
/**
8+
* @var \Ydb\TableStats\QueryPhaseStats
9+
*/
10+
protected $phaseStats;
11+
12+
public function __construct(\Ydb\TableStats\QueryPhaseStats $phaseStats)
13+
{
14+
$this->phaseStats = $phaseStats;
15+
}
16+
17+
18+
/**
19+
* @return int|string
20+
*/
21+
public function getDurationUs()
22+
{
23+
return $this->phaseStats->getDurationUs();
24+
}
25+
26+
/**
27+
* @return TableAccessStats[]
28+
*/
29+
public function getTableAccess()
30+
{
31+
$result = iterator_to_array($this->phaseStats->getTableAccess());
32+
foreach ($result as $key=>$item) {
33+
$result[$key] = new TableAccessStats($item);
34+
}
35+
return $result;
36+
}
37+
38+
/**
39+
* @return int|string
40+
*/
41+
public function getCpuTimeUs()
42+
{
43+
return $this->phaseStats->getCpuTimeUs();
44+
}
45+
46+
/**
47+
* @return int|string
48+
*/
49+
public function getAffectedShards()
50+
{
51+
return $this->phaseStats->getAffectedShards();
52+
}
53+
54+
/**
55+
* @return bool
56+
*/
57+
public function getLiteralPhase()
58+
{
59+
return $this->phaseStats->getLiteralPhase();
60+
}
61+
}

src/QueryStats/QueryStats.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
namespace YdbPlatform\Ydb\QueryStats;
4+
5+
class QueryStats
6+
{
7+
8+
protected $queryStats;
9+
public function __construct(\Ydb\TableStats\QueryStats $queryStats)
10+
{
11+
$this->queryStats = $queryStats;
12+
}
13+
14+
/**
15+
* @return QueryPhaseStats[]
16+
*/
17+
public function getQueryPhases()
18+
{
19+
$result = iterator_to_array($this->queryStats->getQueryPhases()->getIterator());
20+
foreach ($result as $key=>$item) {
21+
$result[$key] = new QueryPhaseStats($item);
22+
}
23+
return $result;
24+
}
25+
26+
/**
27+
* @return CompilationStats|null
28+
*/
29+
public function getCompilation(): ?CompilationStats
30+
{
31+
if($this->queryStats->getQueryPhases()){
32+
return new CompilationStats($this->queryStats->getCompilation());
33+
} else {
34+
return null;
35+
}
36+
}
37+
38+
/**
39+
* @return int|string
40+
*/
41+
public function getProcessCpuTimeUs()
42+
{
43+
return $this->queryStats->getProcessCpuTimeUs();
44+
}
45+
46+
/**
47+
* @return string
48+
*/
49+
public function getQueryPlan(): string
50+
{
51+
return $this->queryStats->getQueryPlan();
52+
}
53+
54+
/**
55+
* @return string
56+
*/
57+
public function getQueryAst(): string
58+
{
59+
return $this->queryStats->getQueryAst();
60+
}
61+
62+
/**
63+
* @return int|string
64+
*/
65+
public function getTotalDurationUs()
66+
{
67+
return $this->queryStats->getTotalDurationUs();
68+
}
69+
70+
/**
71+
* @return int|string
72+
*/
73+
public function getTotalCpuTimeUs()
74+
{
75+
return $this->queryStats->getTotalCpuTimeUs();
76+
}
77+
78+
}

src/QueryStats/TableAccessStats.php

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
namespace YdbPlatform\Ydb\QueryStats;
3+
class TableAccessStats
4+
{
5+
6+
/**
7+
* @var \Ydb\TableStats\TableAccessStats
8+
*/
9+
protected $accessStats;
10+
11+
public function __construct(\Ydb\TableStats\TableAccessStats $accessStats)
12+
{
13+
$this->accessStats = $accessStats;
14+
}
15+
16+
/**
17+
* @return string
18+
*/
19+
public function getName()
20+
{
21+
return $this->accessStats->getName();
22+
}
23+
24+
/**
25+
* @return OperationStats|null
26+
*/
27+
public function getReads()
28+
{
29+
$result = $this->accessStats->getReads();
30+
if ($result){
31+
$result = new OperationStats($result);
32+
}
33+
return $result;
34+
}
35+
36+
public function hasReads()
37+
{
38+
return $this->accessStats->hasReads();
39+
}
40+
41+
public function clearReads()
42+
{
43+
$this->accessStats->clearReads();
44+
}
45+
46+
/**
47+
* @return OperationStats|null
48+
*/
49+
public function getUpdates()
50+
{
51+
$result = $this->accessStats->getUpdates();
52+
if ($result){
53+
$result = new OperationStats($result);
54+
}
55+
return $result;
56+
}
57+
58+
public function hasUpdates()
59+
{
60+
return $this->accessStats->hasUpdates();
61+
}
62+
63+
public function clearUpdates()
64+
{
65+
$this->accessStats->clearUpdates();
66+
}
67+
68+
69+
/**
70+
* @return \Ydb\TableStats\OperationStats|null
71+
*/
72+
public function getDeletes()
73+
{
74+
return $this->accessStats->getDeletes();
75+
}
76+
77+
public function hasDeletes()
78+
{
79+
return $this->accessStats->hasDeletes();
80+
}
81+
82+
public function clearDeletes()
83+
{
84+
$this->accessStats->clearDeletes();
85+
}
86+
87+
/**
88+
* @return int|string
89+
*/
90+
public function getPartitionsCount()
91+
{
92+
return $this->accessStats->getPartitionsCount();
93+
}
94+
}
95+

0 commit comments

Comments
 (0)