Package com.hp.hpl.jena.sparql.expr.nodevalue

Examples of com.hp.hpl.jena.sparql.expr.nodevalue.NodeValueInteger


        check(extend, new TransformExtendCombine(), opExpectedString);
    }
   
    @Test public void combine_extend_02()
    {
        Op extend = OpExtend.extendDirect(OpTable.unit(), new VarExprList(Var.alloc("x"), new NodeValueInteger(1)));
        extend = OpExtend.extendDirect(extend, new VarExprList(Var.alloc("y"), new ExprVar("x")));
       
        String opExpectedString = StrUtils.strjoinNL(
                                            "(extend ((?x 1) (?y ?x))",
                                            "  (table unit))");
View Full Code Here


    }
   
    @Test public void combine_extend_03()
    {
        // Technically illegal SPARQL here but useful to validate that the optimizer doesn't do the wrong thing
        Op extend = OpExtend.extendDirect(OpTable.unit(), new VarExprList(Var.alloc("x"), new NodeValueInteger(1)));
        extend = OpExtend.extendDirect(extend, new VarExprList(Var.alloc("x"), new NodeValueInteger(2)));
       
        String opExpectedString = StrUtils.strjoinNL(
                                            "(extend ((?x 2))",
                                            "  (extend ((?x 1))",
                                            "    (table unit)))");
View Full Code Here

        check(extend, new TransformExtendCombine(), opExpectedString);
    }
       
    @Test public void combine_assign_01()
    {
        Op assign = OpAssign.assignDirect(OpTable.unit(), new VarExprList(Var.alloc("x"), new NodeValueInteger(1)));
        assign = OpAssign.assignDirect(assign, new VarExprList(Var.alloc("y"), new NodeValueInteger(2)));
       
        String opExpectedString = StrUtils.strjoinNL(
                                            "(assign ((?x 1) (?y 2))",
                                            "  (table unit))");
       
View Full Code Here

        check(assign, new TransformExtendCombine(), opExpectedString);
    }
   
    @Test public void combine_assign_02()
    {
        Op assign = OpAssign.assignDirect(OpTable.unit(), new VarExprList(Var.alloc("x"), new NodeValueInteger(1)));
        assign = OpAssign.assignDirect(assign, new VarExprList(Var.alloc("y"), new ExprVar("x")));
       
        String opExpectedString = StrUtils.strjoinNL(
                                            "(assign ((?x 1) (?y ?x))",
                                            "  (table unit))");
View Full Code Here

        check(assign, new TransformExtendCombine(), opExpectedString);
    }
   
    @Test public void combine_assign_03()
    {
        Op assign = OpAssign.assignDirect(OpTable.unit(), new VarExprList(Var.alloc("x"), new NodeValueInteger(1)));
        assign = OpAssign.assignDirect(assign, new VarExprList(Var.alloc("x"), new NodeValueInteger(2)));
       
        String opExpectedString = StrUtils.strjoinNL(
                                            "(assign ((?x 2))",
                                            "  (assign ((?x 1))",
                                            "    (table unit)))");
View Full Code Here

        //get a different result with dependencies preserved because the definition of the dependent function can change
        Expr cube = new E_Multiply(new E_Function("http://example/square", new ExprList(new ExprVar("x"))), new ExprVar("x"));
        UserDefinedFunctionFactory.getFactory().add("http://example/cube", cube, new ArrayList<Var>(cube.getVarsMentioned()));
       
        UserDefinedFunction f = (UserDefinedFunction) UserDefinedFunctionFactory.getFactory().create("http://example/cube");
        f.build("http://example/cube", new ExprList(new NodeValueInteger(2)));
       
        Expr actual = f.getActualExpr();
        NodeValue result = actual.eval(BindingFactory.create(), FunctionEnvBase.createTest());
        Assert.assertEquals(8, NodeFactory.nodeToInt(result.asNode()));
       
        //Change the definition of the function we depend on
        square = new ExprVar("x");
        UserDefinedFunctionFactory.getFactory().add("http://example/square", square, new ArrayList<Var>(square.getVarsMentioned()));
        f.build("http://example/cube", new ExprList(new NodeValueInteger(2)));
       
        actual = f.getActualExpr();
        result = actual.eval(BindingFactory.create(), FunctionEnvBase.createTest());
        Assert.assertEquals(4, NodeFactory.nodeToInt(result.asNode()));
    }
View Full Code Here

    public void test_function_expansion_02() {
        Expr e = new E_Multiply(new ExprVar("x"), new ExprVar("x"));
        UserDefinedFunctionFactory.getFactory().add("http://example/square", e, new ArrayList<Var>(e.getVarsMentioned()));
       
        UserDefinedFunction f = (UserDefinedFunction) UserDefinedFunctionFactory.getFactory().create("http://example/square");
        f.build("http://example/square", new ExprList(new NodeValueInteger(3)));
       
        Expr actual = f.getActualExpr();
        Assert.assertFalse(e.equals(actual));
        Assert.assertEquals(0, actual.getVarsMentioned().size());
        Assert.assertEquals(new E_Multiply(new NodeValueInteger(3), new NodeValueInteger(3)), actual);
    }
View Full Code Here

        defArgs.add(Var.alloc("y"));
        UserDefinedFunctionFactory.getFactory().add("http://example/square", e, defArgs);
       
        UserDefinedFunction f = (UserDefinedFunction) UserDefinedFunctionFactory.getFactory().create("http://example/square");
        ExprList args = new ExprList();
        args.add(new NodeValueInteger(3));
        args.add(new NodeValueInteger(4));
        f.build("http://example/square", args);
       
        Expr actual = f.getActualExpr();
        Assert.assertFalse(e.equals(actual));
        Assert.assertEquals(0, actual.getVarsMentioned().size());
        Assert.assertEquals(new E_Multiply(new NodeValueInteger(3), new NodeValueInteger(4)), actual);
    }
View Full Code Here

        args.add(Var.alloc("y"));
        UserDefinedFunctionFactory.getFactory().add("http://example/takeaway", takeaway, args);
       
        //Test that with preserveDependencies set to false (the default) that the definition is expanded appropriately
        ExprList numArgs = new ExprList();
        numArgs.add(new NodeValueInteger(1));
        numArgs.add(new NodeValueDouble(2.3));
        Expr test = new E_Function("http://example/takeaway", numArgs);
        UserDefinedFunctionFactory.getFactory().add("http://example/test", test, new ArrayList<Var>());
       
        UserDefinedFunctionDefinition def = UserDefinedFunctionFactory.getFactory().get("http://example/test");
View Full Code Here

        UserDefinedFunctionFactory.getFactory().add("http://example/takeaway", takeaway, args);
       
        //Test that with preserveDependencies set to false (the default) that the definition is expanded appropriately
        ExprList numArgs = new ExprList();
        numArgs.add(new NodeValueDouble(2.3));
        numArgs.add(new NodeValueInteger(1));
        Expr test = new E_Function("http://example/takeaway", numArgs);
        UserDefinedFunctionFactory.getFactory().add("http://example/test", test, new ArrayList<Var>());
       
        UserDefinedFunctionDefinition def = UserDefinedFunctionFactory.getFactory().get("http://example/test");
        Expr base = def.getBaseExpr();
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.sparql.expr.nodevalue.NodeValueInteger

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.