forked from halo-dev/halo
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
- Loading branch information
Showing
42 changed files
with
1,905 additions
and
611 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
47 changes: 47 additions & 0 deletions
47
api/src/main/java/run/halo/app/extension/index/KeyComparator.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,47 @@ | ||
package run.halo.app.extension.index; | ||
|
||
import java.util.Comparator; | ||
import org.springframework.lang.Nullable; | ||
|
||
public class KeyComparator implements Comparator<String> { | ||
public static final KeyComparator INSTANCE = new KeyComparator(); | ||
|
||
@Override | ||
public int compare(@Nullable String a, @Nullable String b) { | ||
if (a == null && b == null) { | ||
return 0; | ||
} else if (a == null) { | ||
// null less than everything | ||
return 1; | ||
} else if (b == null) { | ||
// null less than everything | ||
return -1; | ||
} | ||
|
||
int i = 0; | ||
int j = 0; | ||
while (i < a.length() && j < b.length()) { | ||
if (Character.isDigit(a.charAt(i)) && Character.isDigit(b.charAt(j))) { | ||
// handle number part | ||
int num1 = 0; | ||
int num2 = 0; | ||
while (i < a.length() && Character.isDigit(a.charAt(i))) { | ||
num1 = num1 * 10 + (a.charAt(i++) - '0'); | ||
} | ||
while (j < b.length() && Character.isDigit(b.charAt(j))) { | ||
num2 = num2 * 10 + (b.charAt(j++) - '0'); | ||
} | ||
if (num1 != num2) { | ||
return num1 - num2; | ||
} | ||
} else if (a.charAt(i) != b.charAt(j)) { | ||
// handle non-number part | ||
return a.charAt(i) - b.charAt(j); | ||
} else { | ||
i++; | ||
j++; | ||
} | ||
} | ||
return a.length() - b.length(); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
api/src/main/java/run/halo/app/extension/index/query/IsNotNull.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,15 @@ | ||
package run.halo.app.extension.index.query; | ||
|
||
import java.util.NavigableSet; | ||
|
||
public class IsNotNull extends SimpleQuery { | ||
|
||
protected IsNotNull(String fieldName) { | ||
super(fieldName, null); | ||
} | ||
|
||
@Override | ||
public NavigableSet<String> matches(QueryIndexView indexView) { | ||
return indexView.getAllIdsForField(fieldName); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
api/src/main/java/run/halo/app/extension/index/query/IsNull.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,18 @@ | ||
package run.halo.app.extension.index.query; | ||
|
||
import java.util.NavigableSet; | ||
|
||
public class IsNull extends SimpleQuery { | ||
|
||
protected IsNull(String fieldName) { | ||
super(fieldName, null); | ||
} | ||
|
||
@Override | ||
public NavigableSet<String> matches(QueryIndexView indexView) { | ||
var allIds = indexView.getAllIds(); | ||
var idsForField = indexView.getAllIdsForField(fieldName); | ||
allIds.removeAll(idsForField); | ||
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
Oops, something went wrong.