提交 c940fbb4 authored 作者: Thomas Mueller's avatar Thomas Mueller

Small improvements.

上级 aa455b32
......@@ -300,7 +300,7 @@ public abstract class Expression {
/**
* If this expression consists of column expressions it should return them.
*
*
* @return array of expression columns if applicable, null otherwise
*/
public Expression[] getExpressionColumns(Session session) {
......@@ -309,7 +309,7 @@ public abstract class Expression {
/**
* Extracts expression columns from ValueArray
*
*
* @param session the current session
* @param value the value to extract columns from
* @return array of expression columns
......@@ -317,7 +317,7 @@ public abstract class Expression {
public static Expression[] getExpressionColumns(Session session, ValueArray value) {
Value[] list = value.getList();
ExpressionColumn[] expr = new ExpressionColumn[list.length];
for (int i = 0; i < list.length; i++) {
for (int i = 0, len = list.length; i < len; i++) {
Value v = list[i];
Column col = new Column("C" + (i + 1), v.getType(), v.getPrecision(), v.getScale(),
v.getDisplaySize());
......@@ -327,11 +327,11 @@ public abstract class Expression {
}
/**
* Extracts expression columns from the given result set.
*
* Extracts expression columns from the given result set.
*
* @param session the session
* @param rs the result set
* @return an array of expression columns
* @return an array of expression columns
* @throws SQLException
*/
public static Expression[] getExpressionColumns(Session session, ResultSet rs) throws SQLException {
......
......@@ -99,16 +99,17 @@ public class JavaAggregate extends Expression {
}
public void mapColumns(ColumnResolver resolver, int level) {
for (int i = 0; i < args.length; i++) {
args[i].mapColumns(resolver, level);
for (Expression arg : args) {
arg.mapColumns(resolver, level);
}
}
public Expression optimize(Session session) {
userConnection = session.createConnection(false);
argTypes = new int[args.length];
int[] argSqlTypes = new int[args.length];
for (int i = 0; i < args.length; i++) {
int len = args.length;
argTypes = new int[len];
int[] argSqlTypes = new int[len];
for (int i = 0; i < len; i++) {
Expression expr = args[i];
args[i] = expr.optimize(session);
int type = expr.getType();
......@@ -178,7 +179,7 @@ public class JavaAggregate extends Expression {
}
Object[] argValues = new Object[args.length];
Object arg = null;
for (int i = 0; i < args.length; i++) {
for (int i = 0, len = args.length; i < len; i++) {
Value v = args[i].getValue(session);
v = v.convertTo(argTypes[i]);
arg = v.getObject();
......
......@@ -53,7 +53,7 @@ public class JavaFunction extends Expression implements FunctionCall {
public Expression optimize(Session session) {
boolean allConst = isDeterministic();
for (int i = 0; i < args.length; i++) {
for (int i = 0, len = args.length; i < len; i++) {
Expression e = args[i].optimize(session);
args[i] = e;
allConst &= e.isConstant();
......@@ -160,9 +160,9 @@ public class JavaFunction extends Expression implements FunctionCall {
public Expression[] getExpressionColumns(Session session) {
switch (getType()) {
case Value.RESULT_SET:
ValueResultSet vrs = getValueForColumnList(session, getArgs());
ValueResultSet rs = getValueForColumnList(session, getArgs());
try {
return getExpressionColumns(session, vrs.getResultSet());
return getExpressionColumns(session, rs.getResultSet());
} catch (SQLException e) {
throw DbException.convert(e);
}
......
......@@ -96,14 +96,14 @@ public class Subquery extends Expression {
private Expression getExpression() {
if (expression == null) {
ArrayList<Expression> exprs = query.getExpressions();
ArrayList<Expression> expressions = query.getExpressions();
int columnCount = query.getColumnCount();
if (columnCount == 1) {
expression = exprs.get(0);
expression = expressions.get(0);
} else {
Expression[] list = new Expression[columnCount];
for (int i = 0; i < columnCount; i++) {
list[i] = exprs.get(i);
list[i] = expressions.get(i);
}
expression = new ExpressionList(list);
}
......
......@@ -961,8 +961,7 @@ public class FullText {
private int[] getWordIds(Object[] row) throws SQLException {
HashSet<String> words = New.hashSet();
for (int i = 0; i < index.indexColumns.length; i++) {
int idx = index.indexColumns[i];
for (int idx : index.indexColumns) {
int type = columnTypes[idx];
Object data = row[idx];
if (type == Types.CLOB && data != null) {
......
......@@ -430,8 +430,9 @@ public class FullTextLucene extends FullText {
if (limit == 0) {
limit = docs.totalHits;
}
for (int i = 0; i < limit && i + offset < docs.totalHits
&& i + offset < docs.scoreDocs.length; i++) {
for (int i = 0, len = docs.scoreDocs.length;
i < limit && i + offset < docs.totalHits
&& i + offset < len; i++) {
ScoreDoc sd = docs.scoreDocs[i + offset];
Document doc = searcher.doc(sd.doc);
float score = sd.score;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论