Package com.asakusafw.vocabulary.flow.graph

Examples of com.asakusafw.vocabulary.flow.graph.FlowElement


        assert stageModels != null;
        LOG.debug("出力を解析しています({})", graph.getOutput());

        List<Export> results = Lists.create();
        for (FlowBlock.Input target : graph.getOutput().getBlockInputs()) {
            FlowElement element = target.getElementPort().getOwner();
            FlowElementDescription desc = element.getDescription();
            if (desc.getKind() != FlowElementKind.OUTPUT) {
                error("{0}は出力を表現していません", desc);
                continue;
            }
            OutputDescription description = (OutputDescription) desc;
View Full Code Here


        assert elements != null;
        LOG.debug("シャッフルへの各セグメントを分析しています");

        List<ShuffleModel.Segment> segments = Lists.create();
        for (int elementId = 0, n = elements.size(); elementId < n; elementId++) {
            FlowElement element = elements.get(elementId);
            FlowElementDescription description = element.getDescription();
            RendezvousProcessor proc = environment.getProcessors()
                .findRendezvousProcessor(description);
            if (proc == null) {
                error("{0}に対する{1}が見つかりませんでした",
                        description,
                        FlowElementProcessor.class.getName());
                continue;
            }

            List<ShuffleModel.Segment> segmentsInElement = Lists.create();
            LOG.debug("{}は{}を使ってシャッフルの情報を分析します", element, proc);
            for (FlowElementInput input : element.getInputPorts()) {
                ShuffleDescription desc = extractDescription(proc, input);
                ShuffleModel.Segment segment = resolveDescription(
                        elementId,
                        segments.size() + segmentsInElement.size() + 1,
                        input,
View Full Code Here

        List<FlowElement> results = Lists.create();
        Set<FlowElement> saw = Sets.create();
        for (FlowBlock reducer : reduceBlocks) {
            for (FlowBlock.Input input : reducer.getBlockInputs()) {
                FlowElement rendezvous = input.getElementPort().getOwner();
                if (saw.contains(rendezvous)) {
                    continue;
                }
                LOG.debug("{}の{}は待ち合わせ要素です", reducer, rendezvous);
                saw.add(rendezvous);
View Full Code Here

     * 指定の名前を有する要素を返す。
     * @param name 対象の名前
     * @return 発見した要素
     */
    public FlowElement get(String name) {
        FlowElement found = elements.get(name);
        if (found == null) {
            throw new AssertionError(name + elements.keySet());
        }
        return found;
    }
View Full Code Here

     * 指定の名前を有する要素を返す。
     * @param name 対象の名前
     * @return 発見した要素
     */
    public FlowElementDescription desc(String name) {
        FlowElement found = elements.get(name);
        if (found == null) {
            throw new AssertionError(name + elements.keySet());
        }
        return found.getDescription();
    }
View Full Code Here

        Matcher matcher = PORT.matcher(spec);
        if (matcher.matches() == false) {
            throw new AssertionError(spec);
        }
        String elementName = matcher.group(1);
        FlowElement element = elements.get(elementName);
        if (element == null) {
            throw new AssertionError(elementName + elements.keySet());
        }

        String portName = matcher.group(3);
        if (portName == null) {
            if (element.getInputPorts().size() != 1) {
                throw new AssertionError(element.getInputPorts());
            }
            return element.getInputPorts().get(0);
        }

        FlowElementInput port = null;
        for (FlowElementInput finding : element.getInputPorts()) {
            if (portName.equals(finding.getDescription().getName())) {
                port = finding;
                break;
            }
        }
View Full Code Here

        Matcher matcher = PORT.matcher(spec);
        if (matcher.matches() == false) {
            throw new AssertionError(spec);
        }
        String elementName = matcher.group(1);
        FlowElement element = elements.get(elementName);
        if (element == null) {
            throw new AssertionError(elementName + elements.keySet());
        }

        String portName = matcher.group(3);
        if (portName == null) {
            if (element.getOutputPorts().size() != 1) {
                throw new AssertionError(element.getOutputPorts());
            }
            return element.getOutputPorts().get(0);
        }

        FlowElementOutput port = null;
        for (FlowElementOutput finding : element.getOutputPorts()) {
            if (portName.equals(finding.getDescription().getName())) {
                port = finding;
                break;
            }
        }
View Full Code Here

        }
        return port;
    }

    private FlowElement register(String name, FlowElementDescription desc) {
        FlowElement element = new FlowElement(desc);
        return register(name, element);
    }
View Full Code Here

        MockOut<CharSequence> out = new MockOut<CharSequence>(CharSequence.class, "out");
        out.add(op);

        FlowElementOutput port = op.toOutputPort();
        FlowElement element = port.getOwner();
        OperatorDescription desc = (OperatorDescription) element.getDescription();
        List<Parameter> params = desc.getParameters();
        assertThat(params.size(), is(1));
        assertThat(params.get(0).getName(), is("param"));
        assertThat(params.get(0).getType(), is((Type) int.class));
        assertThat(params.get(0).getValue(), is((Object) 5));
View Full Code Here

        Map<FlowElementInput, FlowElementInput> unifiedInputs = Maps.create();
        Map<FlowElementOutput, FlowElementOutput> unifiedOutputs = Maps.create();

        // find originals
        for (Map.Entry<FlowElement, FlowElement> entry : elementMapping.entrySet()) {
            FlowElement orig = entry.getKey();
            FlowElement dest = entry.getValue();
            assert orig.getIdentity().equals(orig.getIdentity());
            FlowElement unified;
            if (unifier.containsKey(orig.getIdentity()) == false) {
                unified = dest;
                unifier.put(orig.getIdentity(), unified);
            else {
                unified = unifier.get(orig.getIdentity());
                LOG.debug("Unify {} -> {}", dest, unified);
            }
            unifiedElements.put(dest, unified);
            List<FlowElementInput> srcInput = orig.getInputPorts();
            List<FlowElementInput> dstInput = dest.getInputPorts();
            List<FlowElementInput> uniInput = unified.getInputPorts();
            assert srcInput.size() == uniInput.size();
            for (int i = 0, n = srcInput.size(); i < n; i++) {
                if (inputMapping.containsKey(srcInput.get(i))) {
                    inputMapping.put(srcInput.get(i), uniInput.get(i));
                    unifiedInputs.put(dstInput.get(i), uniInput.get(i));
                }
            }
            List<FlowElementOutput> srcOutput = orig.getOutputPorts();
            List<FlowElementOutput> dstOutput = dest.getOutputPorts();
            List<FlowElementOutput> uniOutput = unified.getOutputPorts();
            assert srcOutput.size() == uniOutput.size();
            for (int i = 0, n = srcOutput.size(); i < n; i++) {
                if (outputMapping.containsKey(srcOutput.get(i))) {
                    outputMapping.put(srcOutput.get(i), uniOutput.get(i));
                    unifiedOutputs.put(dstOutput.get(i), uniOutput.get(i));
                }
            }
        }

        // reconnect inputs
        for (Map.Entry<FlowElement, FlowElement> entry : elementMapping.entrySet()) {
            FlowElement elem = entry.getValue();
            FlowElement unified = unifiedElements.get(elem);
            assert unified != null;
            if (elem != unified) {
                List<FlowElementInput> srcInput = elem.getInputPorts();
                List<FlowElementInput> uniInput = unified.getInputPorts();
                assert srcInput.size() == uniInput.size();
                for (int i = 0, n = srcInput.size(); i < n; i++) {
                    FlowElementInput srcPort = srcInput.get(i);
                    FlowElementInput uniPort = uniInput.get(i);
                    for (PortConnection conn : srcPort.getConnected()) {
                        FlowElementOutput opposite = unifiedOutputs.get(conn.getUpstream());
                        assert opposite != null;
                        PortConnection.connect(opposite, uniPort);
                    }
                    srcPort.disconnectAll();
                }
            }
        }

        // reconnect outputs
        for (FlowElement elem : elementMapping.values()) {
            FlowElement unified = unifiedElements.get(elem);
            assert unified != null;
            if (elem != unified) {
                List<FlowElementOutput> srcOutput = elem.getOutputPorts();
                List<FlowElementOutput> uniOutput = unified.getOutputPorts();
                assert srcOutput.size() == uniOutput.size();
                for (int i = 0, n = srcOutput.size(); i < n; i++) {
                    FlowElementOutput srcPort = srcOutput.get(i);
                    FlowElementOutput uniPort = uniOutput.get(i);
                    for (PortConnection conn : srcPort.getConnected()) {
                        FlowElementInput opposite = unifiedInputs.get(conn.getDownstream());
                        assert opposite != null;
                        PortConnection.connect(uniPort, opposite);
                    }
                    srcPort.disconnectAll();
                }
            }
        }

        // delete unified
        for (Map.Entry<FlowElement, FlowElement> entry : elementMapping.entrySet()) {
            FlowElement elem = entry.getValue();
            FlowElement unified = unifiedElements.get(elem);
            assert unified != null;
            entry.setValue(unified);
        }

        this.elements = Sets.from(elementMapping.values());
View Full Code Here

TOP

Related Classes of com.asakusafw.vocabulary.flow.graph.FlowElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.