提交 7c3cbb4a authored 作者: Andrei Tokar's avatar Andrei Tokar

retract "fix" without case

change synchronize to Atomic for untilAnalyzeCounter
上级 a4ed2d4c
......@@ -219,14 +219,6 @@ public class IndexCursor implements Cursor {
}
private SearchRow getSearchRow(SearchRow row, int columnId, Value v, boolean max) {
Column column = columnId == SearchRow.ROWID_INDEX ?
table.getRowIdColumn() :
table.getColumn(columnId);
int vType = v.getType();
int resType = Value.getHigherOrder(column.getType(), vType);
if(vType != resType) {
v = column.convert(v, session.getDatabase().getMode());
}
if (row == null) {
row = table.getTemplateRow();
} else {
......
......@@ -13,6 +13,7 @@ import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.h2.api.DatabaseEventListener;
import org.h2.api.ErrorCode;
......@@ -118,7 +119,7 @@ public class MVTable extends TableBase {
*/
private final ArrayDeque<Session> waitingSessions = new ArrayDeque<>();
private final Trace traceLock;
private int changesSinceAnalyze;
private final AtomicInteger changesUnitilAnalyze;
private int nextAnalyze;
private final boolean containsLargeObject;
private Column rowIdColumn;
......@@ -129,9 +130,7 @@ public class MVTable extends TableBase {
public MVTable(CreateTableData data, MVTableEngine.Store store) {
super(data);
nextAnalyze = database.getSettings().analyzeAuto;
if(nextAnalyze <= 0) {
nextAnalyze = Integer.MAX_VALUE;
}
changesUnitilAnalyze = nextAnalyze <= 0 ? null : new AtomicInteger(nextAnalyze);
this.store = store;
this.transactionStore = store.getTransactionStore();
this.isHidden = data.isHidden;
......@@ -729,7 +728,9 @@ public class MVTable extends TableBase {
Index index = indexes.get(i);
index.truncate(session);
}
changesSinceAnalyze = 0;
if (changesUnitilAnalyze != null) {
changesUnitilAnalyze.set(nextAnalyze);
}
}
@Override
......@@ -758,17 +759,16 @@ public class MVTable extends TableBase {
}
private void analyzeIfRequired(Session session) {
synchronized (this) {
if (++changesSinceAnalyze <= nextAnalyze) {
return;
}
changesSinceAnalyze = 0;
if (changesUnitilAnalyze != null) {
if (changesUnitilAnalyze.decrementAndGet() == 0) {
if (nextAnalyze <= Integer.MAX_VALUE / 2) {
nextAnalyze *= 2;
}
}
changesUnitilAnalyze.set(nextAnalyze);
session.markTableForAnalyze(this);
}
}
}
@Override
public void checkSupportAlter() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论