Package com.hp.hpl.jena.graph

Examples of com.hp.hpl.jena.graph.Graph


                Explain.explain("Execute", opQuadPattern.getPattern(), execCxt.getContext()) ;
                BasicPattern bgp = opQuadPattern.getBasicPattern() ;
                return SolverLib.execute(ds, gn, bgp, input, filter, execCxt) ;
            }
            // Maybe a TDB named graph inside a non-TDB dataset.
            Graph g = execCxt.getActiveGraph() ;
            if ( g instanceof GraphTDB )
            {
                // Triples graph from TDB (which is the default graph of the dataset),
                // used a named graph in a composite dataset.
                BasicPattern bgp = opQuadPattern.getBasicPattern() ;
View Full Code Here


   
    @Override
    public QueryIterator execute(BasicPattern pattern, QueryIterator input, ExecutionContext execCxt)
    {
        // --- In case this isn't for TDB
        Graph g = execCxt.getActiveGraph() ;
       
        if ( ! ( g instanceof GraphTDB ) )
            // Not us - bounce up the StageGenerator chain
            return above.execute(pattern, input, execCxt) ;
        GraphTDB graph = (GraphTDB)g ;
View Full Code Here

                return QueryIterNullIterator.create(execCxt) ;
        }
       
        //Set bindings = new HashSet() ;    // Use a Set if you want unique results.
        List<Binding> bindings = new ArrayList<Binding>() ;   // Use a list if you want counting results.
        Graph graph = execCxt.getActiveGraph() ;
       
        ExtendedIterator<Triple>iter = graph.find(Node.ANY, Node.ANY, Node.ANY) ;
        for ( ; iter.hasNext() ; )
        {
            Triple t = iter.next() ;
            slot(bindings, input, t.getSubject(),   subjVar, nodeLocalname) ;
            slot(bindings, input, t.getPredicate(), subjVar, nodeLocalname) ;
View Full Code Here

                    // http://jena.apache.org/documentation/notes/sse.html
                    // format.  It is not a streaming parser; it creates some triples,
                    // then send them to the output. This style might be useful for creating
                    // triples from a converter process or program.
                    Item item = SSE.parse(in) ;
                    Graph graph = BuilderGraph.buildGraph(item) ;
                    Iterator<Triple> iter = graph.find(null, null, null) ;
                    for ( ; iter.hasNext() ; )
                        output.triple(iter.next()) ;
                }} ;
        }
View Full Code Here

        final Model model = data0.getNamedModel( MY_NS );
        out.println("Model := "+model);

        out.println("getting graph...");
        /// this is the DATA in that MODEL
        final Graph graph = model.getGraph();
        out.println("Graph := "+graph);

        if (graph.isEmpty()) {
            final Resource product1 = model.createResource(
                    iriFactory.construct( MY_NS +"product/1" )
                        .toString() );

            final Property hasName = model.createProperty( MY_NS, "#hasName");
            final Statement stmt = model.createStatement(
                    product1, hasName, model.createLiteral("Beach Ball","en") );
            out.println("Statement = " + stmt);

            model.add(stmt);

            // just for fun
            out.println("Triple := " + stmt.asTriple().toString());
        } else {
            out.println("Graph is not Empty; it has "+graph.size()+" Statements");
            long t0, t1;
            t0 = System.currentTimeMillis();
            final Query q = QueryFactory.create(
                    "PREFIX exns: <"+MY_NS+"#>\n"+
                    "PREFIX exprod: <"+MY_NS+"product/>\n"+
                    " SELECT * "
                    // if you don't provide the Model to the
                    // QueryExecutionFactory below, then you'll need
                    // to specify the FROM;
                    // you *can* always specify it, if you want
                    // +" FROM <"+MY_NS+">\n"
                    // +" WHERE { ?node <"+MY_NS+"#hasName> ?name }"
                    // +" WHERE { ?node exns:hasName ?name }"
                    // +" WHERE { exprod:1 exns:hasName ?name }"
                    +" WHERE { ?res ?pred ?obj }"
                    );
            out.println("Query := "+q);
            t1 = System.currentTimeMillis();
            out.println("QueryFactory.TIME="+(t1 - t0));

            t0 = System.currentTimeMillis();
            final QueryExecution qExec = QueryExecutionFactory
                    // if you query the whole DataSet,
                    // you have to provide a FROM in the SparQL
                    //.create(q, data0);
                    .create(q, model);
            t1 = System.currentTimeMillis();
            out.println("QueryExecutionFactory.TIME="+(t1 - t0));

            try {
                t0 = System.currentTimeMillis();
                ResultSet rs = qExec.execSelect();
                t1 = System.currentTimeMillis();
                out.println("executeSelect.TIME="+(t1 - t0));
                while (rs.hasNext()) {
                    QuerySolution sol = rs.next();
                    out.println("Solution := "+sol);
                    for (Iterator<String> names = sol.varNames(); names.hasNext(); ) {
                        final String name = names.next();
                        out.println("\t"+name+" := "+sol.get(name));
                    }
                }
            } finally {
                qExec.close();
            }
        }
        out.println("closing graph");
        graph.close();
        out.println("closing model");
        model.close();
        //out.println("closing DataSetGraph");
        //dsg.close();
        out.println("closing DataSet");
