提交 cfde40ae authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Rename some private fields in SortOrder and optimize code a bit

上级 bf06f2b4
...@@ -50,20 +50,31 @@ public class SortOrder implements Comparator<Value[]> { ...@@ -50,20 +50,31 @@ public class SortOrder implements Comparator<Value[]> {
public static final int NULLS_LAST = 4; public static final int NULLS_LAST = 4;
/** /**
* The default sort order for NULL. * The default comparison result for NULL, either 1 or -1.
*/ */
private static final int DEFAULT_NULL_SORT = private static final int DEFAULT_NULL_SORT;
SysProperties.SORT_NULLS_HIGH ? 1 : -1;
/** /**
* The default sort order bit for NULLs last. * The default NULLs sort order bit for ASC indexes.
*/ */
private static final int DEFAULT_NULLS_LAST = SysProperties.SORT_NULLS_HIGH ? NULLS_LAST : NULLS_FIRST; private static final int DEFAULT_ASC_NULLS;
/** /**
* The default sort order bit for NULLs first. * The default NULLs sort order bit for DESC indexes.
*/ */
private static final int DEFAULT_NULLS_FIRST = SysProperties.SORT_NULLS_HIGH ? NULLS_FIRST : NULLS_LAST; private static final int DEFAULT_DESC_NULLS;
static {
if (SysProperties.SORT_NULLS_HIGH) {
DEFAULT_NULL_SORT = 1;
DEFAULT_ASC_NULLS = NULLS_LAST;
DEFAULT_DESC_NULLS = NULLS_FIRST;
} else { // default
DEFAULT_NULL_SORT = -1;
DEFAULT_ASC_NULLS = NULLS_FIRST;
DEFAULT_DESC_NULLS = NULLS_LAST;
}
}
private final Database database; private final Database database;
...@@ -292,9 +303,9 @@ public class SortOrder implements Comparator<Value[]> { ...@@ -292,9 +303,9 @@ public class SortOrder implements Comparator<Value[]> {
* @param sortType sort type bit mask * @param sortType sort type bit mask
* @return bit mask with either {@link #NULLS_FIRST} or {@link #NULLS_LAST} explicitly set. * @return bit mask with either {@link #NULLS_FIRST} or {@link #NULLS_LAST} explicitly set.
*/ */
public static int addExplicitNullPosition(final int sortType) { public static int addExplicitNullPosition(int sortType) {
if ((sortType & NULLS_FIRST) != NULLS_FIRST && (sortType & NULLS_LAST) != NULLS_LAST) { if ((sortType & (NULLS_FIRST | NULLS_LAST)) == 0) {
return sortType | ((sortType & DESCENDING) == ASCENDING ? DEFAULT_NULLS_LAST : DEFAULT_NULLS_FIRST); return sortType | ((sortType & DESCENDING) == 0 ? DEFAULT_ASC_NULLS : DEFAULT_DESC_NULLS);
} else { } else {
return sortType; return sortType;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论