Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import ai.timefold.solver.core.api.score.stream.bi.BiConstraintCollector;
import ai.timefold.solver.core.config.solver.EnvironmentMode;
import ai.timefold.solver.core.impl.bavet.common.AbstractGroupNode;
import ai.timefold.solver.core.impl.bavet.common.tuple.AbstractTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.BiTuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.Tuple;
import ai.timefold.solver.core.impl.bavet.common.tuple.TupleLifecycle;

abstract class AbstractGroupBiNode<OldA, OldB, OutTuple_ extends AbstractTuple, GroupKey_, ResultContainer_, Result_>
abstract class AbstractGroupBiNode<OldA, OldB, OutTuple_ extends Tuple, GroupKey_, ResultContainer_, Result_>
extends AbstractGroupNode<BiTuple<OldA, OldB>, OutTuple_, GroupKey_, ResultContainer_, Result_> {

private final TriFunction<ResultContainer_, OldA, OldB, Runnable> accumulator;
Expand All @@ -37,7 +37,7 @@ protected AbstractGroupBiNode(int groupStoreIndex,

@Override
protected final Runnable accumulate(ResultContainer_ resultContainer, BiTuple<OldA, OldB> tuple) {
return accumulator.apply(resultContainer, tuple.factA, tuple.factB);
return accumulator.apply(resultContainer, tuple.getA(), tuple.getB());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ public ConcatBiBiNode(TupleLifecycle<BiTuple<A, B>> nextNodesTupleLifecycle,

@Override
protected BiTuple<A, B> getOutTupleFromLeft(BiTuple<A, B> leftTuple) {
return new BiTuple<>(leftTuple.factA, leftTuple.factB, outputStoreSize);
return BiTuple.of(leftTuple.getA(), leftTuple.getB(), outputStoreSize);
}

@Override
protected BiTuple<A, B> getOutTupleFromRight(BiTuple<A, B> rightTuple) {
return new BiTuple<>(rightTuple.factA, rightTuple.factB, outputStoreSize);
return BiTuple.of(rightTuple.getA(), rightTuple.getB(), outputStoreSize);
}

@Override
protected void updateOutTupleFromLeft(BiTuple<A, B> leftTuple, BiTuple<A, B> outTuple) {
outTuple.factA = leftTuple.factA;
outTuple.factB = leftTuple.factB;
outTuple.setA(leftTuple.getA());
outTuple.setB(leftTuple.getB());
}

@Override
protected void updateOutTupleFromRight(BiTuple<A, B> rightTuple, BiTuple<A, B> outTuple) {
outTuple.factA = rightTuple.factA;
outTuple.factB = rightTuple.factB;
outTuple.setA(rightTuple.getA());
outTuple.setB(rightTuple.getB());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ public ConcatBiUniNode(Function<A, B> paddingFunction, TupleLifecycle<BiTuple<A,

@Override
protected BiTuple<A, B> getOutTupleFromLeft(BiTuple<A, B> leftTuple) {
return new BiTuple<>(leftTuple.factA, leftTuple.factB, outputStoreSize);
return BiTuple.of(leftTuple.getA(), leftTuple.getB(), outputStoreSize);
}

@Override
protected BiTuple<A, B> getOutTupleFromRight(UniTuple<A> rightTuple) {
var factA = rightTuple.factA;
return new BiTuple<>(factA, paddingFunction.apply(factA), outputStoreSize);
var factA = rightTuple.getA();
return BiTuple.of(factA, paddingFunction.apply(factA), outputStoreSize);
}

@Override
protected void updateOutTupleFromLeft(BiTuple<A, B> leftTuple, BiTuple<A, B> outTuple) {
outTuple.factA = leftTuple.factA;
outTuple.factB = leftTuple.factB;
outTuple.setA(leftTuple.getA());
outTuple.setB(leftTuple.getB());
}

@Override
protected void updateOutTupleFromRight(UniTuple<A> rightTuple, BiTuple<A, B> outTuple) {
outTuple.factA = rightTuple.factA;
outTuple.setA(rightTuple.getA());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ public ConcatUniBiNode(Function<A, B> paddingFunction, TupleLifecycle<BiTuple<A,

@Override
protected BiTuple<A, B> getOutTupleFromLeft(UniTuple<A> leftTuple) {
var factA = leftTuple.factA;
return new BiTuple<>(factA, paddingFunction.apply(factA), outputStoreSize);
var factA = leftTuple.getA();
return BiTuple.of(factA, paddingFunction.apply(factA), outputStoreSize);
}

@Override
protected BiTuple<A, B> getOutTupleFromRight(BiTuple<A, B> rightTuple) {
return new BiTuple<>(rightTuple.factA, rightTuple.factB, outputStoreSize);
return BiTuple.of(rightTuple.getA(), rightTuple.getB(), outputStoreSize);
}

@Override
protected void updateOutTupleFromLeft(UniTuple<A> leftTuple, BiTuple<A, B> outTuple) {
outTuple.factA = leftTuple.factA;
outTuple.setA(leftTuple.getA());
}

@Override
protected void updateOutTupleFromRight(BiTuple<A, B> rightTuple, BiTuple<A, B> outTuple) {
outTuple.factA = rightTuple.factA;
outTuple.factB = rightTuple.factB;
outTuple.setA(rightTuple.getA());
outTuple.setB(rightTuple.getB());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public FlattenLastBiNode(int flattenLastStoreIndex, Function<B, Iterable<NewB>>

@Override
protected BiTuple<A, NewB> createTuple(BiTuple<A, B> originalTuple, NewB newB) {
return new BiTuple<>(originalTuple.factA, newB, outputStoreSize);
return BiTuple.of(originalTuple.getA(), newB, outputStoreSize);
}

@Override
protected B getEffectiveFactIn(BiTuple<A, B> tuple) {
return tuple.factB;
return tuple.getB();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public Group0Mapping1CollectorBiNode(int groupStoreIndex, int undoStoreIndex,

@Override
protected UniTuple<A> createOutTuple(Void groupKey) {
return new UniTuple<>(null, outputStoreSize);
return UniTuple.of(outputStoreSize);
}

@Override
protected void updateOutTupleToResult(UniTuple<A> outTuple, A a) {
outTuple.factA = a;
outTuple.setA(a);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ BiConstraintCollector<OldA, OldB, Object, Pair<A, B>> mergeCollectors(

@Override
protected BiTuple<A, B> createOutTuple(Void groupKey) {
return new BiTuple<>(null, null, outputStoreSize);
return BiTuple.of(outputStoreSize);
}

@Override
protected void updateOutTupleToResult(BiTuple<A, B> outTuple, Pair<A, B> result) {
outTuple.factA = result.key();
outTuple.factB = result.value();
outTuple.setA(result.key());
outTuple.setB(result.value());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ BiConstraintCollector<OldA, OldB, Object, Triple<A, B, C>> mergeCollectors(

@Override
protected TriTuple<A, B, C> createOutTuple(Void groupKey) {
return new TriTuple<>(null, null, null, outputStoreSize);
return TriTuple.of(outputStoreSize);
}

@Override
protected void updateOutTupleToResult(TriTuple<A, B, C> outTuple, Triple<A, B, C> result) {
outTuple.factA = result.a();
outTuple.factB = result.b();
outTuple.factC = result.c();
outTuple.setA(result.a());
outTuple.setB(result.b());
outTuple.setC(result.c());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ BiConstraintCollector<OldA, OldB, Object, Quadruple<A, B, C, D>> mergeCollectors

@Override
protected QuadTuple<A, B, C, D> createOutTuple(Void groupKey) {
return new QuadTuple<>(null, null, null, null, outputStoreSize);
return QuadTuple.of(outputStoreSize);
}

@Override
protected void updateOutTupleToResult(QuadTuple<A, B, C, D> outTuple, Quadruple<A, B, C, D> result) {
outTuple.factA = result.a();
outTuple.factB = result.b();
outTuple.factC = result.c();
outTuple.factD = result.d();
outTuple.setA(result.a());
outTuple.setB(result.b());
outTuple.setC(result.c());
outTuple.setD(result.d());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public Group1Mapping0CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMapping,
}

static <A, OldA, OldB> A createGroupKey(BiFunction<OldA, OldB, A> groupKeyMapping, BiTuple<OldA, OldB> tuple) {
return groupKeyMapping.apply(tuple.factA, tuple.factB);
return groupKeyMapping.apply(tuple.getA(), tuple.getB());
}

@Override
protected UniTuple<A> createOutTuple(A a) {
return new UniTuple<>(a, outputStoreSize);
return UniTuple.of(a, outputStoreSize);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public Group1Mapping1CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMapping,

@Override
protected BiTuple<A, B> createOutTuple(A a) {
return new BiTuple<>(a, null, outputStoreSize);
return BiTuple.of(a, outputStoreSize);
}

@Override
protected void updateOutTupleToResult(BiTuple<A, B> outTuple, B b) {
outTuple.factB = b;
outTuple.setB(b);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ public Group1Mapping2CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMapping,

@Override
protected TriTuple<A, B, C> createOutTuple(A a) {
return new TriTuple<>(a, null, null, outputStoreSize);
return TriTuple.of(a, outputStoreSize);
}

@Override
protected void updateOutTupleToResult(TriTuple<A, B, C> outTuple, Pair<B, C> result) {
outTuple.factB = result.key();
outTuple.factC = result.value();
outTuple.setB(result.key());
outTuple.setC(result.value());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public Group1Mapping3CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMapping,

@Override
protected QuadTuple<A, B, C, D> createOutTuple(A a) {
return new QuadTuple<>(a, null, null, null, outputStoreSize);
return QuadTuple.of(a, outputStoreSize);
}

@Override
protected void updateOutTupleToResult(QuadTuple<A, B, C, D> outTuple, Triple<B, C, D> result) {
outTuple.factB = result.a();
outTuple.factC = result.b();
outTuple.factD = result.c();
outTuple.setB(result.a());
outTuple.setC(result.b());
outTuple.setD(result.c());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ public Group2Mapping0CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMappingA,

static <A, B, OldA, OldB> Pair<A, B> createGroupKey(BiFunction<OldA, OldB, A> groupKeyMappingA,
BiFunction<OldA, OldB, B> groupKeyMappingB, BiTuple<OldA, OldB> tuple) {
OldA oldA = tuple.factA;
OldB oldB = tuple.factB;
A a = groupKeyMappingA.apply(oldA, oldB);
B b = groupKeyMappingB.apply(oldA, oldB);
return new Pair<>(a, b);
var oldA = tuple.getA();
var oldB = tuple.getB();
return new Pair<>(groupKeyMappingA.apply(oldA, oldB), groupKeyMappingB.apply(oldA, oldB));
}

@Override
protected BiTuple<A, B> createOutTuple(Pair<A, B> groupKey) {
return new BiTuple<>(groupKey.key(), groupKey.value(), outputStoreSize);
return BiTuple.of(groupKey.key(), groupKey.value(), outputStoreSize);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public Group2Mapping1CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMappingA,

@Override
protected TriTuple<A, B, C> createOutTuple(Pair<A, B> groupKey) {
return new TriTuple<>(groupKey.key(), groupKey.value(), null, outputStoreSize);
return TriTuple.of(groupKey.key(), groupKey.value(), outputStoreSize);
}

@Override
protected void updateOutTupleToResult(TriTuple<A, B, C> outTuple, C c) {
outTuple.factC = c;
outTuple.setC(c);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ public Group2Mapping2CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMappingA,

@Override
protected QuadTuple<A, B, C, D> createOutTuple(Pair<A, B> groupKey) {
return new QuadTuple<>(groupKey.key(), groupKey.value(), null, null, outputStoreSize);
return QuadTuple.of(groupKey.key(), groupKey.value(), outputStoreSize);
}

@Override
protected void updateOutTupleToResult(QuadTuple<A, B, C, D> outTuple, Pair<C, D> result) {
outTuple.factC = result.key();
outTuple.factD = result.value();
outTuple.setC(result.key());
outTuple.setD(result.value());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@ public Group3Mapping0CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMappingA,
static <A, B, C, OldA, OldB> Triple<A, B, C> createGroupKey(BiFunction<OldA, OldB, A> groupKeyMappingA,
BiFunction<OldA, OldB, B> groupKeyMappingB, BiFunction<OldA, OldB, C> groupKeyMappingC,
BiTuple<OldA, OldB> tuple) {
OldA oldA = tuple.factA;
OldB oldB = tuple.factB;
A a = groupKeyMappingA.apply(oldA, oldB);
B b = groupKeyMappingB.apply(oldA, oldB);
C c = groupKeyMappingC.apply(oldA, oldB);
return new Triple<>(a, b, c);
var oldA = tuple.getA();
var oldB = tuple.getB();
return new Triple<>(groupKeyMappingA.apply(oldA, oldB), groupKeyMappingB.apply(oldA, oldB),
groupKeyMappingC.apply(oldA, oldB));
}

@Override
protected TriTuple<A, B, C> createOutTuple(Triple<A, B, C> groupKey) {
return new TriTuple<>(groupKey.a(), groupKey.b(), groupKey.c(), outputStoreSize);
return TriTuple.of(groupKey.a(), groupKey.b(), groupKey.c(), outputStoreSize);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public Group3Mapping1CollectorBiNode(BiFunction<OldA, OldB, A> groupKeyMappingA,

@Override
protected QuadTuple<A, B, C, D> createOutTuple(Triple<A, B, C> groupKey) {
return new QuadTuple<>(groupKey.a(), groupKey.b(), groupKey.c(), null, outputStoreSize);
return QuadTuple.of(groupKey.a(), groupKey.b(), groupKey.c(), outputStoreSize);
}

@Override
protected void updateOutTupleToResult(QuadTuple<A, B, C, D> outTuple, D d) {
outTuple.factD = d;
outTuple.setD(d);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@ private static <A, B, C, D, OldA, OldB> Quadruple<A, B, C, D> createGroupKey(
BiFunction<OldA, OldB, A> groupKeyMappingA, BiFunction<OldA, OldB, B> groupKeyMappingB,
BiFunction<OldA, OldB, C> groupKeyMappingC, BiFunction<OldA, OldB, D> groupKeyMappingD,
BiTuple<OldA, OldB> tuple) {
OldA oldA = tuple.factA;
OldB oldB = tuple.factB;
A a = groupKeyMappingA.apply(oldA, oldB);
B b = groupKeyMappingB.apply(oldA, oldB);
C c = groupKeyMappingC.apply(oldA, oldB);
D d = groupKeyMappingD.apply(oldA, oldB);
return new Quadruple<>(a, b, c, d);
var oldA = tuple.getA();
var oldB = tuple.getB();
return new Quadruple<>(groupKeyMappingA.apply(oldA, oldB), groupKeyMappingB.apply(oldA, oldB),
groupKeyMappingC.apply(oldA, oldB), groupKeyMappingD.apply(oldA, oldB));
}

@Override
protected QuadTuple<A, B, C, D> createOutTuple(Quadruple<A, B, C, D> groupKey) {
return new QuadTuple<>(groupKey.a(), groupKey.b(), groupKey.c(), groupKey.d(), outputStoreSize);
return QuadTuple.of(groupKey.a(), groupKey.b(), groupKey.c(), groupKey.d(), outputStoreSize);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public IndexedIfExistsBiNode(boolean shouldExist, IndexerFactory<C> indexerFacto

@Override
protected boolean testFiltering(BiTuple<A, B> leftTuple, UniTuple<C> rightTuple) {
return filtering.test(leftTuple.factA, leftTuple.factB, rightTuple.factA);
return filtering.test(leftTuple.getA(), leftTuple.getB(), rightTuple.getA());
}

}
Loading
Loading