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

Small performance optimization

上级 07ad5271
......@@ -58,6 +58,7 @@ public abstract class Prepared {
private Command command;
private int objectId;
private int currentRowNumber;
private int rowScanCount;
/**
* Create a new object.
......@@ -343,7 +344,10 @@ public abstract class Prepared {
*
* @param rowNumber the row number
*/
protected void setCurrentRowNumber(int rowNumber) {
protected void setCurrentRowNumber(int rowNumber) throws SQLException {
if ((rowScanCount++ & 127) == 0) {
checkCanceled();
}
this.currentRowNumber = rowNumber;
}
......
......@@ -53,7 +53,6 @@ public class Delete extends Prepared {
try {
setCurrentRowNumber(0);
while (tableFilter.next()) {
checkCanceled();
setCurrentRowNumber(rows.size() + 1);
if (condition == null || Boolean.TRUE.equals(condition.getBooleanValue(session))) {
Row row = tableFilter.get();
......@@ -63,8 +62,11 @@ public class Delete extends Prepared {
rows.add(row);
}
}
int rowScanCount = 0;
for (rows.reset(); rows.hasNext();) {
checkCanceled();
if ((rowScanCount++ & 127) == 0) {
checkCanceled();
}
Row row = rows.next();
table.removeRow(session, row);
session.log(table, UndoLogRecord.DELETE, row);
......
......@@ -93,7 +93,6 @@ public class Insert extends Prepared {
}
}
}
checkCanceled();
table.fireBefore(session);
table.validateConvertUpdateSequence(session, newRow);
table.fireBeforeRow(session, null, newRow);
......@@ -110,7 +109,6 @@ public class Insert extends Prepared {
table.fireBefore(session);
table.lock(session, true, false);
while (rows.next()) {
checkCanceled();
count++;
Value[] r = rows.currentRow();
Row newRow = table.getTemplateRow();
......
......@@ -132,7 +132,6 @@ public class Merge extends Prepared {
table.fireBefore(session);
table.lock(session, true, false);
while (rows.next()) {
checkCanceled();
count++;
Value[] r = rows.currentRow();
Row newRow = table.getTemplateRow();
......
......@@ -155,7 +155,6 @@ public class Select extends Query {
setCurrentRowNumber(0);
Value[] previousKeyValues = null;
while (topTableFilter.next()) {
checkCanceled();
setCurrentRowNumber(rowNumber + 1);
if (condition == null || Boolean.TRUE.equals(condition.getBooleanValue(session))) {
rowNumber++;
......@@ -306,7 +305,6 @@ public class Select extends Query {
setCurrentRowNumber(0);
ValueArray defaultGroup = ValueArray.get(new Value[0]);
while (topTableFilter.next()) {
checkCanceled();
setCurrentRowNumber(rowNumber + 1);
if (condition == null || Boolean.TRUE.equals(condition.getBooleanValue(session))) {
Value key;
......@@ -457,7 +455,6 @@ public class Select extends Query {
SearchRow first = null;
int columnIndex = index.getColumns()[0].getColumnId();
while (true) {
checkCanceled();
setCurrentRowNumber(rowNumber + 1);
Cursor cursor = index.findNext(session, first, null);
if (!cursor.next()) {
......@@ -491,7 +488,6 @@ public class Select extends Query {
int rowNumber = 0;
setCurrentRowNumber(0);
while (topTableFilter.next()) {
checkCanceled();
setCurrentRowNumber(rowNumber + 1);
if (condition == null || Boolean.TRUE.equals(condition.getBooleanValue(session))) {
Value[] row = new Value[columnCount];
......
......@@ -85,7 +85,6 @@ public class Update extends Prepared {
setCurrentRowNumber(0);
int count = 0;
while (tableFilter.next()) {
checkCanceled();
setCurrentRowNumber(count+1);
if (condition == null || Boolean.TRUE.equals(condition.getBooleanValue(session))) {
Row oldRow = tableFilter.get();
......@@ -133,7 +132,6 @@ public class Update extends Prepared {
if (table.fireRow()) {
rows.invalidateCache();
for (rows.reset(); rows.hasNext();) {
checkCanceled();
Row o = rows.next();
Row n = rows.next();
table.fireAfterRow(session, o, n);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论