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

org.optaplanner.constraint.streams.bavet.quad.JoinQuadNode 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.quad;

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

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.tri.TriTuple;
import org.optaplanner.constraint.streams.bavet.uni.UniTuple;
import org.optaplanner.core.api.function.TriFunction;

final class JoinQuadNode
        extends AbstractJoinNode, D, QuadTuple, QuadTupleImpl> {

    private final TriFunction mappingABC;
    private final int outputStoreSize;

    public JoinQuadNode(TriFunction mappingABC, Function mappingD,
            int inputStoreIndexAB, int inputStoreIndexC,
            TupleLifecycle> nextNodesTupleLifecycle,
            int outputStoreSize,
            Indexer, Map, QuadTupleImpl>> indexerABC,
            Indexer, Map, QuadTupleImpl>> indexerD) {
        super(mappingD, inputStoreIndexAB, inputStoreIndexC, nextNodesTupleLifecycle, indexerABC, indexerD);
        this.mappingABC = mappingABC;
        this.outputStoreSize = outputStoreSize;
    }

    @Override
    protected IndexProperties createIndexPropertiesLeft(TriTuple leftTuple) {
        return mappingABC.apply(leftTuple.getFactA(), leftTuple.getFactB(), leftTuple.getFactC());
    }

    @Override
    protected void updateOutTupleLeft(QuadTupleImpl outTuple, TriTuple leftTuple) {
        outTuple.factA = leftTuple.getFactA();
        outTuple.factB = leftTuple.getFactB();
        outTuple.factC = leftTuple.getFactC();
    }

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

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

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

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy