-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: optimize old attachment query parameters using index (#5363)
#### What type of PR is this? /kind improvement /area core /milestone 2.13.x #### What this PR does / why we need it: 使用索引功能优化附件列表查询 #### Does this PR introduce a user-facing change? ```release-note 使用索引功能优化附件列表查询 ```
- Loading branch information
Showing
11 changed files
with
169 additions
and
263 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
api/src/main/java/run/halo/app/extension/index/query/Not.java
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 @@ | ||
package run.halo.app.extension.index.query; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.util.Collections; | ||
import java.util.NavigableSet; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class Not extends LogicalQuery { | ||
|
||
private final Query negatedQuery; | ||
|
||
public Not(Query negatedQuery) { | ||
super(Collections.singleton( | ||
requireNonNull(negatedQuery, "The negated query must not be null."))); | ||
this.negatedQuery = negatedQuery; | ||
} | ||
|
||
@Override | ||
public NavigableSet<String> matches(QueryIndexView indexView) { | ||
var negatedResult = negatedQuery.matches(indexView); | ||
var allIds = indexView.getAllIds(); | ||
allIds.removeAll(negatedResult); | ||
return allIds; | ||
} | ||
} |
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
Oops, something went wrong.