-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
[wip] Filecache chunking #43576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
[wip] Filecache chunking #43576
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
216a92e
feat: add class for (future) shared access to the filecache
icewind1991 647e64d
expose escapeLikeParameter trough query builder
icewind1991 b3b0c14
block access to the filecache tables by default
icewind1991 1611232
adjust share provider wip
icewind1991 f481a4a
refactor: don't join on filecache in usermountcache
icewind1991 e7c8840
transform favorite, tag and systemtag search queries to fileid lists
icewind1991 4c6aabf
register DI alias for IFileAccess
icewind1991 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
transform favorite, tag and systemtag search queries to fileid lists
not as performant but compatible with sharding Signed-off-by: Robin Appelman <[email protected]>
- Loading branch information
commit e7c884043aca8802bd40aadcd4ecdf9be706085d
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
70 changes: 70 additions & 0 deletions
70
lib/private/Files/Search/QueryOptimizer/DavTagToFileIds.php
This file contains hidden or 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,70 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
| /** | ||
| * @copyright Copyright (c) 2024 Robin Appelman <[email protected]> | ||
| * | ||
| * @license GNU AGPL version 3 or any later version | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as | ||
| * published by the Free Software Foundation, either version 3 of the | ||
| * License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| namespace OC\Files\Search\QueryOptimizer; | ||
|
|
||
| use OC\Files\Search\SearchComparison; | ||
| use OCP\Files\Search\ISearchComparison; | ||
| use OCP\Files\Search\ISearchOperator; | ||
| use OCP\IDBConnection; | ||
| use OCP\IGroupManager; | ||
| use OCP\IUser; | ||
|
|
||
| class DavTagToFileIds extends ReplacingOptimizerStep { | ||
| public function __construct( | ||
| private IDBConnection $connection, | ||
| private IUser $user, | ||
| ) { | ||
| } | ||
|
|
||
| public function processOperator(ISearchOperator &$operator): bool { | ||
| if ($operator instanceof ISearchComparison && $operator->getField() === 'tagname') { | ||
| $operator = new SearchComparison(ISearchComparison::COMPARE_IN, 'fileid', $this->getFileIdsForDavTag($operator)); | ||
| return true; | ||
| } else { | ||
| return parent::processOperator($operator); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| private function getFileIdsForDavTag(ISearchComparison $comparison): array { | ||
| $query = $this->connection->getQueryBuilder(); | ||
|
|
||
| $query->select('tagmap.objid') | ||
| ->from('vcategory_to_object', 'tagmap') | ||
| ->leftJoin('tagmap', 'vcategory', 'tag', $query->expr()->andX( | ||
| $query->expr()->eq('tagmap.type', 'tag.type'), | ||
| $query->expr()->eq('tagmap.categoryid', 'tag.id') | ||
| )) | ||
| ->where($query->expr()->eq('tag.type', $query->createNamedParameter('files'))) | ||
| ->andWhere($query->expr()->eq('tag.uid', $query->createNamedParameter($this->user->getUID()))); | ||
| if ($comparison->getType() === ISearchComparison::COMPARE_EQUAL) { | ||
| $query->andWhere($query->expr()->eq('tag.category', $query->createNamedParameter($comparison->getValue()))); | ||
| } elseif ($comparison->getType() === ISearchComparison::COMPARE_LIKE) { | ||
| $query->andWhere($query->expr()->like('tag.category', $query->createNamedParameter($comparison->getValue()))); | ||
| } else { | ||
| throw new \InvalidArgumentException('Unsupported comparison for field ' . $comparison->getField() . ': ' . $comparison->getType()); | ||
| } | ||
| return $query->executeQuery()->fetchAll(\PDO::FETCH_COLUMN); | ||
| } | ||
| } |
This file contains hidden or 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,44 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
| /** | ||
| * @copyright Copyright (c) 2024 Robin Appelman <[email protected]> | ||
| * | ||
| * @license GNU AGPL version 3 or any later version | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as | ||
| * published by the Free Software Foundation, either version 3 of the | ||
| * License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| namespace OC\Files\Search\QueryOptimizer; | ||
|
|
||
| use OC\Files\Search\SearchComparison; | ||
| use OCP\Files\Search\ISearchComparison; | ||
| use OCP\Files\Search\ISearchOperator; | ||
| use OCP\IDBConnection; | ||
| use OCP\IGroupManager; | ||
| use OCP\IUser; | ||
|
|
||
| class FavoriteToTag extends ReplacingOptimizerStep { | ||
| public const TAG_FAVORITE = '_$!<Favorite>!$_'; | ||
|
|
||
| public function processOperator(ISearchOperator &$operator): bool { | ||
| if ($operator instanceof ISearchComparison && $operator->getField() === 'favorite' && $operator->getType() === ISearchComparison::COMPARE_EQUAL) { | ||
| $operator = new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'tagname', self::TAG_FAVORITE); | ||
| return true; | ||
| } else { | ||
| return parent::processOperator($operator); | ||
| } | ||
| } | ||
| } |
73 changes: 73 additions & 0 deletions
73
lib/private/Files/Search/QueryOptimizer/SystemTagToFileIds.php
This file contains hidden or 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,73 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
| /** | ||
| * @copyright Copyright (c) 2024 Robin Appelman <[email protected]> | ||
| * | ||
| * @license GNU AGPL version 3 or any later version | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as | ||
| * published by the Free Software Foundation, either version 3 of the | ||
| * License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| namespace OC\Files\Search\QueryOptimizer; | ||
|
|
||
| use OC\Files\Search\SearchComparison; | ||
| use OCP\Files\Search\ISearchComparison; | ||
| use OCP\Files\Search\ISearchOperator; | ||
| use OCP\IDBConnection; | ||
| use OCP\IGroupManager; | ||
| use OCP\IUser; | ||
|
|
||
| class SystemTagToFileIds extends ReplacingOptimizerStep { | ||
| public function __construct( | ||
| private IDBConnection $connection, | ||
| private IUser $user, | ||
| private IGroupManager $groupManager, | ||
| ) { | ||
| } | ||
|
|
||
| public function processOperator(ISearchOperator &$operator): bool { | ||
| if ($operator instanceof ISearchComparison && $operator->getField() === 'systemtag') { | ||
| $operator = new SearchComparison(ISearchComparison::COMPARE_IN, 'fileid', $this->getFileIdsForSystemTag($operator)); | ||
| return true; | ||
| } else { | ||
| return parent::processOperator($operator); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| private function getFileIdsForSystemTag(ISearchComparison $comparison): array { | ||
| $query = $this->connection->getQueryBuilder(); | ||
|
|
||
| $on = $query->expr()->andX($query->expr()->eq('systemtag.id', 'systemtagmap.systemtagid')); | ||
| if (!$this->groupManager->isAdmin($this->user->getUID())) { | ||
| $on->add($query->expr()->eq('systemtag.visibility', $query->createNamedParameter(true))); | ||
| } | ||
|
|
||
| $query->select('systemtagmap.objectid') | ||
| ->from('systemtag_object_mapping', 'systemtagmap') | ||
| ->leftJoin('systemtagmap', 'systemtag', 'systemtag', $on) | ||
| ->where($query->expr()->eq('systemtagmap.objecttype', $query->createNamedParameter('files'))) | ||
| ->andWhere($query->expr()->eq('systemtagmap.objecttype', $query->createNamedParameter('files'))); | ||
| if ($comparison->getType() === ISearchComparison::COMPARE_EQUAL) { | ||
| $query->andWhere($query->expr()->eq('systemtag.name', $query->createNamedParameter($comparison->getValue()))); | ||
| } elseif ($comparison->getType() === ISearchComparison::COMPARE_LIKE) { | ||
| $query->andWhere($query->expr()->like('systemtag.name', $query->createNamedParameter($comparison->getValue()))); | ||
| } else { | ||
| throw new \InvalidArgumentException('Unsupported comparison for field ' . $comparison->getField() . ': ' . $comparison->getType()); | ||
| } | ||
| return $query->executeQuery()->fetchAll(\PDO::FETCH_COLUMN); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / Psalm
InvalidArgument