diff --git a/core/src/main/java/ai/timefold/solver/core/impl/score/stream/bavet/common/index/QuadKeyFunction.java b/core/src/main/java/ai/timefold/solver/core/impl/score/stream/bavet/common/index/QuadKeyFunction.java index 0315bfa857..0fa3503688 100644 --- a/core/src/main/java/ai/timefold/solver/core/impl/score/stream/bavet/common/index/QuadKeyFunction.java +++ b/core/src/main/java/ai/timefold/solver/core/impl/score/stream/bavet/common/index/QuadKeyFunction.java @@ -57,7 +57,7 @@ private Object apply2(A a, B b, C c, D d, Object oldKey) { if (oldKey == null) { return new Pair<>(subkey1, subkey2); } - return ((Pair) UniKeyFunction.extractSubkey(keyId, keyId)) + return ((Pair) UniKeyFunction.extractSubkey(keyId, oldKey)) .newIfDifferent(subkey1, subkey2); } @@ -69,7 +69,7 @@ private Object apply3(A a, B b, C c, D d, Object oldKey) { if (oldKey == null) { return new Triple<>(subkey1, subkey2, subkey3); } - return ((Triple) UniKeyFunction.extractSubkey(keyId, keyId)) + return ((Triple) UniKeyFunction.extractSubkey(keyId, oldKey)) .newIfDifferent(subkey1, subkey2, subkey3); } @@ -82,7 +82,7 @@ private Object apply4(A a, B b, C c, D d, Object oldKey) { if (oldKey == null) { return new Quadruple<>(subkey1, subkey2, subkey3, subkey4); } - return ((Quadruple) UniKeyFunction.extractSubkey(keyId, keyId)) + return ((Quadruple) UniKeyFunction.extractSubkey(keyId, oldKey)) .newIfDifferent(subkey1, subkey2, subkey3, subkey4); } @@ -93,7 +93,7 @@ private Object applyMany(A a, B b, C c, D d, Object oldKey) { result[i] = mappingFunctions[i].apply(a, b, c, d); } } else { - var oldArray = ((IndexerKey) UniKeyFunction.extractSubkey(keyId, keyId)).properties(); + var oldArray = ((IndexerKey) UniKeyFunction.extractSubkey(keyId, oldKey)).properties(); var subKeysEqual = true; for (var i = 0; i < mappingFunctionCount; i++) { var subkey = mappingFunctions[i].apply(a, b, c, d); diff --git a/core/src/main/java/ai/timefold/solver/core/impl/score/stream/bavet/common/index/TriKeyFunction.java b/core/src/main/java/ai/timefold/solver/core/impl/score/stream/bavet/common/index/TriKeyFunction.java index e47a35e0ae..51464cc65a 100644 --- a/core/src/main/java/ai/timefold/solver/core/impl/score/stream/bavet/common/index/TriKeyFunction.java +++ b/core/src/main/java/ai/timefold/solver/core/impl/score/stream/bavet/common/index/TriKeyFunction.java @@ -57,7 +57,7 @@ private Object apply2(A a, B b, C c, Object oldKey) { if (oldKey == null) { return new Pair<>(subkey1, subkey2); } - return ((Pair) UniKeyFunction.extractSubkey(keyId, keyId)) + return ((Pair) UniKeyFunction.extractSubkey(keyId, oldKey)) .newIfDifferent(subkey1, subkey2); } @@ -69,7 +69,7 @@ private Object apply3(A a, B b, C c, Object oldKey) { if (oldKey == null) { return new Triple<>(subkey1, subkey2, subkey3); } - return ((Triple) UniKeyFunction.extractSubkey(keyId, keyId)) + return ((Triple) UniKeyFunction.extractSubkey(keyId, oldKey)) .newIfDifferent(subkey1, subkey2, subkey3); } @@ -82,9 +82,8 @@ private Object apply4(A a, B b, C c, Object oldKey) { if (oldKey == null) { return new Quadruple<>(subkey1, subkey2, subkey3, subkey4); } - var oldIndexKeys = (IndexKeys) oldKey; - return ((Quadruple) oldIndexKeys.get(keyId)).newIfDifferent(subkey1, subkey2, subkey3, - subkey4); + return ((Quadruple) UniKeyFunction.extractSubkey(keyId, oldKey)) + .newIfDifferent(subkey1, subkey2, subkey3, subkey4); } private Object applyMany(A a, B b, C c, Object oldKey) { @@ -94,7 +93,7 @@ private Object applyMany(A a, B b, C c, Object oldKey) { result[i] = mappingFunctions[i].apply(a, b, c); } } else { - var oldArray = ((IndexerKey) UniKeyFunction.extractSubkey(keyId, keyId)).properties(); + var oldArray = ((IndexerKey) UniKeyFunction.extractSubkey(keyId, oldKey)).properties(); var subKeysEqual = true; for (var i = 0; i < mappingFunctionCount; i++) { var subkey = mappingFunctions[i].apply(a, b, c);