QueryOptimizer.php 867 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Files\Search\QueryOptimizer;
  8. use OCP\Files\Search\ISearchOperator;
  9. class QueryOptimizer {
  10. /** @var QueryOptimizerStep[] */
  11. private $steps = [];
  12. public function __construct() {
  13. // note that the order here is relevant
  14. $this->steps = [
  15. new PathPrefixOptimizer(),
  16. new MergeDistributiveOperations(),
  17. new FlattenSingleArgumentBinaryOperation(),
  18. new FlattenNestedBool(),
  19. new OrEqualsToIn(),
  20. new FlattenNestedBool(),
  21. new SplitLargeIn(),
  22. ];
  23. }
  24. public function processOperator(ISearchOperator &$operator) {
  25. foreach ($this->steps as $step) {
  26. $step->inspectOperator($operator);
  27. }
  28. foreach ($this->steps as $step) {
  29. $step->processOperator($operator);
  30. }
  31. }
  32. }