Package com.asakusafw.compiler.flow

Examples of com.asakusafw.compiler.flow.FlowGraphGenerator


    /**
     * {@link FlowBlock#compaction()}
     */
    @Test
    public void compaction_deadIn() {
        FlowGraphGenerator gen = new FlowGraphGenerator();
        gen.defineInput("in1");
        gen.defineInput("in2");
        gen.defineOperator("op1", "in1 in2", "out1 out2");
        gen.defineOutput("out1");
        gen.defineOutput("out2");
        gen.connect("in1", "op1.in1").connect("op1.out1", "out1");
        gen.connect("in2", "op1.in2").connect("op1.out2", "out2");
        FlowBlock bin = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                new ArrayList<FlowElementInput>(gen.inputs()),
                Arrays.asList(gen.output("in1"), gen.output("in2")),
                gen.getAsSet("in1", "in2"));
        FlowBlock b1 = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                Arrays.asList(gen.input("op1.in1"), gen.input("op1.in2")),
                Arrays.asList(gen.output("op1.out1"), gen.output("op1.out2")),
                gen.getAsSet("op1"));
        FlowBlock bout = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                Arrays.asList(gen.input("out1"), gen.input("out2")),
                new ArrayList<FlowElementOutput>(gen.outputs()),
                gen.getAsSet("out1", "out2"));
        FlowBlock.connect(bin.getBlockOutputs().get(0), b1.getBlockInputs().get(0));
        FlowBlock.connect(b1.getBlockOutputs().get(0), bout.getBlockInputs().get(0));
        FlowBlock.connect(b1.getBlockOutputs().get(1), bout.getBlockInputs().get(1));
        bin.detach();
        b1.detach();
View Full Code Here


    /**
     * {@link FlowBlock#compaction()}
     */
    @Test
    public void compaction_deadOut() {
        FlowGraphGenerator gen = new FlowGraphGenerator();
        gen.defineInput("in1");
        gen.defineInput("in2");
        gen.defineOperator("op1", "in1 in2", "out1 out2");
        gen.defineOutput("out1");
        gen.defineOutput("out2");
        gen.connect("in1", "op1.in1").connect("op1.out1", "out1");
        gen.connect("in2", "op1.in2").connect("op1.out2", "out2");
        FlowBlock bin = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                new ArrayList<FlowElementInput>(gen.inputs()),
                Arrays.asList(gen.output("in1"), gen.output("in2")),
                gen.getAsSet("in1", "in2"));
        FlowBlock b1 = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                Arrays.asList(gen.input("op1.in1"), gen.input("op1.in2")),
                Arrays.asList(gen.output("op1.out1"), gen.output("op1.out2")),
                gen.getAsSet("op1"));
        FlowBlock bout = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                Arrays.asList(gen.input("out1"), gen.input("out2")),
                new ArrayList<FlowElementOutput>(gen.outputs()),
                gen.getAsSet("out1", "out2"));
        FlowBlock.connect(bin.getBlockOutputs().get(0), b1.getBlockInputs().get(0));
        FlowBlock.connect(bin.getBlockOutputs().get(1), b1.getBlockInputs().get(1));
        FlowBlock.connect(b1.getBlockOutputs().get(0), bout.getBlockInputs().get(0));
        bin.detach();
        b1.detach();
View Full Code Here

    /**
     * {@link FlowBlock#compaction()}
     */
    @Test
    public void compaction_emptyIn() {
        FlowGraphGenerator gen = new FlowGraphGenerator();
        gen.defineInput("in1");
        gen.defineOperator("op1", "in", "out");
        gen.defineOperator("op2", "in", "out");
        gen.defineOutput("out1");
        gen.connect("in1", "op1").connect("op1", "op2").connect("op2", "out1");
        FlowBlock bin = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                new ArrayList<FlowElementInput>(gen.inputs()),
                Arrays.asList(gen.output("in1")),
                gen.getAsSet("in1"));
        FlowBlock b1 = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                Arrays.asList(gen.input("op1")),
                Arrays.asList(gen.output("op2")),
                gen.getAsSet("op1", "op2"));
        FlowBlock bout = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                Arrays.asList(gen.input("out1")),
                new ArrayList<FlowElementOutput>(gen.outputs()),
                gen.getAsSet("out1"));
        FlowBlock.connect(b1.getBlockOutputs().get(0), bout.getBlockInputs().get(0));
        bin.detach();
        b1.detach();
        bout.detach();

View Full Code Here

    /**
     * {@link FlowBlock#compaction()}
     */
    @Test
    public void compaction_stopOut() {
        FlowGraphGenerator gen = new FlowGraphGenerator();
        gen.defineInput("in1");
        gen.defineOperator("op1", "in", "out");
        gen.defineOperator("op2", "in", "out");
        gen.defineOutput("out1");
        gen.connect("in1", "op1").connect("op1", "op2").connect("op2", "out1");
        FlowBlock bin = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                new ArrayList<FlowElementInput>(gen.inputs()),
                Arrays.asList(gen.output("in1")),
                gen.getAsSet("in1"));
        FlowBlock b1 = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                Arrays.asList(gen.input("op1")),
                Arrays.asList(gen.output("op2")),
                gen.getAsSet("op1", "op2"));
        FlowBlock bout = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                Arrays.asList(gen.input("out1")),
                new ArrayList<FlowElementOutput>(gen.outputs()),
                gen.getAsSet("out1"));
        FlowBlock.connect(bin.getBlockOutputs().get(0), b1.getBlockInputs().get(0));
        bin.detach();
        b1.detach();
        bout.detach();

View Full Code Here

    /**
     * {@link FlowBlock#compaction()}
     */
    @Test
    public void compaction_mandatoryStop() {
        FlowGraphGenerator gen = new FlowGraphGenerator();
        gen.defineInput("in1");
        gen.defineOperator("op1", "in", "out");
        gen.defineOperator("op2", "in", "out", ObservationCount.AT_LEAST_ONCE);
        gen.defineOutput("out1");
        gen.connect("in1", "op1").connect("op1", "op2").connect("op2", "out1");
        FlowBlock bin = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                new ArrayList<FlowElementInput>(gen.inputs()),
                Arrays.asList(gen.output("in1")),
                gen.getAsSet("in1"));
        FlowBlock b1 = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                Arrays.asList(gen.input("op1")),
                Arrays.asList(gen.output("op2")),
                gen.getAsSet("op1", "op2"));
        FlowBlock bout = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                Arrays.asList(gen.input("out1")),
                new ArrayList<FlowElementOutput>(gen.outputs()),
                gen.getAsSet("out1"));
        FlowBlock.connect(bin.getBlockOutputs().get(0), b1.getBlockInputs().get(0));
        bin.detach();
        b1.detach();
        bout.detach();

View Full Code Here

    /**
     * {@link FlowBlock#compaction()}
     */
    @Test
    public void compaction_stable() {
        FlowGraphGenerator gen = new FlowGraphGenerator();
        gen.defineInput("in1");
        gen.defineOperator("op1", "in", "out");
        gen.defineOperator("op2", "in", "out");
        gen.defineOutput("out1");
        gen.connect("in1", "op1").connect("op1", "op2").connect("op2", "out1");
        FlowBlock bin = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                new ArrayList<FlowElementInput>(gen.inputs()),
                Arrays.asList(gen.output("in1")),
                gen.getAsSet("in1"));
        FlowBlock b1 = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                Arrays.asList(gen.input("op1")),
                Arrays.asList(gen.output("op2")),
                gen.getAsSet("op1", "op2"));
        FlowBlock bout = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                Arrays.asList(gen.input("out1")),
                new ArrayList<FlowElementOutput>(gen.outputs()),
                gen.getAsSet("out1"));
        FlowBlock.connect(b1.getBlockOutputs().get(0), bout.getBlockInputs().get(0));
        FlowBlock.connect(bin.getBlockOutputs().get(0), b1.getBlockInputs().get(0));
        bin.detach();
        b1.detach();
        bout.detach();
View Full Code Here

        gen.connect("empty", "op.i1");
        gen.connect("op.o1", "out");
        gen.connect("op.o2", "stop");
        FlowGraph component = gen.toGraph();

        gen = new FlowGraphGenerator();
        gen.defineInput("in");
        gen.defineOutput("out");
        gen.defineFlowPart("c", component);
        gen.connect("in", "c.in");
        gen.connect("c.out", "out");
View Full Code Here

    /**
     * {@link FlowGraphUtil#inlineFlowPart(FlowElement, FlowElementAttribute...)}
     */
    @Test
    public void inlineFlowPart() {
        FlowGraphGenerator cgen = new FlowGraphGenerator();
        cgen.defineInput("in");
        cgen.defineOutput("out");
        cgen.defineOperator("op", "in", "out");
        cgen.connect("in", "op.in");
        cgen.connect("op.out", "out");
        FlowGraph component = cgen.toGraph();

        gen = new FlowGraphGenerator();
        gen.defineInput("in");
        gen.defineOutput("out");
        FlowElement fc = gen.defineFlowPart("c", component);
        gen.connect("in", "c.in");
        gen.connect("c.out", "out");

        FlowGraphUtil.inlineFlowPart(fc);

        Graph<FlowElement> graph = FlowGraphUtil.toElementGraph(gen.toGraph());

        assertThat(graph.contains(gen.get("c")), is(false));
        Set<FlowElement> path = Graphs.collectAllConnected(graph, gen.getAsSet("in"));
        assertThat(path, hasItems(cgen.get("op"), gen.get("out")));
        assertThat(path, not(hasItem(cgen.get("in"))));
        assertThat(path, not(hasItem(cgen.get("out"))));
    }
View Full Code Here

    /**
     * {@link FlowBlock#isEmpty()}
     */
    @Test
    public void isEmpty() {
        FlowGraphGenerator gen = new FlowGraphGenerator();
        gen.defineInput("in");
        gen.defineOperator("op", "in", "out");
        gen.defineOutput("out");
        gen.connect("in", "op").connect("op", "out");

        FlowBlock block = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                new ArrayList<FlowElementInput>(gen.inputs()),
                new ArrayList<FlowElementOutput>(gen.outputs()),
                gen.getAsSet("op"));

        assertThat(block.isEmpty(), is(true));
    }
View Full Code Here

    /**
     * {@link FlowBlock#isEmpty()}
     */
    @Test
    public void isEmpty_input() {
        FlowGraphGenerator gen = new FlowGraphGenerator();
        gen.defineInput("in");
        gen.defineOperator("op", "in", "out");
        gen.defineOutput("out");
        gen.connect("in", "op").connect("op", "out");

        FlowBlock block = FlowBlock.fromPorts(
                0,
                gen.toGraph(),
                new ArrayList<FlowElementInput>(gen.inputs("op")),
                new ArrayList<FlowElementOutput>(gen.outputs()),
                gen.getAsSet("op"));

        assertThat(block.isEmpty(), is(false));
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.compiler.flow.FlowGraphGenerator

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.