提交 9e7a31c4 authored 作者: Andrei Tokar's avatar Andrei Tokar

additional optimizations for MVRTreeMap

上级 6d79ef93
...@@ -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);
keyType.increaseBounds(bounds, key); if (!keyType.contains(bounds, key)) {
p.setKey(index, bounds); bounds = keyType.createBoundingBox(bounds);
keyType.increaseBounds(bounds, key);
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.
* *
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论