1
0

QueryOptimizerStep.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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\ISearchBinaryOperator;
  9. use OCP\Files\Search\ISearchOperator;
  10. class QueryOptimizerStep {
  11. /**
  12. * Allow optimizer steps to inspect the entire query before starting processing
  13. *
  14. * @param ISearchOperator $operator
  15. * @return void
  16. */
  17. public function inspectOperator(ISearchOperator $operator): void {
  18. if ($operator instanceof ISearchBinaryOperator) {
  19. foreach ($operator->getArguments() as $argument) {
  20. $this->inspectOperator($argument);
  21. }
  22. }
  23. }
  24. /**
  25. * Allow optimizer steps to modify query operators
  26. *
  27. * @param ISearchOperator $operator
  28. * @return void
  29. */
  30. public function processOperator(ISearchOperator &$operator) {
  31. if ($operator instanceof ISearchBinaryOperator) {
  32. foreach ($operator->getArguments() as $argument) {
  33. $this->processOperator($argument);
  34. }
  35. }
  36. }
  37. }