class RowOrderingImpl extends java.lang.Object implements RowOrdering
Modifier and Type | Field and Description |
---|---|
private java.util.ArrayList<Optimizable> |
alwaysOrderedOptimizables
List of table numbers for tables that are always ordered.
|
(package private) ColumnOrdering |
columnsAlwaysOrdered |
(package private) ColumnOrdering |
currentColumnOrdering |
private java.util.ArrayList<ColumnOrdering> |
ordering
List of ColumnOrderings.
|
private java.util.ArrayList<Optimizable> |
unorderedOptimizables
List of unordered Optimizables.
|
ASCENDING, DESCENDING, DONTCARE
Constructor and Description |
---|
RowOrderingImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addOrderedColumn(int direction,
int tableNumber,
int columnNumber)
Add a column to this RowOrdering in the current order position.
|
void |
addUnorderedOptimizable(Optimizable optimizable)
Add an unordered optimizable to this RowOrdering.
|
boolean |
alwaysOrdered(int tableNumber)
Ask whether the given table is always ordered.
|
void |
columnAlwaysOrdered(Optimizable optimizable,
int columnNumber)
Tell this RowOrdering that it is always ordered on the given column
of the given optimizable.
|
void |
copy(RowOrdering copyTo)
Copy the contents of this RowOrdering to the given RowOrdering.
|
boolean |
isColumnAlwaysOrdered(int tableNumber,
int columnNumber)
Return true if the column is always ordered.
|
void |
nextOrderPosition(int direction)
Move to the next order position for adding ordered columns.
|
void |
optimizableAlwaysOrdered(Optimizable optimizable)
Tell this RowOrdering that it is always ordered on the given optimizable
This is useful when considering a unique index where there is an
equality match on the entire key - in this case, all the columns
are ordered, regardless of the direction or position,
or even whether the columns are in the index.
|
boolean |
orderedOnColumn(int direction,
int tableNumber,
int columnNumber)
Tell whether this ordering is ordered on the given column.
|
boolean |
orderedOnColumn(int direction,
int orderPosition,
int tableNumber,
int columnNumber)
Tell whether this ordering is ordered on the given column in
the given position
|
private void |
rememberCurrentColumnOrdering(int posn) |
void |
removeOptimizable(int tableNumber)
Tell this row ordering that it is no longer ordered on the given
table.
|
private void |
removeOptimizable(int tableNumber,
java.util.ArrayList<Optimizable> list)
Remove all optimizables with the given table number from the
given list of optimizables.
|
java.lang.String |
toString() |
private boolean |
unorderedOptimizablesOtherThan(Optimizable optimizable)
Returns true if there are unordered optimizables in the join order
other than the given one.
|
private final java.util.ArrayList<ColumnOrdering> ordering
ColumnOrdering columnsAlwaysOrdered
private final java.util.ArrayList<Optimizable> alwaysOrderedOptimizables
ColumnOrdering currentColumnOrdering
private final java.util.ArrayList<Optimizable> unorderedOptimizables
public boolean isColumnAlwaysOrdered(int tableNumber, int columnNumber)
RowOrdering
isColumnAlwaysOrdered
in interface RowOrdering
tableNumber
- The table in questioncolumnNumber
- The number of the column in question.RowOrdering.isColumnAlwaysOrdered(int, int)
public boolean orderedOnColumn(int direction, int orderPosition, int tableNumber, int columnNumber) throws StandardException
RowOrdering
orderedOnColumn
in interface RowOrdering
direction
- One of ASCENDING, DESCENDING, or DONTCARE
depending on the requirements of the caller.
An ORDER BY clause cares about direction,
while DISTINCT and GROUP BY do not.orderPosition
- The position in the ordering list. For example,
for ORDER BY A, B, position 0 has column A,
and position 1 has column B. Note that for an
ordering, more than one column can be in a single
ordering position: for example, in the query
SELECT * FROM S, T WHERE S.A = T.B ORDER BY T.B
columns S.A and T.B will be in the same ordering
positions because they are equal. Also, constant
values are considered ordered in all positions
(consider SELECT A FROM T WHERE A = 1 ORDER BY A).tableNumber
- The table number of the Optimizable containing
the column in questioncolumnNumber
- The column number in the table (one-based).StandardException
- Thrown on errorRowOrdering.orderedOnColumn(int, int, int, int)
public boolean orderedOnColumn(int direction, int tableNumber, int columnNumber) throws StandardException
RowOrdering
orderedOnColumn
in interface RowOrdering
direction
- One of ASCENDING, DESCENDING, or DONTCARE
depending on the requirements of the caller.
An ORDER BY clause cares about direction,
while DISTINCT and GROUP BY do not.tableNumber
- The table number of the Optimizable containing
the column in questioncolumnNumber
- The column number in the table (one-based).StandardException
- Thrown on errorRowOrdering.orderedOnColumn(int, int, int, int)
public void addOrderedColumn(int direction, int tableNumber, int columnNumber)
RowOrdering
addOrderedColumn
in interface RowOrdering
direction
- One of ASCENDING, DESCENDING, or DONTCARE.
DONTCARE can be used for things like columns
with constant value, and for one-row tables.tableNumber
- The table the column is in.columnNumber
- The column number in the table (one-based)RowOrdering.addOrderedColumn(int, int, int)
public void nextOrderPosition(int direction)
RowOrdering
nextOrderPosition
in interface RowOrdering
direction
- One of ASCENDING, DESCENDING, or DONTCARE.
DONTCARE can be used for things like columns
with constant value, and for one-row tables.RowOrdering.nextOrderPosition(int)
public void optimizableAlwaysOrdered(Optimizable optimizable)
RowOrdering
optimizableAlwaysOrdered
in interface RowOrdering
optimizable
- The table in questionpublic void columnAlwaysOrdered(Optimizable optimizable, int columnNumber)
RowOrdering
columnAlwaysOrdered
in interface RowOrdering
optimizable
- The table in questioncolumnNumber
- The number of the column in question.RowOrdering.columnAlwaysOrdered(org.apache.derby.iapi.sql.compile.Optimizable, int)
public boolean alwaysOrdered(int tableNumber)
RowOrdering
alwaysOrdered
in interface RowOrdering
RowOrdering.alwaysOrdered(int)
public void removeOptimizable(int tableNumber)
RowOrdering
removeOptimizable
in interface RowOrdering
tableNumber
- The number of the table to remove from
this RowOrdering.RowOrdering.removeOptimizable(int)
private void removeOptimizable(int tableNumber, java.util.ArrayList<Optimizable> list)
public void addUnorderedOptimizable(Optimizable optimizable)
RowOrdering
addUnorderedOptimizable
in interface RowOrdering
RowOrdering.addUnorderedOptimizable(org.apache.derby.iapi.sql.compile.Optimizable)
public void copy(RowOrdering copyTo)
RowOrdering
copy
in interface RowOrdering
RowOrdering.copy(org.apache.derby.iapi.sql.compile.RowOrdering)
private void rememberCurrentColumnOrdering(int posn)
public java.lang.String toString()
toString
in class java.lang.Object
private boolean unorderedOptimizablesOtherThan(Optimizable optimizable)
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.