mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-16 23:55:23 +01:00
Indices now have a separate reindex() method because large changes to the index have to be supported.
Therefore, indices are no longer thread-safe. They don't need to be.
This commit is contained in:
parent
b7064cb102
commit
bcf35085ed
@ -102,4 +102,9 @@ public synchronized Collection<Region> queryOverlapping(
|
||||
public synchronized int size() {
|
||||
return regions.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reindex() {
|
||||
// Whoo, nothing to do, because this index is so simple
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.region.Region;
|
||||
import com.sk89q.worldguard.region.UnsupportedIntersectionException;
|
||||
import com.sk89q.worldguard.region.shapes.IndexableShape;
|
||||
import com.sk89q.worldguard.region.shapes.ShapeMBRConverter;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
@ -59,8 +60,6 @@ public synchronized void add(Region... region) {
|
||||
for (Region r : region) {
|
||||
regions.put(normalizeId(r.getId()), r);
|
||||
}
|
||||
tree = new PRTree<Region>(converter, branchFactor);
|
||||
tree.load(regions.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -69,8 +68,6 @@ public synchronized void remove(String... id) {
|
||||
for (String i : id) {
|
||||
regions.remove(normalizeId(i));
|
||||
}
|
||||
tree = new PRTree<Region>(converter, branchFactor);
|
||||
tree.load(regions.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -98,7 +95,7 @@ public synchronized Collection<Region> queryContains(
|
||||
location.getY(), location.getZ(), location.getZ());
|
||||
|
||||
for (Region region : tree.find(pointMBR)) {
|
||||
if (region.contains(location) && !result.contains(region)) {
|
||||
if (region.getShape().contains(location) && !result.contains(region)) {
|
||||
result.add(region);
|
||||
}
|
||||
}
|
||||
@ -129,4 +126,10 @@ public synchronized int size() {
|
||||
return regions.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reindex() {
|
||||
tree = new PRTree<Region>(converter, branchFactor);
|
||||
tree.load(regions.values());
|
||||
}
|
||||
|
||||
}
|
@ -35,8 +35,8 @@
|
||||
* using the method {@link Region#shouldCache()}.
|
||||
* <p>
|
||||
* Region IDs are case in-sensitive and implementations must be aware of this when
|
||||
* querying by ID. Any casing can be used when looking up an ID. Implementations must
|
||||
* be thread-safe.
|
||||
* querying by ID. Any casing can be used when looking up an ID. Implementations do NOT
|
||||
* have to be thread-safe.
|
||||
*/
|
||||
public interface RegionIndex {
|
||||
|
||||
@ -100,6 +100,9 @@ Collection<Region> queryOverlapping(
|
||||
* Add the given region to this index. If a region already known by this index is
|
||||
* attempted to be added to this index, nothing will happen. Parents of the
|
||||
* given region will not be added automatically.
|
||||
* <p>
|
||||
* After making changes, {@link #reindex()} MUST be called in order to ensure
|
||||
* maximum performance and index consistency.
|
||||
*
|
||||
* @param region the region to add
|
||||
*/
|
||||
@ -109,6 +112,9 @@ Collection<Region> queryOverlapping(
|
||||
* Remove the region with the given ID from this index. If the region being removed
|
||||
* has children, they will not be removed automatically. Their parent will also
|
||||
* not be set to null automatically.
|
||||
* <p>
|
||||
* After making changes, {@link #reindex()} MUST be called in order to ensure
|
||||
* maximum performance and index consistency.
|
||||
*
|
||||
* @param id the ID of the region to remove
|
||||
*/
|
||||
@ -118,6 +124,9 @@ Collection<Region> queryOverlapping(
|
||||
* Remove a region from this index having the exact same ID, but possibly no
|
||||
* other equal attribute. If the region being removed as children, they will not be
|
||||
* removed automatically. Their parent will also not be set to null automatically.
|
||||
* <p>
|
||||
* After making changes, {@link #reindex()} MUST be called in order to ensure
|
||||
* maximum performance and index consistency.
|
||||
*
|
||||
* @param region the region with the ID to match against
|
||||
*/
|
||||
@ -176,4 +185,10 @@ Collection<Region> queryOverlapping(
|
||||
*/
|
||||
int size();
|
||||
|
||||
/**
|
||||
* After making a series of changes, this method should be called in order to
|
||||
* perform any re-indexing activities.
|
||||
*/
|
||||
void reindex();
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user