Package eu.admire.dispel.graph

Examples of eu.admire.dispel.graph.LiteralValuesNode


            setArrayIndices(instance.getExpressions());
            break;
        case SEQUENCE:
        {
            SequenceStrategy sequence = (SequenceStrategy)strategy;
            LiteralValuesNode node = new LiteralValuesNode();
            node.setOutputDescriptor(sequence.getSType(), sequence.getDType());
            node.addAll(sequence.getExpressions());
            mConnection = node.getOutput();
            break;
        }
        case OUTPUT:
        {
            ConnectionStrategy connection = (ConnectionStrategy)strategy;
            if (connection.mConnectionVar != null)
            {
                if (connection.mConnectionVar.getType() == PrimitiveType.STREAM)
                {
                    LiteralValuesNode node = new LiteralValuesNode();
                    Object value = connection.mConnectionVar.getValue(
                            connection.mArrayIndices);
                    node.addAll((List<Object>)value);
                    mConnection = node.getOutput();
                   
                }
                else
                {
                    mConnection = (Connection)connection.mConnectionVar.getValue(
                            connection.mArrayIndices);
                }
            }
            else
            {
                Object value;
                Variable variable =
                    mExecutionState.getVariables().get(connection.mPE);
                if (variable == null)
                {
                    throw new UnresolvedVariableException(connection.mPE);
                }
                value = variable.getValue(connection.mArrayIndices);
                if (value instanceof RequestNode)
                {
                    RequestNode node = (RequestNode)value;
                    mConnection = node.getOutput(connection.mName, connection.mIndex.intValue());
                }
                else
                {
                    throw new TypeMismatchException("ProcessingElement", value);
                }
            }
            break;
        }
        case INPUT:
        {
            ConnectionStrategy connection = (ConnectionStrategy)strategy;
            if (connection.mConnectionVar != null)
            {
                Connection c = (Connection) connection.mConnectionVar.getValue(connection.mArrayIndices);
                if (c == null ||
                        !(c.getSource() instanceof LiteralValuesNode &&
                                mConnection.getSource() instanceof LiteralValuesNode))
                {
                    connection.mConnectionVar.setValue(mConnection, connection.mArrayIndices);
                }
                else
                {
                    LiteralValuesNode literal = (LiteralValuesNode) c.getSource();
                    LiteralValuesNode current = (LiteralValuesNode) mConnection.getSource();
                    literal.add(current.getValues());
                }
            }
            else
            {
                Object value;
                Variable variable =
                    mExecutionState.getVariables().get(connection.mPE);
                if (variable == null)
                {
                    throw new UnresolvedVariableException(connection.mPE);
                }
                value = variable.getValue(connection.mArrayIndices);
                if (value instanceof RequestNode)
                {
                    RequestNode node = (RequestNode)value;
                    if (node.getAllInputs().containsKey(connection.mName))
                    {
                        Connection c = node.getAllInputs().get(connection.mName).get(connection.mIndex);
                        if (c != null && c.getSource() instanceof LiteralValuesNode
                                && mConnection.getSource() instanceof LiteralValuesNode)
                        {
                            LiteralValuesNode literal = (LiteralValuesNode) c.getSource();
                            LiteralValuesNode current = (LiteralValuesNode) mConnection.getSource();
                            literal.add(current.getValues());
                        }
                        else
                        {
                            node.connectInput(connection.mName, connection.mIndex.intValue(), mConnection);
                        }
View Full Code Here


        Graph graph = builder.getSubmittedGraphs().iterator().next();
        for (RequestNode requestNode : graph.getNodes())
        {
            if (requestNode instanceof LiteralValuesNode)
            {
                LiteralValuesNode literal = (LiteralValuesNode)requestNode;
                ProcessingElementOutputDescriptor outputDesc =
                    literal.getOutputDescriptor();
                assertTrue(outputDesc.getSType() instanceof ListSType);
                SType childType = ((ListSType)outputDesc.getSType()).getChildType();
                assertTrue(childType instanceof TupleSType);
                Map<String, SType> elements = ((TupleSType)childType).getElements();
                SType t = elements.get("i");
                assertTrue(t instanceof PrimitiveSType);
                assertEquals("Element i has wrong SType,", "Integer", ((PrimitiveSType)t).getName());
                t = elements.get("s");
                assertTrue(t instanceof PrimitiveSType);
                assertEquals("Element s has wrong SType,", "String", ((PrimitiveSType)t).getName());
                List<Object> values = literal.getValues();
                assertEquals("Wrong number of literal values,", 2, values.size());
                assertEquals(ListMarker.BEGIN, values.get(0));
                assertEquals(ListMarker.END, values.get(1));
            }
        }
View Full Code Here

        ProcessingElementDescriptor descriptor =
            new SimpleProcessingElementDescriptor(inputs, outputs, null);
        project.setDescriptor(descriptor);

        // columns that are mapped
        LiteralValuesNode columnNames = new LiteralValuesNode();
        // projection expressions
        LiteralValuesNode expressions = new LiteralValuesNode();
        expressions.add(ListMarker.BEGIN);
        columnNames.add(ListMarker.BEGIN);
        for (Entry<String, DType> element : sourceTuple.getElements().entrySet())
        {
            DType targetType = targetTuple.getElements().get(element.getKey());
            if (TypeUtilities.isEqual(element.getValue(), targetType))
            {
                // no conversion required
                continue;
            }
            else
            {
                // look up the projection expression
                String proj = mConverter.getProjection(element.getValue(), targetType);
                if (proj == null)
                {
                    throw new TypeIncompatibleException(
                            "No arithmetic project expression found for DType conversion from "
                            + element.getValue() + " to " + targetType);
                }
                // replace ? with the tuple column name
                String expression = proj.replaceAll("\\?", element.getKey());
                // map the column using the expression
                columnNames.add(element.getKey());
                expressions.add(expression);
            }
        }
        expressions.add(ListMarker.END);
        columnNames.add(ListMarker.END);
        project.connectInput("expressions", 0, expressions.getOutput());
        project.connectInput("columnNames", 0, columnNames.getOutput());
        composite.add(expressions);
        composite.add(columnNames);
        composite.add(project);
        return project;
View Full Code Here

            runDISPEL("Connection c; " +
                    "|- [ <s= { 1, 2, 3} > ] -| => c; ");
        assertNull(mError);
        Variable c = builder.getDispelExecutionState().getVariables().get("c");
        Connection connection = (Connection)c.getValue();
        LiteralValuesNode literal =
            (LiteralValuesNode)connection.getSource();
        List<Object> values = literal.getValues();
        assertEquals(ListMarker.BEGIN, values.get(0));
        assertTrue(values.get(1) instanceof Map);
        Map<String, Object> tuple = (Map<String, Object>) values.get(1);
        Object element = tuple.get("s");
        assertTrue(element instanceof List);
View Full Code Here

           
        // convert using arithmetic project
        ProcessingElementNode project =
            new ProcessingElementNode(TUPLE_ARITHMETIC_PROJECT);
        composite.add(project);
        LiteralValuesNode expressions = new LiteralValuesNode();
        composite.add(expressions);
        LiteralValuesNode resultNames = new LiteralValuesNode();
        composite.add(resultNames);
        String proj = mConverter.getProjection(
                sourceOutput.getDType(),
                targetInput.getDType());
        if (proj == null)
        {
            throw new TypeIncompatibleException(
                    "No arithmetic project expression found for DType conversion from "
                    + sourceOutput.getDType() + " to " + targetInput.getDType());
        }
        // replace ? with the name of the tuple column to form the
        // arithmetic project expression
        String expression = proj.replaceAll("\\?", sourceOutput.getName());
        expressions.add(ListMarker.BEGIN);
        expressions.add(expression);
        expressions.add(ListMarker.END);
        resultNames.add(ListMarker.BEGIN);
        resultNames.add(sourceOutput.getName());
        resultNames.add(ListMarker.END);
        project.connectInput("expressions", 0, expressions.getOutput());
        project.connectInput("resultColumnNames", 0, resultNames.getOutput());
        CompositeProcessingElement wrapper =
            new CompositeProcessingElement(
                    null,
                    composite);
        wrapper.setInput("input", 0, project.getInput("data", 0));
View Full Code Here

//        System.out.println(GraphConverter.convertToDISPEL(graph));
    }

    public void testSimpleSequenceLiteral()
    {
        LiteralValuesNode literal = new LiteralValuesNode("x", "y", "<a href=\".\"/>", 1, 2);
        ProcessingElementNode a = new ProcessingElementNode("eu.admire.A");
        a.connectInput("in", 0, literal.getOutput());
        Graph graph = new Graph();
        graph.add(a);
        graph.add(literal);
//        System.out.println(GraphConverter.convertToDISPEL(graph));
    }
View Full Code Here

//        System.out.println(GraphConverter.convertToDISPEL(graph));
    }
  
    public void testListLiteral()
    {
        LiteralValuesNode literal =
            new LiteralValuesNode(
                    ListMarker.BEGIN, "x", "y", ListMarker.END,
                    ListMarker.BEGIN, 1, 2, ListMarker.END);
        ProcessingElementNode a = new ProcessingElementNode("eu.admire.A");
        a.connectInput("in", 0, literal.getOutput());
        Graph graph = new Graph();
        graph.add(a);
        graph.add(literal);
//        System.out.println(GraphConverter.convertToDISPEL(graph));
    }
View Full Code Here

//        System.out.println(GraphConverter.convertToDISPEL(graph));
    }

    public void testNestedListLiteral()
    {
        LiteralValuesNode literal =
            new LiteralValuesNode(
                    ListMarker.BEGIN,
                    ListMarker.BEGIN, "x", "y", ListMarker.END,
                    ListMarker.BEGIN, 1, 2, ListMarker.END,
                    ListMarker.END,
                    ListMarker.BEGIN,
                    ListMarker.BEGIN, 0, 1, 2.3, ListMarker.END,
                    ListMarker.END
                    );
        ProcessingElementNode a = new ProcessingElementNode("eu.admire.A");
        a.connectInput("in", 0, literal.getOutput());
        Graph graph = new Graph();
        graph.add(a);
        graph.add(literal);
//        System.out.println(GraphConverter.convertToDISPEL(graph));
    }
View Full Code Here

                pe.getProcessingElementDescriptor();
            result = descriptor.getOutput(outputName);
        }
        else if (node instanceof LiteralValuesNode)
        {
            LiteralValuesNode literal = (LiteralValuesNode)node;
            result = literal.getOutputDescriptor();
        }
        return result;
    }
View Full Code Here

    public void testLiteral() throws Exception
    {
        Graph graph = new Graph();
        ProcessingElementNode nodeA = new ProcessingElementNode("uk.org.ogsadai.SQLQuery");
        graph.add(nodeA);
        LiteralValuesNode nodeB = new LiteralValuesNode(1, 2, 3);
        graph.add(nodeB);
        LiteralValuesNode nodeC = new LiteralValuesNode(
                ListMarker.BEGIN,
                "this is a string that is too long",
                "another very long string that doesn't fit",
                "and a \\\"string\\\" with quotes",
                ListMarker.END,
                ListMarker.BEGIN,
                new Repeater(null, Arrays.asList(ListMarker.BEGIN, "X", "Y", 2, ListMarker.END)),
                ListMarker.END);
        graph.add(nodeC);
        nodeA.connectInput("in1", 0, nodeB.getOutput());
        nodeA.connectInput("in2", 0, nodeC.getOutput());
        String dot = DotGenerator.generate(graph);
//        writeFile(dot);
        System.out.println(dot);
    }
View Full Code Here

TOP

Related Classes of eu.admire.dispel.graph.LiteralValuesNode

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.