-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40555 from nextcloud/query-optimize-distribute
optimize query pattern used by storage filter
- Loading branch information
Showing
20 changed files
with
877 additions
and
54 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
29 changes: 29 additions & 0 deletions
29
lib/private/Files/Search/QueryOptimizer/FlattenNestedBool.php
This file contains 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,29 @@ | ||
<?php | ||
|
||
namespace OC\Files\Search\QueryOptimizer; | ||
|
||
use OC\Files\Search\SearchBinaryOperator; | ||
use OCP\Files\Search\ISearchBinaryOperator; | ||
use OCP\Files\Search\ISearchOperator; | ||
|
||
class FlattenNestedBool extends QueryOptimizerStep { | ||
public function processOperator(ISearchOperator &$operator) { | ||
if ( | ||
$operator instanceof SearchBinaryOperator && ( | ||
$operator->getType() === ISearchBinaryOperator::OPERATOR_OR || | ||
$operator->getType() === ISearchBinaryOperator::OPERATOR_AND | ||
) | ||
) { | ||
$newArguments = []; | ||
foreach ($operator->getArguments() as $oldArgument) { | ||
if ($oldArgument instanceof SearchBinaryOperator && $oldArgument->getType() === $operator->getType()) { | ||
$newArguments = array_merge($newArguments, $oldArgument->getArguments()); | ||
} else { | ||
$newArguments[] = $oldArgument; | ||
} | ||
} | ||
$operator->setArguments($newArguments); | ||
} | ||
parent::processOperator($operator); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
lib/private/Files/Search/QueryOptimizer/FlattenSingleArgumentBinaryOperation.php
This file contains 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,27 @@ | ||
<?php | ||
|
||
namespace OC\Files\Search\QueryOptimizer; | ||
|
||
use OCP\Files\Search\ISearchBinaryOperator; | ||
use OCP\Files\Search\ISearchOperator; | ||
|
||
/** | ||
* replace single argument AND and OR operations with their single argument | ||
*/ | ||
class FlattenSingleArgumentBinaryOperation extends ReplacingOptimizerStep { | ||
public function processOperator(ISearchOperator &$operator): bool { | ||
parent::processOperator($operator); | ||
if ( | ||
$operator instanceof ISearchBinaryOperator && | ||
count($operator->getArguments()) === 1 && | ||
( | ||
$operator->getType() === ISearchBinaryOperator::OPERATOR_OR || | ||
$operator->getType() === ISearchBinaryOperator::OPERATOR_AND | ||
) | ||
) { | ||
$operator = $operator->getArguments()[0]; | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
Oops, something went wrong.