All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.optaplanner.constraint.streams.bavet.tri.JoinTriNode Maven / Gradle / Ivy

Go to download

OptaPlanner solves planning problems. This lightweight, embeddable planning engine implements powerful and scalable algorithms to optimize business resource scheduling and planning. This module contains implementation of Constraint streams (Bavet).

There is a newer version: 10.0.0
Show newest version
package org.optaplanner.constraint.streams.bavet.tri;

import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;

import org.optaplanner.constraint.streams.bavet.bi.BiTuple;
import org.optaplanner.constraint.streams.bavet.common.AbstractJoinNode;
import org.optaplanner.constraint.streams.bavet.common.TupleLifecycle;
import org.optaplanner.constraint.streams.bavet.common.index.IndexProperties;
import org.optaplanner.constraint.streams.bavet.common.index.Indexer;
import org.optaplanner.constraint.streams.bavet.uni.UniTuple;

final class JoinTriNode extends AbstractJoinNode, C, TriTuple, TriTupleImpl> {

    private final BiFunction mappingAB;
    private final int outputStoreSize;

    public JoinTriNode(BiFunction mappingAB, Function mappingC,
            int inputStoreIndexAB, int inputStoreIndexC,
            TupleLifecycle> nextNodesTupleLifecycle,
            int outputStoreSize,
            Indexer, Map, TriTupleImpl>> indexerAB,
            Indexer, Map, TriTupleImpl>> indexerC) {
        super(mappingC, inputStoreIndexAB, inputStoreIndexC, nextNodesTupleLifecycle, indexerAB, indexerC);
        this.mappingAB = mappingAB;
        this.outputStoreSize = outputStoreSize;
    }

    @Override
    protected IndexProperties createIndexPropertiesLeft(BiTuple leftTuple) {
        return mappingAB.apply(leftTuple.getFactA(), leftTuple.getFactB());
    }

    @Override
    protected TriTupleImpl createOutTuple(BiTuple leftTuple, UniTuple rightTuple) {
        return new TriTupleImpl<>(leftTuple.getFactA(), leftTuple.getFactB(), rightTuple.getFactA(), outputStoreSize);
    }

    @Override
    protected void updateOutTupleLeft(TriTupleImpl outTuple, BiTuple leftTuple) {
        outTuple.factA = leftTuple.getFactA();
        outTuple.factB = leftTuple.getFactB();
    }

    @Override
    protected void updateOutTupleRight(TriTupleImpl outTuple, UniTuple rightTuple) {
        outTuple.factC = rightTuple.getFactA();
    }

    @Override
    public String toString() {
        return "JoinTriNode";
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy