Unverified 提交 30649cad authored 作者: Andrei Tokar's avatar Andrei Tokar 提交者: GitHub

Merge pull request #1460 from h2database/issue_1427

Issue 1427: performance of MVSpatialIndex construction
...@@ -271,8 +271,11 @@ public final class MVRTreeMap<V> extends MVMap<SpatialKey, V> { ...@@ -271,8 +271,11 @@ public final class MVRTreeMap<V> extends MVMap<SpatialKey, V> {
} else { } else {
result = operate(c, key, value, decisionMaker); result = operate(c, key, value, decisionMaker);
Object bounds = p.getKey(index); Object bounds = p.getKey(index);
if (!keyType.contains(bounds, key)) {
bounds = keyType.createBoundingBox(bounds);
keyType.increaseBounds(bounds, key); keyType.increaseBounds(bounds, key);
p.setKey(index, bounds); p.setKey(index, bounds);
}
p.setChild(index, c); p.setChild(index, c);
} }
} }
......
...@@ -163,8 +163,14 @@ public class SpatialDataType implements DataType { ...@@ -163,8 +163,14 @@ public class SpatialDataType implements DataType {
return; return;
} }
for (int i = 0; i < dimensions; i++) { for (int i = 0; i < dimensions; i++) {
b.setMin(i, Math.min(b.min(i), a.min(i))); float v = a.min(i);
b.setMax(i, Math.max(b.max(i), a.max(i))); if (v < b.min(i)) {
b.setMin(i, v);
}
v = a.max(i);
if (v > b.max(i)) {
b.setMax(i, v);
}
} }
} }
...@@ -287,12 +293,7 @@ public class SpatialDataType implements DataType { ...@@ -287,12 +293,7 @@ public class SpatialDataType implements DataType {
if (a.isNull()) { if (a.isNull()) {
return a; return a;
} }
float[] minMax = new float[dimensions * 2]; return new SpatialKey(0, a);
for (int i = 0; i < dimensions; i++) {
minMax[i + i] = a.min(i);
minMax[i + i + 1] = a.max(i);
}
return new SpatialKey(0, minMax);
} }
/** /**
......
...@@ -26,6 +26,11 @@ public class SpatialKey { ...@@ -26,6 +26,11 @@ public class SpatialKey {
this.minMax = minMax; this.minMax = minMax;
} }
public SpatialKey(long id, SpatialKey other) {
this.id = id;
this.minMax = other.minMax.clone();
}
/** /**
* Get the minimum value for the given dimension. * Get the minimum value for the given dimension.
* *
......
...@@ -449,7 +449,10 @@ public class TransactionStore { ...@@ -449,7 +449,10 @@ public class TransactionStore {
if (map != null) { // might be null if map was removed later if (map != null) { // might be null if map was removed later
Object key = op[1]; Object key = op[1];
commitDecisionMaker.setUndoKey(undoKey); commitDecisionMaker.setUndoKey(undoKey);
map.operate(key, null, commitDecisionMaker); // although second parameter (value) is not really used
// by CommitDecisionMaker, MVRTreeMap has weird traversal logic based on it,
// and any non-null value will do, to signify update, not removal
map.operate(key, VersionedValue.DUMMY, commitDecisionMaker);
} }
} }
undoLog.clear(); undoLog.clear();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论