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

com.espertech.esper.dataflow.util.LogicalChannelUtil Maven / Gradle / Ivy

/*
 ***************************************************************************************
 *  Copyright (C) 2006 EsperTech, Inc. All rights reserved.                            *
 *  http://www.espertech.com/esper                                                     *
 *  http://www.espertech.com                                                           *
 *  ---------------------------------------------------------------------------------- *
 *  The software in this package is published under the terms of the GPL license       *
 *  a copy of which has been included with this distribution in the license.txt file.  *
 ***************************************************************************************
 */
package com.espertech.esper.dataflow.util;

import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class LogicalChannelUtil {

    public static List getBindingsConsuming(int producerOpNum, List bindings) {
        List result = new ArrayList();

        for (LogicalChannelBinding binding : bindings) {
            if (binding.getLogicalChannel().getOutputPort().getProducingOpNum() != producerOpNum) {
                continue;
            }
            result.add(binding);
        }

        return result;
    }

    public static String printChannels(List channels) {
        StringWriter writer = new StringWriter();
        writer.write("\n");
        for (LogicalChannel channel : channels) {
            writer.write(channel.toString() + "\n");
        }
        return writer.toString();
    }

    public static List getOutputPortByStreamName(Set incomingOpNums, String[] inputStreamNames, Map> compiledOutputPorts) {
        List ports = new ArrayList();
        for (int operator : incomingOpNums) {
            List opPorts = compiledOutputPorts.get(operator);
            if (opPorts != null) {  // Can be null if referring to itself
                for (LogicalChannelProducingPortCompiled opPort : opPorts) {
                    for (String streamName : inputStreamNames) {
                        if (opPort.getStreamName().equals(streamName)) {
                            ports.add(opPort);
                        }
                    }
                }
            }
        }
        return ports;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy