Package net.fortytwo.ripple.query

Examples of net.fortytwo.ripple.query.QueryEngine


        // TODO: shutDown on failure
        model = new SesameModel(sailConfig.getSail());

        StackEvaluator eval = new LazyStackEvaluator();
        QueryEngine queryEngine = new QueryEngine(model, eval, System.out, System.err);

        queryPipe = new QueryPipe(queryEngine, results);
    }
View Full Code Here


    protected QueryEngine getTestQueryEngine() throws RippleException {
        if (null == queryEngine) {
            StackEvaluator eval = new LazyEvaluatingIterator.WrappingEvaluator();
            //StackEvaluator eval = new LazyStackEvaluator();
            queryEngine = new QueryEngine(getTestModel(), eval, System.out, System.err);
        }

        return queryEngine;
    }
View Full Code Here

    protected Collection<RippleList> reduce(final InputStream from) throws RippleException {
        Collector<RippleList>
                results = new Collector<RippleList>();

        QueryEngine qe = getTestQueryEngine();

        QueryPipe actualPipe = new QueryPipe(qe, results);
        actualPipe.put(from);
        actualPipe.close();
View Full Code Here

    protected Collection<RippleList> reduce(final String from) throws RippleException {
        Collector<RippleList>
                results = new Collector<RippleList>();

        QueryEngine qe = getTestQueryEngine();

        QueryPipe actualPipe = new QueryPipe(qe, results);
        actualPipe.put(from + "\n");
        actualPipe.close();
View Full Code Here

    protected void assertReducesTo(final String from, final String... to) throws Exception {
        Collector<RippleList>
                expected = new Collector<RippleList>(),
                actual = new Collector<RippleList>();

        QueryEngine qe = getTestQueryEngine();

        QueryPipe actualPipe = new QueryPipe(qe, actual);
        actualPipe.put(from + "\n");
        actualPipe.close();
View Full Code Here

        // Attach a Ripple model to the repository.
        Model model = new SesameModel(sail);

        // Attach a query engine to the model.
        StackEvaluator evaluator = new LazyStackEvaluator();
        QueryEngine qe
                = new QueryEngine(model, evaluator, out, err);

        // Attach an interpreter to the query engine and let it query from
        // standard input.
        RippleCommandLine r = new RippleCommandLine(qe, in);
        r.run();
View Full Code Here

*/
public class RipplePrintStreamTest extends RippleTestCase {
    public void testLiterals() throws Exception {
        Model model = getTestModel();
        ModelConnection mc = model.createConnection();
        QueryEngine qe = new QueryEngine(model, null, System.out, System.err);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        RipplePrintStream ps = new RipplePrintStream(new PrintStream(bos), qe.getLexicon());

        mc.setNamespace("xsd", "http://www.w3.org/2001/XMLSchema#", true);

        ps.print(mc.valueOf(42));
        assertEquals("42", bos.toString());
View Full Code Here

*/
public class DefinitionsTest extends RippleTestCase {
    public void testDefinitions() throws Exception {
        Sail sail = getTestSail();
        SailConnection sc = sail.getConnection();
        QueryEngine qe = getTestQueryEngine();

        ListAST foobar = new ListAST(
                new PlainLiteralAST("foo"), new ListAST(new PlainLiteralAST("bar"), new ListAST()));
        ListAST foobar2 = new ListAST(
                new PlainLiteralAST("foo2"), new ListAST(new PlainLiteralAST("bar2"), new ListAST()));
        URI foobarUri = sail.getValueFactory().createURI(qe.getLexicon().getDefaultNamespace() + "foobar");
        Literal foo = sail.getValueFactory().createLiteral("foo");
        Literal foo2 = sail.getValueFactory().createLiteral("foo2");

        Command defCmd = new DefineListCmd("foobar", foobar);
        Command undefCmd = new UndefineListCmd("foobar");
        Command redefCmd = new RedefineListCmd("foobar", foobar2);

        int count;
        Value obj;

        count = countStatements(sc.getStatements(foobarUri, null, null, false));
        assertEquals(0, count);

        // Undefine a term which has not been defined.
        qe.executeCommand(undefCmd);
        count = countStatements(sc.getStatements(foobarUri, null, null, false));
        assertEquals(0, count);

        // Define a term which is not yet defined.
        qe.executeCommand(defCmd);
        count = countStatements(sc.getStatements(foobarUri, null, null, false));
        assertEquals(3, count);
        obj = getSingleStatement(sc.getStatements(foobarUri, RDF.FIRST, null, false)).getObject();
//System.out.println("obj = " + obj + " (datatype = " + ((Literal) obj).getDatatype());
        assertTrue(obj.equals(foo));
        assertFalse(obj.equals(foo2));

        // Undefine a term which has been defined.
        qe.executeCommand(undefCmd);
        count = countStatements(sc.getStatements(foobarUri, null, null, false));
        assertEquals(0, count);

        // Redefine a term which has already been defined.
        qe.executeCommand(defCmd);
        count = countStatements(sc.getStatements(foobarUri, null, null, false));
        assertEquals(3, count);
        obj = getSingleStatement(sc.getStatements(foobarUri, RDF.FIRST, null, false)).getObject();
        assertTrue(obj.equals(foo));
        assertFalse(obj.equals(foo2));
        qe.executeCommand(redefCmd);
        count = countStatements(sc.getStatements(foobarUri, null, null, false));
        assertEquals(3, count);
        obj = getSingleStatement(sc.getStatements(foobarUri, RDF.FIRST, null, false)).getObject();
        assertTrue(obj.equals(foo2));
        assertFalse(obj.equals(foo));

        // Undefine a term which has been redefined.
        qe.executeCommand(undefCmd);
        count = countStatements(sc.getStatements(foobarUri, null, null, false));
        assertEquals(0, count);

        // Redefine a term which has not yet been defined.
        qe.executeCommand(redefCmd);
        count = countStatements(sc.getStatements(foobarUri, null, null, false));
        assertEquals(3, count);
        obj = getSingleStatement(sc.getStatements(foobarUri, RDF.FIRST, null, false)).getObject();
        assertTrue(obj.equals(foo2));
        assertFalse(obj.equals(foo));
View Full Code Here

TOP

Related Classes of net.fortytwo.ripple.query.QueryEngine

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.