mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 08:14:45 +00:00
Fingerprint skips scheduling knobs
- prefetchRings and persist leave the hydrology settings fingerprint, since they only choose which windows are prepared ahead and whether plans are saved - Compile checks drainage.fillEpsilon as the compiled float, rejecting values that round to 0 or overflow to infinity - DEFAULT_FINGERPRINT recaptured
This commit is contained in:
1 parent
ca431452fe
commit
408ac5e6b0
2 files changed
+30
-6
No files matched your search
@@ -508,7 +508,7 @@ public final class HydrologySettings {
|
||||
|
||||
private void requireBounds(IrisHydrology config) {
|
||||
requireWithin(prefetchRings, 0, MAX_PREFETCH_RINGS, "prefetchRings");
|
||||
requirePositive(config.getDrainage().getFillEpsilon(), "drainage.fillEpsilon");
|
||||
requirePositive(drainage.fillEpsilon(), "drainage.fillEpsilon");
|
||||
for (int index = 0; index < config.getTiers().size(); index++) {
|
||||
requireTierBounds(config.getTiers().get(index), "tiers[" + index + "]");
|
||||
}
|
||||
@@ -571,8 +571,8 @@ public final class HydrologySettings {
|
||||
}
|
||||
}
|
||||
|
||||
private static void requirePositive(double value, String field) {
|
||||
if (!(Double.isFinite(value) && value > 0D)) {
|
||||
private static void requirePositive(float value, String field) {
|
||||
if (!(Float.isFinite(value) && value > 0f)) {
|
||||
throw new IllegalArgumentException("Hydrology " + field + " must be a finite value above 0, got " + value);
|
||||
}
|
||||
}
|
||||
@@ -607,8 +607,7 @@ public final class HydrologySettings {
|
||||
}
|
||||
|
||||
private long computeFingerprint() {
|
||||
Fingerprint hash = new Fingerprint().add(seed).add(seaLevel).add(minY).add(maxY).add(enabled)
|
||||
.add(density).add(prefetchRings).add(persist);
|
||||
Fingerprint hash = new Fingerprint().add(seed).add(seaLevel).add(minY).add(maxY).add(enabled).add(density);
|
||||
addClimate(hash);
|
||||
addDrainage(hash);
|
||||
addTiers(hash);
|
||||
|
||||
+26
-1
@@ -22,6 +22,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
@@ -32,7 +33,7 @@ public class HydrologySettingsTest {
|
||||
private static final int SEA_LEVEL = 62;
|
||||
private static final int MIN_Y = -64;
|
||||
private static final int MAX_Y = 320;
|
||||
private static final long DEFAULT_FINGERPRINT = 8818472145657699942L;
|
||||
private static final long DEFAULT_FINGERPRINT = 4166234412166664615L;
|
||||
|
||||
@Test
|
||||
public void densityIsBoundedAndChangesThePlanIdentity() {
|
||||
@@ -245,6 +246,18 @@ public class HydrologySettingsTest {
|
||||
assertEquals("fingerprint must be identical in every JVM run", DEFAULT_FINGERPRINT, first);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void schedulingKnobsDoNotChangeTheFingerprint() {
|
||||
HydrologySettings eager = compile(new IrisHydrology().setPrefetchRings(4));
|
||||
HydrologySettings inMemory = compile(new IrisHydrology().setPersist(false));
|
||||
HydrologySettings both = compile(new IrisHydrology().setPrefetchRings(0).setPersist(false));
|
||||
assertEquals(4, eager.prefetchRings());
|
||||
assertFalse(inMemory.persist());
|
||||
assertEquals(DEFAULT_FINGERPRINT, eager.fingerprint());
|
||||
assertEquals(DEFAULT_FINGERPRINT, inMemory.fingerprint());
|
||||
assertEquals(DEFAULT_FINGERPRINT, both.fingerprint());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compileRejectsUnknownFluidProfile() {
|
||||
IrisHydrology config = new IrisHydrology();
|
||||
@@ -337,6 +350,18 @@ public class HydrologySettingsTest {
|
||||
assertEquals(64f, compile(densest).ponds().seeded().density(), 0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compileRejectsAFillEpsilonThatIsNotPositiveAsAFloat() {
|
||||
for (double invalid : new double[]{0D, -0.001D, 1e-50D, Double.MIN_VALUE, 1e300D, Double.NaN, Double.POSITIVE_INFINITY}) {
|
||||
IrisHydrology config = new IrisHydrology();
|
||||
config.getDrainage().setFillEpsilon(invalid);
|
||||
assertRejected(config, "drainage.fillEpsilon must be a finite value above 0");
|
||||
}
|
||||
IrisHydrology finest = new IrisHydrology();
|
||||
finest.getDrainage().setFillEpsilon(0.00001D);
|
||||
assertEquals(0.00001f, compile(finest).drainage().fillEpsilon(), 0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compileRejectsCavePoolsThatReachPastTheNeighbouringChunks() {
|
||||
IrisHydrology wide = new IrisHydrology();
|
||||
|
||||
Reference in new issue
Block a user