2021-08-23 09:01:03 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2021-08-23 09:01:03 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace OC\Files\Search\QueryOptimizer;
|
|
|
|
|
|
|
|
|
|
use OCP\Files\Search\ISearchOperator;
|
|
|
|
|
|
|
|
|
|
class QueryOptimizer {
|
|
|
|
|
/** @var QueryOptimizerStep[] */
|
|
|
|
|
private $steps = [];
|
|
|
|
|
|
2023-09-21 07:49:16 -04:00
|
|
|
public function __construct() {
|
|
|
|
|
// note that the order here is relevant
|
2021-08-23 09:01:03 -04:00
|
|
|
$this->steps = [
|
2023-09-21 07:49:16 -04:00
|
|
|
new PathPrefixOptimizer(),
|
|
|
|
|
new MergeDistributiveOperations(),
|
|
|
|
|
new FlattenSingleArgumentBinaryOperation(),
|
2024-02-06 08:31:21 -05:00
|
|
|
new FlattenNestedBool(),
|
2023-09-21 07:49:16 -04:00
|
|
|
new OrEqualsToIn(),
|
|
|
|
|
new FlattenNestedBool(),
|
2024-02-05 12:56:43 -05:00
|
|
|
new SplitLargeIn(),
|
2021-08-23 09:01:03 -04:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-21 07:49:16 -04:00
|
|
|
public function processOperator(ISearchOperator &$operator) {
|
2023-01-11 10:38:41 -05:00
|
|
|
foreach ($this->steps as $step) {
|
|
|
|
|
$step->inspectOperator($operator);
|
|
|
|
|
}
|
2021-08-23 09:01:03 -04:00
|
|
|
foreach ($this->steps as $step) {
|
|
|
|
|
$step->processOperator($operator);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|