mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-27 14:30:14 +00:00
Extend VolmLib storage hunks
- Make StorageHunk, ArrayHunk, AtomicHunk, SynchronizedArrayHunk, AtomicDoubleHunk, AtomicIntegerHunk and AtomicLongHunk extend their VolmLib counterparts and only bind the Iris Hunk interface - Drop the Lombok data, equals and hashCode generation the duplicated storage hunks carried - Ship the VolmLib storage hunks by removing their unusedVolmLibClasses entries
This commit is contained in:
1 parent
355d7f4132
commit
3551614088
8 files changed
+8
-219
No files matched your search
@@ -332,11 +332,6 @@ List<String> unusedVolmLibClasses = [
|
|||||||
'art/arcane/volmlib/util/board/BoardUpdateTask',
|
'art/arcane/volmlib/util/board/BoardUpdateTask',
|
||||||
'art/arcane/volmlib/util/bukkit/Placeholders',
|
'art/arcane/volmlib/util/bukkit/Placeholders',
|
||||||
'art/arcane/volmlib/util/hunk/HunkFactory',
|
'art/arcane/volmlib/util/hunk/HunkFactory',
|
||||||
'art/arcane/volmlib/util/hunk/storage/ArrayHunk',
|
|
||||||
'art/arcane/volmlib/util/hunk/storage/AtomicDoubleHunk',
|
|
||||||
'art/arcane/volmlib/util/hunk/storage/AtomicIntegerHunk',
|
|
||||||
'art/arcane/volmlib/util/hunk/storage/AtomicLongHunk',
|
|
||||||
'art/arcane/volmlib/util/hunk/storage/SynchronizedArrayHunk',
|
|
||||||
'art/arcane/volmlib/util/hunk/view/BiomeForceBridge',
|
'art/arcane/volmlib/util/hunk/view/BiomeForceBridge',
|
||||||
'art/arcane/volmlib/util/hunk/view/BiomeGridForceSupport',
|
'art/arcane/volmlib/util/hunk/view/BiomeGridForceSupport',
|
||||||
'art/arcane/volmlib/util/hunk/view/BiomeGridHunkHolder',
|
'art/arcane/volmlib/util/hunk/view/BiomeGridHunkHolder',
|
||||||
|
|||||||
@@ -18,41 +18,10 @@
|
|||||||
|
|
||||||
package art.arcane.iris.util.project.hunk.storage;
|
package art.arcane.iris.util.project.hunk.storage;
|
||||||
|
|
||||||
import art.arcane.iris.engine.data.cache.Cache;
|
|
||||||
import art.arcane.iris.util.project.hunk.Hunk;
|
import art.arcane.iris.util.project.hunk.Hunk;
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
public class ArrayHunk<T> extends art.arcane.volmlib.util.hunk.storage.ArrayHunk<T> implements Hunk<T> {
|
||||||
|
|
||||||
@SuppressWarnings("Lombok")
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class ArrayHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
|
||||||
private final T[] data;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public ArrayHunk(int w, int h, int d) {
|
public ArrayHunk(int w, int h, int d) {
|
||||||
super(w, h, d);
|
super(w, h, d);
|
||||||
data = (T[]) new Object[w * h * d];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRaw(int x, int y, int z, T t) {
|
|
||||||
data[index(x, y, z)] = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T getRaw(int x, int y, int z) {
|
|
||||||
return data[index(x, y, z)];
|
|
||||||
}
|
|
||||||
|
|
||||||
private int index(int x, int y, int z) {
|
|
||||||
return Cache.to1D(x, y, z, getWidth(), getHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fill(T t) {
|
|
||||||
Arrays.fill(data, t);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,38 +18,10 @@
|
|||||||
|
|
||||||
package art.arcane.iris.util.project.hunk.storage;
|
package art.arcane.iris.util.project.hunk.storage;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.AtomicDoubleArray;
|
|
||||||
import art.arcane.iris.util.project.hunk.Hunk;
|
import art.arcane.iris.util.project.hunk.Hunk;
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
@SuppressWarnings({"Lombok"})
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class AtomicDoubleHunk extends StorageHunk<Double> implements Hunk<Double> {
|
|
||||||
private final AtomicDoubleArray data;
|
|
||||||
|
|
||||||
|
public class AtomicDoubleHunk extends art.arcane.volmlib.util.hunk.storage.AtomicDoubleHunk implements Hunk<Double> {
|
||||||
public AtomicDoubleHunk(int w, int h, int d) {
|
public AtomicDoubleHunk(int w, int h, int d) {
|
||||||
super(w, h, d);
|
super(w, h, d);
|
||||||
data = new AtomicDoubleArray(w * h * d);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAtomic() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRaw(int x, int y, int z, Double t) {
|
|
||||||
data.set(index(x, y, z), t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Double getRaw(int x, int y, int z) {
|
|
||||||
return data.get(index(x, y, z));
|
|
||||||
}
|
|
||||||
|
|
||||||
private int index(int x, int y, int z) {
|
|
||||||
return (z * getWidth() * getHeight()) + (y * getWidth()) + x;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,44 +19,9 @@
|
|||||||
package art.arcane.iris.util.project.hunk.storage;
|
package art.arcane.iris.util.project.hunk.storage;
|
||||||
|
|
||||||
import art.arcane.iris.util.project.hunk.Hunk;
|
import art.arcane.iris.util.project.hunk.Hunk;
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
|
||||||
|
|
||||||
@SuppressWarnings({"Lombok"})
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class AtomicHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
|
||||||
private final AtomicReferenceArray<T> data;
|
|
||||||
// index() runs per block access on the hottest paths; two final-field multiplies beat
|
|
||||||
// re-deriving the strides through the accessors every call.
|
|
||||||
private final int xStride;
|
|
||||||
private final int zStride;
|
|
||||||
|
|
||||||
|
public class AtomicHunk<T> extends art.arcane.volmlib.util.hunk.storage.AtomicHunk<T> implements Hunk<T> {
|
||||||
public AtomicHunk(int w, int h, int d) {
|
public AtomicHunk(int w, int h, int d) {
|
||||||
super(w, h, d);
|
super(w, h, d);
|
||||||
data = new AtomicReferenceArray<>(w * h * d);
|
|
||||||
xStride = w;
|
|
||||||
zStride = w * h;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAtomic() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRaw(int x, int y, int z, T t) {
|
|
||||||
data.set(index(x, y, z), t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T getRaw(int x, int y, int z) {
|
|
||||||
return data.get(index(x, y, z));
|
|
||||||
}
|
|
||||||
|
|
||||||
private int index(int x, int y, int z) {
|
|
||||||
return (z * zStride) + (y * xStride) + x;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-30
@@ -19,38 +19,9 @@
|
|||||||
package art.arcane.iris.util.project.hunk.storage;
|
package art.arcane.iris.util.project.hunk.storage;
|
||||||
|
|
||||||
import art.arcane.iris.util.project.hunk.Hunk;
|
import art.arcane.iris.util.project.hunk.Hunk;
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicIntegerArray;
|
|
||||||
|
|
||||||
@SuppressWarnings({"Lombok"})
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class AtomicIntegerHunk extends StorageHunk<Integer> implements Hunk<Integer> {
|
|
||||||
private final AtomicIntegerArray data;
|
|
||||||
|
|
||||||
|
public class AtomicIntegerHunk extends art.arcane.volmlib.util.hunk.storage.AtomicIntegerHunk implements Hunk<Integer> {
|
||||||
public AtomicIntegerHunk(int w, int h, int d) {
|
public AtomicIntegerHunk(int w, int h, int d) {
|
||||||
super(w, h, d);
|
super(w, h, d);
|
||||||
data = new AtomicIntegerArray(w * h * d);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAtomic() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRaw(int x, int y, int z, Integer t) {
|
|
||||||
data.set(index(x, y, z), t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getRaw(int x, int y, int z) {
|
|
||||||
return data.get(index(x, y, z));
|
|
||||||
}
|
|
||||||
|
|
||||||
private int index(int x, int y, int z) {
|
|
||||||
return (z * getWidth() * getHeight()) + (y * getWidth()) + x;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,38 +19,9 @@
|
|||||||
package art.arcane.iris.util.project.hunk.storage;
|
package art.arcane.iris.util.project.hunk.storage;
|
||||||
|
|
||||||
import art.arcane.iris.util.project.hunk.Hunk;
|
import art.arcane.iris.util.project.hunk.Hunk;
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicLongArray;
|
|
||||||
|
|
||||||
@SuppressWarnings({"Lombok"})
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class AtomicLongHunk extends StorageHunk<Long> implements Hunk<Long> {
|
|
||||||
private final AtomicLongArray data;
|
|
||||||
|
|
||||||
|
public class AtomicLongHunk extends art.arcane.volmlib.util.hunk.storage.AtomicLongHunk implements Hunk<Long> {
|
||||||
public AtomicLongHunk(int w, int h, int d) {
|
public AtomicLongHunk(int w, int h, int d) {
|
||||||
super(w, h, d);
|
super(w, h, d);
|
||||||
data = new AtomicLongArray(w * h * d);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAtomic() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRaw(int x, int y, int z, Long t) {
|
|
||||||
data.set(index(x, y, z), t);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long getRaw(int x, int y, int z) {
|
|
||||||
return data.get(index(x, y, z));
|
|
||||||
}
|
|
||||||
|
|
||||||
private int index(int x, int y, int z) {
|
|
||||||
return (z * getWidth() * getHeight()) + (y * getWidth()) + x;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,27 +19,9 @@
|
|||||||
package art.arcane.iris.util.project.hunk.storage;
|
package art.arcane.iris.util.project.hunk.storage;
|
||||||
|
|
||||||
import art.arcane.iris.util.project.hunk.Hunk;
|
import art.arcane.iris.util.project.hunk.Hunk;
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public abstract class StorageHunk<T> implements Hunk<T> {
|
|
||||||
private final int width;
|
|
||||||
private final int height;
|
|
||||||
private final int depth;
|
|
||||||
|
|
||||||
|
public abstract class StorageHunk<T> extends art.arcane.volmlib.util.hunk.storage.StorageHunk<T> implements Hunk<T> {
|
||||||
public StorageHunk(int width, int height, int depth) {
|
public StorageHunk(int width, int height, int depth) {
|
||||||
if (width <= 0 || height <= 0 || depth <= 0) {
|
super(width, height, depth);
|
||||||
throw new RuntimeException("Unsupported size " + width + " " + height + " " + depth);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.width = width;
|
|
||||||
this.height = height;
|
|
||||||
this.depth = depth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract void setRaw(int x, int y, int z, T t);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract T getRaw(int x, int y, int z);
|
|
||||||
}
|
}
|
||||||
+1
-37
@@ -19,45 +19,9 @@
|
|||||||
package art.arcane.iris.util.project.hunk.storage;
|
package art.arcane.iris.util.project.hunk.storage;
|
||||||
|
|
||||||
import art.arcane.iris.util.project.hunk.Hunk;
|
import art.arcane.iris.util.project.hunk.Hunk;
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
public class SynchronizedArrayHunk<T> extends art.arcane.volmlib.util.hunk.storage.SynchronizedArrayHunk<T> implements Hunk<T> {
|
||||||
|
|
||||||
@SuppressWarnings({"Lombok"})
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class SynchronizedArrayHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
|
||||||
private final T[] data;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public SynchronizedArrayHunk(int w, int h, int d) {
|
public SynchronizedArrayHunk(int w, int h, int d) {
|
||||||
super(w, h, d);
|
super(w, h, d);
|
||||||
data = (T[]) new Object[w * h * d];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRaw(int x, int y, int z, T t) {
|
|
||||||
synchronized (data) {
|
|
||||||
data[index(x, y, z)] = t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T getRaw(int x, int y, int z) {
|
|
||||||
synchronized (data) {
|
|
||||||
return data[index(x, y, z)];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int index(int x, int y, int z) {
|
|
||||||
return (z * getWidth() * getHeight()) + (y * getWidth()) + x;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fill(T t) {
|
|
||||||
synchronized (data) {
|
|
||||||
Arrays.fill(data, t);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user