Skip to content

Commit b7b7165

Browse files
authored
Reduce number of References initializations that affects processing performance (#369)
* Reduce number of References initializations that affects processing performance * Static analysis fixes
1 parent bc5c3d1 commit b7b7165

File tree

12 files changed

+138
-137
lines changed

12 files changed

+138
-137
lines changed

src/core/etl/src/Flow/ETL/Join/Comparison/Equal.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,14 @@
99
use Flow\ETL\Row\EntryReference;
1010

1111
/**
12-
* @implements Comparison<array{entry_left: EntryReference, entry_right: EntryReference}>
12+
* @implements Comparison<array{entry_left: string|EntryReference, entry_right: string|EntryReference}>
1313
*/
1414
final class Equal implements Comparison
1515
{
16-
private readonly EntryReference $entryLeft;
17-
18-
private readonly EntryReference $entryRight;
19-
2016
public function __construct(
21-
string|EntryReference $entryLeft,
22-
string|EntryReference $entryRight
17+
private readonly string|EntryReference $entryLeft,
18+
private readonly string|EntryReference $entryRight
2319
) {
24-
$this->entryLeft = EntryReference::init($entryLeft);
25-
$this->entryRight = EntryReference::init($entryRight);
2620
}
2721

2822
public function __serialize() : array
@@ -49,14 +43,14 @@ public function compare(Row $left, Row $right) : bool
4943
*/
5044
public function left() : array
5145
{
52-
return [$this->entryLeft];
46+
return [\is_string($this->entryLeft) ? EntryReference::init($this->entryLeft) : $this->entryLeft];
5347
}
5448

5549
/**
5650
* @return array<EntryReference>
5751
*/
5852
public function right() : array
5953
{
60-
return [$this->entryRight];
54+
return [\is_string($this->entryRight) ? EntryReference::init($this->entryRight) : $this->entryRight];
6155
}
6256
}

src/core/etl/src/Flow/ETL/Join/Comparison/GreaterThan.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,14 @@
99
use Flow\ETL\Row\EntryReference;
1010

1111
/**
12-
* @implements Comparison<array{entry_left: EntryReference, entry_right: EntryReference}>
12+
* @implements Comparison<array{entry_left: string|EntryReference, entry_right: string|EntryReference}>
1313
*/
1414
final class GreaterThan implements Comparison
1515
{
16-
private readonly EntryReference $entryLeft;
17-
18-
private readonly EntryReference $entryRight;
19-
2016
public function __construct(
21-
string|EntryReference $entryLeft,
22-
string|EntryReference $entryRight
17+
private readonly string|EntryReference $entryLeft,
18+
private readonly string|EntryReference $entryRight
2319
) {
24-
$this->entryLeft = EntryReference::init($entryLeft);
25-
$this->entryRight = EntryReference::init($entryRight);
2620
}
2721

2822
public function __serialize() : array
@@ -49,14 +43,14 @@ public function compare(Row $left, Row $right) : bool
4943
*/
5044
public function left() : array
5145
{
52-
return [$this->entryLeft];
46+
return [\is_string($this->entryLeft) ? EntryReference::init($this->entryLeft) : $this->entryLeft];
5347
}
5448

5549
/**
5650
* @return array<EntryReference>
5751
*/
5852
public function right() : array
5953
{
60-
return [$this->entryRight];
54+
return [\is_string($this->entryRight) ? EntryReference::init($this->entryRight) : $this->entryRight];
6155
}
6256
}

src/core/etl/src/Flow/ETL/Join/Comparison/GreaterThanEqual.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,14 @@
99
use Flow\ETL\Row\EntryReference;
1010

1111
/**
12-
* @implements Comparison<array{entry_left: EntryReference, entry_right: EntryReference}>
12+
* @implements Comparison<array{entry_left: string|EntryReference, entry_right: string|EntryReference}>
1313
*/
1414
final class GreaterThanEqual implements Comparison
1515
{
16-
private readonly EntryReference $entryLeft;
17-
18-
private readonly EntryReference $entryRight;
19-
2016
public function __construct(
21-
string|EntryReference $entryLeft,
22-
string|EntryReference $entryRight
17+
private readonly string|EntryReference $entryLeft,
18+
private readonly string|EntryReference $entryRight
2319
) {
24-
$this->entryLeft = EntryReference::init($entryLeft);
25-
$this->entryRight = EntryReference::init($entryRight);
2620
}
2721

2822
public function __serialize() : array
@@ -49,14 +43,14 @@ public function compare(Row $left, Row $right) : bool
4943
*/
5044
public function left() : array
5145
{
52-
return [$this->entryLeft];
46+
return [\is_string($this->entryLeft) ? EntryReference::init($this->entryLeft) : $this->entryLeft];
5347
}
5448

5549
/**
5650
* @return array<EntryReference>
5751
*/
5852
public function right() : array
5953
{
60-
return [$this->entryRight];
54+
return [\is_string($this->entryRight) ? EntryReference::init($this->entryRight) : $this->entryRight];
6155
}
6256
}

src/core/etl/src/Flow/ETL/Join/Comparison/Identical.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,14 @@
99
use Flow\ETL\Row\EntryReference;
1010

1111
/**
12-
* @implements Comparison<array{entry_left: EntryReference, entry_right: EntryReference}>
12+
* @implements Comparison<array{entry_left: string|EntryReference, entry_right: string|EntryReference}>
1313
*/
1414
final class Identical implements Comparison
1515
{
16-
private readonly EntryReference $entryLeft;
17-
18-
private readonly EntryReference $entryRight;
19-
2016
public function __construct(
21-
string|EntryReference $entryLeft,
22-
string|EntryReference $entryRight
17+
private readonly string|EntryReference $entryLeft,
18+
private readonly string|EntryReference $entryRight
2319
) {
24-
$this->entryLeft = EntryReference::init($entryLeft);
25-
$this->entryRight = EntryReference::init($entryRight);
2620
}
2721

2822
public function __serialize() : array
@@ -49,14 +43,14 @@ public function compare(Row $left, Row $right) : bool
4943
*/
5044
public function left() : array
5145
{
52-
return [$this->entryLeft];
46+
return [\is_string($this->entryLeft) ? EntryReference::init($this->entryLeft) : $this->entryLeft];
5347
}
5448

5549
/**
5650
* @return array<EntryReference>
5751
*/
5852
public function right() : array
5953
{
60-
return [$this->entryRight];
54+
return [\is_string($this->entryRight) ? EntryReference::init($this->entryRight) : $this->entryRight];
6155
}
6256
}

src/core/etl/src/Flow/ETL/Join/Comparison/LessThan.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,14 @@
99
use Flow\ETL\Row\EntryReference;
1010

1111
/**
12-
* @implements Comparison<array{entry_left: EntryReference, entry_right: EntryReference}>
12+
* @implements Comparison<array{entry_left: string|EntryReference, entry_right: string|EntryReference}>
1313
*/
1414
final class LessThan implements Comparison
1515
{
16-
private readonly EntryReference $entryLeft;
17-
18-
private readonly EntryReference $entryRight;
19-
2016
public function __construct(
21-
string|EntryReference $entryLeft,
22-
string|EntryReference $entryRight
17+
private readonly string|EntryReference $entryLeft,
18+
private readonly string|EntryReference $entryRight
2319
) {
24-
$this->entryLeft = EntryReference::init($entryLeft);
25-
$this->entryRight = EntryReference::init($entryRight);
2620
}
2721

2822
public function __serialize() : array
@@ -49,14 +43,14 @@ public function compare(Row $left, Row $right) : bool
4943
*/
5044
public function left() : array
5145
{
52-
return [$this->entryLeft];
46+
return [\is_string($this->entryLeft) ? EntryReference::init($this->entryLeft) : $this->entryLeft];
5347
}
5448

5549
/**
5650
* @return array<EntryReference>
5751
*/
5852
public function right() : array
5953
{
60-
return [$this->entryRight];
54+
return [\is_string($this->entryRight) ? EntryReference::init($this->entryRight) : $this->entryRight];
6155
}
6256
}

src/core/etl/src/Flow/ETL/Join/Comparison/LessThanEqual.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,14 @@
99
use Flow\ETL\Row\EntryReference;
1010

1111
/**
12-
* @implements Comparison<array{entry_left: EntryReference, entry_right: EntryReference}>
12+
* @implements Comparison<array{entry_left: string|EntryReference, entry_right: string|EntryReference}>
1313
*/
1414
final class LessThanEqual implements Comparison
1515
{
16-
private readonly EntryReference $entryLeft;
17-
18-
private readonly EntryReference $entryRight;
19-
2016
public function __construct(
21-
string|EntryReference $entryLeft,
22-
string|EntryReference $entryRight
17+
private readonly string|EntryReference $entryLeft,
18+
private readonly string|EntryReference $entryRight
2319
) {
24-
$this->entryLeft = EntryReference::init($entryLeft);
25-
$this->entryRight = EntryReference::init($entryRight);
2620
}
2721

2822
public function __serialize() : array
@@ -49,14 +43,14 @@ public function compare(Row $left, Row $right) : bool
4943
*/
5044
public function left() : array
5145
{
52-
return [$this->entryLeft];
46+
return [\is_string($this->entryLeft) ? EntryReference::init($this->entryLeft) : $this->entryLeft];
5347
}
5448

5549
/**
5650
* @return array<EntryReference>
5751
*/
5852
public function right() : array
5953
{
60-
return [$this->entryRight];
54+
return [\is_string($this->entryRight) ? EntryReference::init($this->entryRight) : $this->entryRight];
6155
}
6256
}

0 commit comments

Comments
 (0)