提交 4867529d authored 作者: Noel Grandin's avatar Noel Grandin

javadoc update

上级 8722b796
......@@ -114,6 +114,9 @@ public class Select extends Query {
private int[] groupByCopies;
/**
* Whether this query contains aggregate functions.
*/
boolean isGroupQuery;
private boolean isGroupSortedQuery;
private boolean isWindowQuery;
......@@ -194,6 +197,12 @@ public class Select extends Query {
return group;
}
/**
* Get the group data if there is currently a group-by active.
*
* @param window is this a window function
* @return the grouped data
*/
public SelectGroups getGroupDataIfCurrent(boolean window) {
return groupData != null && (window || groupData.isCurrentGroup()) ? groupData : null;
}
......@@ -471,6 +480,12 @@ public class Select extends Query {
groupData.done();
}
/**
* Update any aggregate expressions with the query stage.
* @param columnCount number of columns
* @param stage stage of query (window or normal)
*/
void updateAgg(int columnCount, int stage) {
for (int i = 0; i < columnCount; i++) {
if ((groupByExpression == null || !groupByExpression[i])
......
......@@ -40,6 +40,12 @@ public abstract class Expression {
private boolean addedToFilter;
/**
* Get the SQL snippet for a list of expressions.
*
* @param builder the builder to append the SQL to
* @param expressions the list of expressions
*/
public static void writeExpressions(StringBuilder builder, List<? extends Expression> expressions) {
for (int i = 0, length = expressions.size(); i < length; i++) {
if (i > 0) {
......@@ -49,6 +55,12 @@ public abstract class Expression {
}
}
/**
* Get the SQL snippet for an array of expressions.
*
* @param builder the builder to append the SQL to
* @param expressions the list of expressions
*/
public static void writeExpressions(StringBuilder builder, Expression[] expressions) {
for (int i = 0, length = expressions.length; i < length; i++) {
if (i > 0) {
......
......@@ -271,6 +271,12 @@ public class ExpressionVisitor {
columns1.add(column);
}
/**
* Add a new column to the set of columns.
* This is used for GET_COLUMNS2 visitors.
*
* @param column the additional column.
*/
void addColumn2(Column column) {
if (table == null || table == column.getTable()) {
columns2.add(column);
......@@ -367,6 +373,7 @@ public class ExpressionVisitor {
* Get the set of columns of all tables.
*
* @param filters the filters
* @param allColumnsSet the on-demand all-columns set
*/
public static void allColumnsForTableFilters(TableFilter[] filters, AllColumnsForPlan allColumnsSet) {
for (TableFilter filter : filters) {
......
......@@ -25,8 +25,14 @@ import org.h2.value.Value;
*/
public abstract class AbstractAggregate extends DataAnalysisOperation {
/**
* is this a DISTINCT aggregate
*/
protected final boolean distinct;
/**
* FILTER condition for aggregate/window
*/
protected Expression filterCondition;
AbstractAggregate(Select select, boolean distinct) {
......
......@@ -44,14 +44,31 @@ public abstract class DataAnalysisOperation extends Expression {
*/
public static final int STAGE_WINDOW = 2;
/**
* SELECT
*/
protected final Select select;
/**
* Window clause / OVER
*/
protected Window over;
/**
* Sort order for OVER
*/
protected SortOrder overOrderBySort;
private int lastGroupRowId;
/**
* Create sort order.
*
* @param session database session
* @param orderBy array of order by expressions
* @param offset index offset
* @return the SortOrder
*/
protected static SortOrder createOrder(Session session, ArrayList<SelectOrderBy> orderBy, int offset) {
int size = orderBy.size();
int[] index = new int[size];
......@@ -111,6 +128,13 @@ public abstract class DataAnalysisOperation extends Expression {
mapColumnsAnalysis(resolver, level, state);
}
/**
* Map the columns of the resolver to expression columns.
*
* @param resolver the column resolver
* @param level the subquery nesting level
* @param innerState one of the Expression MAP_IN_* values
*/
protected void mapColumnsAnalysis(ColumnResolver resolver, int level, int innerState) {
if (over != null) {
over.mapColumns(resolver, level);
......@@ -173,6 +197,13 @@ public abstract class DataAnalysisOperation extends Expression {
updateAggregate(session, groupData, groupRowId);
}
/**
* Update a row of an aggregate.
*
* @param session the database session
* @param groupData data for the aggregate group
* @param groupRowId row id of group
*/
protected abstract void updateAggregate(Session session, SelectGroups groupData, int groupRowId);
/**
......@@ -207,6 +238,14 @@ public abstract class DataAnalysisOperation extends Expression {
*/
protected abstract void rememberExpressions(Session session, Value[] array);
/**
* Get the aggregate data for a window clause.
*
* @param session database session
* @param groupData aggregate group data
* @param forOrderBy true if this is for ORDER BY
* @return the aggregate data object, specific to each kind of aggregate.
*/
protected Object getWindowData(Session session, SelectGroups groupData, boolean forOrderBy) {
Object data;
Value key = over.getCurrentKey(session);
......@@ -220,6 +259,13 @@ public abstract class DataAnalysisOperation extends Expression {
return data;
}
/**
* Get the aggregate group data object from the collector object.
* @param groupData the collector object
* @param ifExists if true, return null if object not found,
* if false, return new object if nothing found
* @return group data object
*/
protected Object getGroupData(SelectGroups groupData, boolean ifExists) {
Object data;
data = groupData.getCurrentGroupExprData(this);
......@@ -233,6 +279,11 @@ public abstract class DataAnalysisOperation extends Expression {
return data;
}
/**
* Create aggregate data object specific to the subclass.
*
* @return aggregate-specific data object.
*/
protected abstract Object createAggregateData();
@Override
......@@ -316,6 +367,14 @@ public abstract class DataAnalysisOperation extends Expression {
*/
protected abstract Value getAggregatedValue(Session session, Object aggregateData);
/**
* Update a row of an ordered aggregate.
*
* @param session the database session
* @param groupData data for the aggregate group
* @param groupRowId row id of group
* @param orderBy list of order by expressions
*/
protected void updateOrderedAggregate(Session session, SelectGroups groupData, int groupRowId,
ArrayList<SelectOrderBy> orderBy) {
int ne = getNumExpressions();
......@@ -352,6 +411,8 @@ public abstract class DataAnalysisOperation extends Expression {
}
/**
* Returns result of this window function or window aggregate.
*
* @param session
* the session
* @param result
......@@ -364,6 +425,12 @@ public abstract class DataAnalysisOperation extends Expression {
protected abstract void getOrderedResultLoop(Session session, HashMap<Integer, Value> result,
ArrayList<Value[]> ordered, int rowIdColumn);
/**
* Used to create SQL for the OVER part of the command.
*
* @param builder string builder
* @return the builder object
*/
protected StringBuilder appendTailConditions(StringBuilder builder) {
if (over != null) {
builder.append(' ');
......
......@@ -1167,6 +1167,13 @@ public class Function extends Expression implements FunctionCall {
return v;
}
/**
* Return the resulting value for the given expression arguments.
*
* @param session the session
* @param args argument expressions
* @return the result
*/
protected Value getValueWithArgs(Session session, Expression[] args) {
Value[] values = new Value[args.length];
if (info.nullIfParameterIsNull) {
......
......@@ -493,6 +493,9 @@ public class CacheLongKeyLIRS<V> {
}
}
/**
* Loop through segments, trimming the non resident queue.
*/
public void trimNonResidentQueue() {
for (Segment<V> s : segments) {
synchronized (s) {
......
......@@ -209,6 +209,12 @@ public class MVPrimaryIndex extends BaseIndex {
}
}
/**
* Lock a set of rows.
*
* @param session database session
* @param rowsForUpdate rows to lock
*/
void lockRows(Session session, Iterable<Row> rowsForUpdate) {
TransactionMap<Value, Value> map = getMap(session);
for (Row row : rowsForUpdate) {
......@@ -217,6 +223,13 @@ public class MVPrimaryIndex extends BaseIndex {
}
}
/**
* Lock a single row.
*
* @param session database session
* @param row to lock
* @return row object if it exists
*/
Row lockRow(Session session, Row row) {
TransactionMap<Value, Value> map = getMap(session);
long key = row.getKey();
......@@ -273,7 +286,7 @@ public class MVPrimaryIndex extends BaseIndex {
return getRow(session, key, (ValueArray) v);
}
public Row getRow(Session session, long key, ValueArray array) {
private Row getRow(Session session, long key, ValueArray array) {
Row row = session.createRow(array.getList(), 0);
row.setKey(key);
return row;
......
......@@ -97,6 +97,12 @@ public class MVTableEngine implements TableEngine {
return store;
}
/**
* Convert password from byte[] to char[].
*
* @param key password as byte[]
* @return password as char[].
*/
static char[] decodePassword(byte[] key) {
char[] password = new char[key.length / 2];
for (int i = 0; i < password.length; i++) {
......@@ -210,6 +216,12 @@ public class MVTableEngine implements TableEngine {
return transactionStore;
}
/**
* Get MVTable by table name.
*
* @param tableName table name
* @return MVTable
*/
public MVTable getTable(String tableName) {
return tableMap.get(tableName);
}
......
......@@ -179,7 +179,7 @@ public class TransactionStore {
assert committed || getTransactionId(lastUndoKey) == transactionId;
long logId = lastUndoKey == null ? 0 : getLogId(lastUndoKey) + 1;
registerTransaction(transactionId, status, name, logId, timeoutMillis, 0,
RollbackListener.NONE);
ROLLBACK_LISTENER_NONE);
continue;
}
}
......@@ -307,7 +307,7 @@ public class TransactionStore {
* @return the transaction
*/
public Transaction begin() {
return begin(RollbackListener.NONE, timeoutMillis, 0);
return begin(ROLLBACK_LISTENER_NONE, timeoutMillis, 0);
}
/**
......@@ -387,6 +387,7 @@ public class TransactionStore {
* @param transactionId id of the transaction
* @param logId sequential number of the log record within transaction
* @param undoLogRecord Object[mapId, key, previousValue]
* @return undo key
*/
long addUndoLogRecord(int transactionId, long logId, Object[] undoLogRecord) {
MVMap<Long, Object[]> undoLog = undoLogs[transactionId];
......@@ -582,6 +583,12 @@ public class TransactionStore {
return true;
}
/**
* Get Transaction object for a transaction id.
*
* @param transactionId id for an open transaction
* @return Transaction object.
*/
Transaction getTransaction(int transactionId) {
return transactions.get(transactionId);
}
......@@ -711,14 +718,6 @@ public class TransactionStore {
*/
public interface RollbackListener {
RollbackListener NONE = new RollbackListener() {
@Override
public void onRollback(MVMap<Object, VersionedValue> map, Object key,
VersionedValue existingValue, VersionedValue restoredValue) {
// do nothing
}
};
/**
* Notified of a single map change (add/update/remove)
* @param map modified
......@@ -730,6 +729,14 @@ public class TransactionStore {
VersionedValue existingValue, VersionedValue restoredValue);
}
private static RollbackListener ROLLBACK_LISTENER_NONE = new RollbackListener() {
@Override
public void onRollback(MVMap<Object, VersionedValue> map, Object key,
VersionedValue existingValue, VersionedValue restoredValue) {
// do nothing
}
};
/**
* A data type that contains an array of objects with the specified data
* types.
......
......@@ -22,6 +22,11 @@ class VersionedValueCommitted extends VersionedValue {
this.value = value;
}
/**
* Either cast to VersionedValue, or wrap in VersionedValueCommitted
* @param value the object to cast/wrap
* @return VersionedValue instance
*/
static VersionedValue getInstance(Object value) {
assert value != null;
return value instanceof VersionedValue ? (VersionedValue) value : new VersionedValueCommitted(value);
......
......@@ -23,6 +23,14 @@ class VersionedValueUncommitted extends VersionedValueCommitted {
this.committedValue = committedValue;
}
/**
* Create new VersionedValueUncommitted.
*
* @param operationId combined log/transaction id
* @param value value before commit
* @param committedValue value after commit
* @return VersionedValue instance
*/
static VersionedValue getInstance(long operationId, Object value, Object committedValue) {
return new VersionedValueUncommitted(operationId, value, committedValue);
}
......
......@@ -328,7 +328,8 @@ public class IntervalUtils {
return ValueInterval.from(qualifier, negative, leading, remaining);
}
private static ValueInterval parseInterval2(IntervalQualifier qualifier, String s, char ch, int max, boolean negative) {
private static ValueInterval parseInterval2(IntervalQualifier qualifier, String s,
char ch, int max, boolean negative) {
long leading;
long remaining;
int dash = s.indexOf(ch, 1);
......
......@@ -13,6 +13,9 @@ package org.h2.value;
*/
public class VersionedValue {
/**
* Used when we don't care about a VersionedValue instance.
*/
public static final VersionedValue DUMMY = new VersionedValue();
protected VersionedValue() {}
......
......@@ -805,4 +805,4 @@ queryparser tokenized freeze factorings recompilation unenclosed rfe dsync
econd irst bcef ordinality nord unnest
analyst occupation distributive josaph aor engineer sajeewa isuru randil kevin doctor businessman artist ashan
corrupts splitted disruption unintentional octets preconditions predicates subq objectweb insn opcodes
preserves masking holder unboxing avert iae
preserves masking holder unboxing avert iae transformed
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论