Skip to content

Commit

Permalink
hopefully improve propagation of 'path eq hash' hint into 'in' statem…
Browse files Browse the repository at this point in the history
…ents

Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Feb 5, 2024
1 parent 4f8db37 commit aba15a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ public function processOperator(ISearchOperator &$operator) {
}
parent::processOperator($operator);
}

}
8 changes: 5 additions & 3 deletions lib/private/Files/Search/QueryOptimizer/OrEqualsToIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public function processOperator(ISearchOperator &$operator): bool {
return $value;
}, $group);
$in = new SearchComparison(ISearchComparison::COMPARE_IN, $field, $values);
$in->setQueryHint(ISearchComparison::HINT_PATH_EQ_HASH, $group[0]->getQueryHint(ISearchComparison::HINT_PATH_EQ_HASH, true));
$pathEqHash = array_reduce($group, function ($pathEqHash, ISearchComparison $comparison) {
return $comparison->getQueryHint(ISearchComparison::HINT_PATH_EQ_HASH, true) && $pathEqHash;
}, true);
$in->setQueryHint(ISearchComparison::HINT_PATH_EQ_HASH, $pathEqHash);
return $in;
} else {
return $group[0];
Expand Down Expand Up @@ -57,8 +60,7 @@ private function groupEqualsComparisonsByField(array $operators): array {
$result = [];
foreach ($operators as $operator) {
if ($operator instanceof ISearchComparison && $operator->getType() === ISearchComparison::COMPARE_EQUAL) {
$key = $operator->getField() . $operator->getQueryHint(ISearchComparison::HINT_PATH_EQ_HASH, true);
$result[$key][] = $operator;
$result[$operator->getField()][] = $operator;
} else {
$result[] = [$operator];
}
Expand Down

0 comments on commit aba15a1

Please sign in to comment.