-
-
Notifications
You must be signed in to change notification settings - Fork 53
#1390 - configurable storage for aggregating functions #2473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MrHDOLEK
wants to merge
1
commit into
flow-php:1.x
Choose a base branch
from
MrHDOLEK:#1390
base: 1.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ let | |
| with all; | ||
| enabled | ||
| ++ [ | ||
| apcu | ||
| bcmath | ||
| dom | ||
| mbstring | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/core/etl/src/Flow/ETL/Config/Aggregation/AggregationConfig.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Flow\ETL\Config\Aggregation; | ||
|
|
||
| use Flow\ETL\Dataset\Memory\Unit; | ||
| use Flow\ETL\GroupBy\AggregationStorageStrategy; | ||
| use Flow\ETL\GroupBy\Storage\AggregationStorage; | ||
|
|
||
| final readonly class AggregationConfig | ||
| { | ||
| public const string AGGREGATION_MAX_MEMORY_ENV = 'FLOW_AGGREGATION_MAX_MEMORY'; | ||
|
|
||
| public function __construct( | ||
| public AggregationStorageStrategy $strategy, | ||
| public Unit $memoryLimit, | ||
| public ?AggregationStorage $storage = null, | ||
| public string $filesystemProtocol = 'file', | ||
| ) {} | ||
| } |
79 changes: 79 additions & 0 deletions
79
src/core/etl/src/Flow/ETL/Config/Aggregation/AggregationConfigBuilder.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Flow\ETL\Config\Aggregation; | ||
|
|
||
| use Flow\ETL\Dataset\Memory\Unit; | ||
| use Flow\ETL\GroupBy\AggregationStorageStrategy; | ||
| use Flow\ETL\GroupBy\Storage\AggregationStorage; | ||
|
|
||
| use function getenv; | ||
| use function ini_get; | ||
| use function is_string; | ||
|
|
||
| use const PHP_INT_MAX; | ||
|
|
||
| final class AggregationConfigBuilder | ||
| { | ||
| public const int DEFAULT_AGGREGATION_MEMORY_PERCENTAGE = 70; | ||
|
|
||
| private string $filesystemProtocol = 'file'; | ||
|
|
||
| private ?Unit $memoryLimit = null; | ||
|
|
||
| private ?AggregationStorage $storage = null; | ||
|
|
||
| private AggregationStorageStrategy $strategy = AggregationStorageStrategy::MEMORY; | ||
|
|
||
| public function build(): AggregationConfig | ||
| { | ||
| if ($this->memoryLimit === null) { | ||
| $aggregationMemory = getenv(AggregationConfig::AGGREGATION_MAX_MEMORY_ENV); | ||
|
|
||
| if (is_string($aggregationMemory)) { | ||
| $this->memoryLimit = Unit::fromString($aggregationMemory); | ||
| } else { | ||
| $memoryLimit = ini_get('memory_limit'); | ||
|
|
||
| if ($memoryLimit === false || $memoryLimit === '-1') { | ||
| $this->memoryLimit = Unit::fromBytes(PHP_INT_MAX); | ||
| } else { | ||
| $this->memoryLimit = Unit::fromString( | ||
| $memoryLimit, | ||
| )->percentage(self::DEFAULT_AGGREGATION_MEMORY_PERCENTAGE); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return new AggregationConfig($this->strategy, $this->memoryLimit, $this->storage, $this->filesystemProtocol); | ||
| } | ||
|
|
||
| public function filesystemProtocol(string $protocol): self | ||
| { | ||
| $this->filesystemProtocol = $protocol; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| public function memoryLimit(Unit $memoryLimit): self | ||
| { | ||
| $this->memoryLimit = $memoryLimit; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| public function storage(AggregationStorage $storage): self | ||
| { | ||
| $this->storage = $storage; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| public function strategy(AggregationStorageStrategy $strategy): self | ||
| { | ||
| $this->strategy = $strategy; | ||
|
|
||
| return $this; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,12 +8,15 @@ | |
| use Flow\ETL\Analyze; | ||
| use Flow\ETL\Cache; | ||
| use Flow\ETL\Config; | ||
| use Flow\ETL\Config\Aggregation\AggregationConfigBuilder; | ||
| use Flow\ETL\Config\Cache\CacheConfigBuilder; | ||
| use Flow\ETL\Config\Sort\SortConfigBuilder; | ||
| use Flow\ETL\Config\Telemetry\TelemetryConfig; | ||
| use Flow\ETL\Config\Telemetry\TelemetryOptions; | ||
| use Flow\ETL\Dataset\Memory\Unit; | ||
| use Flow\ETL\Filesystem\FilesystemStreams; | ||
| use Flow\ETL\GroupBy\AggregationStorageStrategy; | ||
| use Flow\ETL\GroupBy\Storage\AggregationStorage; | ||
| use Flow\ETL\NativePHPRandomValueGenerator; | ||
| use Flow\ETL\Pipeline\Optimizer; | ||
| use Flow\ETL\Pipeline\Optimizer\BatchSizeOptimization; | ||
|
|
@@ -34,6 +37,8 @@ | |
|
|
||
| final class ConfigBuilder | ||
| { | ||
| public readonly AggregationConfigBuilder $aggregation; | ||
|
|
||
| public readonly CacheConfigBuilder $cache; | ||
|
|
||
| public readonly SortConfigBuilder $sort; | ||
|
|
@@ -69,6 +74,7 @@ public function __construct() | |
| $this->putInputIntoRows = false; | ||
| $this->optimizer = null; | ||
| $this->clock = null; | ||
| $this->aggregation = new AggregationConfigBuilder(); | ||
| $this->cache = new CacheConfigBuilder(); | ||
| $this->sort = new SortConfigBuilder(); | ||
| $this->randomValueGenerator = new NativePHPRandomValueGenerator(); | ||
|
|
@@ -79,6 +85,34 @@ public function __construct() | |
| : PackageVersion::get('flow-php/etl'); | ||
| } | ||
|
|
||
| public function aggregationFilesystem(string $protocol): self | ||
| { | ||
| $this->aggregation->filesystemProtocol($protocol); | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| public function aggregationMemoryLimit(Unit $unit): self | ||
| { | ||
| $this->aggregation->memoryLimit($unit); | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| public function aggregationStorage(AggregationStorageStrategy $strategy): self | ||
| { | ||
| $this->aggregation->strategy($strategy); | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| public function aggregationStore(AggregationStorage $storage): self | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those two methods, aggregationStorage and aggregationStore are a bit confusing |
||
| { | ||
| $this->aggregation->storage($storage); | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| public function analyze(Analyze $analyze): self | ||
| { | ||
| $this->analyze = $analyze; | ||
|
|
@@ -111,6 +145,7 @@ public function build(EntryFactory $entryFactory = new EntryFactory()): Config | |
| $this->sort->build(), | ||
| $this->analyze, | ||
| $this->telemetryConfig ?? TelemetryConfig::default($this->getClock()), | ||
| $this->aggregation->build(), | ||
| ); | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so storage or strategy? 😅