View Full Code Here

           
            boolean syntheticGraph = ( Quad.isDefaultGraph(graphNode) || Quad.isUnionGraph(graphNode) ) ;
            if ( ! syntheticGraph && ! outerCxt.getDataset().containsGraph(graphNode) )
                return null ;

            Graph g = outerCxt.getDataset().getGraph(graphNode) ;
            // And the contains was true??!!!!!!
            if ( g == null )
                return null ;
                //throw new ARQInternalErrorException(".containsGraph was true but .getGraph is null") ;
           
View Full Code Here

                                 ExecutionContext execCxt)
    {
        if ( input == null )
            Log.fatal(this, "Null input to "+Utils.classShortName(this.getClass())) ;

        Graph graph = execCxt.getActiveGraph() ;

        // Choose reorder transformation and execution strategy.
       
        final ReorderTransformation reorder ;
        final StageGenerator executor ;
View Full Code Here

    {
        ExecutionContext execCxt = evaluator.getExecContext() ;
       
        if ( ! Var.isVar(opGraph.getNode()) )
        {
            Graph graph = execCxt.getDataset().getGraph(opGraph.getNode()) ;
            if ( graph == null )
                // No such name in the dataset
                return new TableEmpty() ;
            ExecutionContext execCxt2 = new ExecutionContext(execCxt, graph) ;
            Evaluator e2 = EvaluatorFactory.create(execCxt2) ;
            return eval(e2, opGraph.getSubOp()) ;
        }
       
        // Graph node is a variable.
        Var gVar = Var.alloc(opGraph.getNode()) ;
        Table current = null ;
        for ( Iterator<Node> iter = execCxt.getDataset().listGraphNodes() ; iter.hasNext() ; )
        {
            Node gn = iter.next();
            Graph graph = execCxt.getDataset().getGraph(gn) ;
            ExecutionContext execCxt2 = new ExecutionContext(execCxt, graph) ;
            Evaluator e2 = EvaluatorFactory.create(execCxt2) ;
           
            Table tableVarURI = TableFactory.create(gVar, gn) ;
            // Evaluate the pattern, join with this graph node possibility.
View Full Code Here

       
        if ( ! opQuad.getGraphNode().isVariable() )
        {
            if ( ! opQuad.getGraphNode().isURI() )
            { throw new ARQInternalErrorException("Not a URI or variable: "+opQuad.getGraphNode()) ;}
            Graph g = null ;
           
            if ( opQuad.isDefaultGraph() )
                g = ds.getDefaultGraph() ;
            else
                g = ds.getGraph(opQuad.getGraphNode()) ;
            if ( g == null )
                return new TableEmpty() ;
            ExecutionContext cxt2 = new ExecutionContext(cxt, g) ;
            QueryIterator qIter = executeBGP(pattern, QueryIterRoot.create(cxt2), cxt2) ;
            return TableFactory.create(qIter) ;
        }
        else
        {
            // Variable.
            Var gVar = Var.alloc(opQuad.getGraphNode()) ;
            // Or just just devolve to OpGraph and get OpUnion chain of OpJoin
            QueryIterConcat concat = new QueryIterConcat(cxt) ;
            for ( Iterator<Node> graphNodes = cxt.getDataset().listGraphNodes() ; graphNodes.hasNext(); )
            {
                Node gn = graphNodes.next() ;
                //Op tableVarURI = TableFactory.create(gn.getName(), Node.createURI(uri)) ;
               
                Graph g = cxt.getDataset().getGraph(gn) ;
                Binding b = BindingFactory.binding(BindingRoot.create(), gVar, gn) ;
                ExecutionContext cxt2 = new ExecutionContext(cxt, g) ;

                // Eval the pattern, eval the variable, join.
                // Pattern may be non-linear in the variable - do a pure execution. 
View Full Code Here

            return b ;
       
        for ( Iterator<Node> iter1 = dataset1.listGraphNodes() ; iter1.hasNext() ; )
        {
            Node gn = iter1.next() ;
            Graph g1 = dataset1.getGraph(gn) ;
            Graph g2 = dataset2.getGraph(gn) ;
            if ( g2 == null )
                return false ;
            if ( ! g1.isIsomorphicWith(g2) )
                return false ;
        }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.graph.Graph

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.