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