Modifier and Type | Field and Description |
---|---|
static int |
ASCENDING
This bit mask means the values should be sorted in ascending order.
|
static int |
DESCENDING
This bit mask means the values should be sorted in descending order.
|
static int |
NULLS_FIRST
This bit mask means NULLs should be sorted before other data, no matter
if ascending or descending order is used.
|
static int |
NULLS_LAST
This bit mask means NULLs should be sorted after other data, no matter
if ascending or descending order is used.
|
Constructor and Description |
---|
SortOrder(SessionLocal session,
int[] queryColumnIndexes)
Construct a new sort order object with default sort directions.
|
SortOrder(SessionLocal session,
int[] queryColumnIndexes,
int[] sortType,
java.util.ArrayList<QueryOrderBy> orderList)
Construct a new sort order object.
|
Modifier and Type | Method and Description |
---|---|
static int[] |
addNullOrdering(Database database,
int[] sortTypes)
Add explicit
NULLS_FIRST or NULLS_LAST where they
aren't already specified. |
int |
compare(Value[] a,
Value[] b)
Compare two expression lists.
|
Column |
getColumn(int index,
TableFilter filter)
Get the column for the given table filter, if the sort column is for this
filter.
|
java.util.ArrayList<QueryOrderBy> |
getOrderList()
Returns the original query order list.
|
int[] |
getQueryColumnIndexes()
Get the column index list.
|
java.util.Comparator<Value> |
getRowValueComparator()
Returns comparator for row values.
|
int[] |
getSortTypes()
Get the sort order bit masks.
|
int[] |
getSortTypesWithNullOrdering()
Returns sort order bit masks with
NULLS_FIRST or
NULLS_LAST explicitly set. |
java.lang.StringBuilder |
getSQL(java.lang.StringBuilder builder,
Expression[] list,
int visible,
int sqlFlags)
Create the SQL snippet that describes this sort order.
|
void |
sort(java.util.ArrayList<Value[]> rows)
Sort a list of rows.
|
void |
sort(java.util.ArrayList<Value[]> rows,
int fromInclusive,
int toExclusive)
Sort a list of rows using offset and limit.
|
static void |
typeToString(java.lang.StringBuilder builder,
int type)
Appends type information (DESC, NULLS FIRST, NULLS LAST) to the specified statement builder.
|
public static final int ASCENDING
public static final int DESCENDING
public static final int NULLS_FIRST
public static final int NULLS_LAST
public SortOrder(SessionLocal session, int[] queryColumnIndexes)
session
- the sessionqueryColumnIndexes
- the column index listpublic SortOrder(SessionLocal session, int[] queryColumnIndexes, int[] sortType, java.util.ArrayList<QueryOrderBy> orderList)
session
- the sessionqueryColumnIndexes
- the column index listsortType
- the sort order bit masksorderList
- the original query order list (if this is a query)public java.lang.StringBuilder getSQL(java.lang.StringBuilder builder, Expression[] list, int visible, int sqlFlags)
builder
- string builder to append tolist
- the expression listvisible
- the number of columns in the select listsqlFlags
- formatting flagspublic static void typeToString(java.lang.StringBuilder builder, int type)
builder
- string buildertype
- sort typepublic int compare(Value[] a, Value[] b)
compare
in interface java.util.Comparator<Value[]>
a
- the first expression listb
- the second expression listpublic void sort(java.util.ArrayList<Value[]> rows)
rows
- the list of rowspublic void sort(java.util.ArrayList<Value[]> rows, int fromInclusive, int toExclusive)
rows
- the list of rowsfromInclusive
- the start index, inclusivetoExclusive
- the end index, exclusivepublic int[] getQueryColumnIndexes()
For the query "select name, id from test order by id, name" this is {1, 0} as the first order by expression (the column "id") is the second column of the query, and the second order by expression ("name") is the first column of the query.
public Column getColumn(int index, TableFilter filter)
index
- the column index (0, 1,..)filter
- the table filterpublic int[] getSortTypes()
public java.util.ArrayList<QueryOrderBy> getOrderList()
public int[] getSortTypesWithNullOrdering()
NULLS_FIRST
or
NULLS_LAST
explicitly set.NULLS_FIRST
or NULLS_LAST
explicitly set.public static int[] addNullOrdering(Database database, int[] sortTypes)
NULLS_FIRST
or NULLS_LAST
where they
aren't already specified.database
- the databasesortTypes
- bit maskspublic java.util.Comparator<Value> getRowValueComparator()