Package com.hp.hpl.jena.graph

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


            // Go through each graph.
            Iterator<Node> iter = Iter.iterator(dataset.listGraphNodes()) ;
            for ( ; iter.hasNext() ; )
            {
                Node n = iter.next();
                Graph g = dataset.getGraph(n) ;
                sync(g) ;
            }
        }
    }
View Full Code Here


     * firing when real data is added. Used to implement bindSchema processing
     * in the parent Reasoner.
     * @return return true if the rule set has also been loaded
     */
    protected boolean preloadDeductions(Graph preloadIn) {
        Graph d = fdeductions.getGraph();
        BasicForwardRuleInfGraph preload = (BasicForwardRuleInfGraph) preloadIn;
        // If the rule set is the same we can reuse those as well
        if (preload.rules == rules) {
            // Load raw deductions
            for (Iterator<Triple> i = preload.find(null, null, null); i.hasNext(); ) {
                d.add(i.next());
            }
            engine.setRuleStore(preload.engine.getRuleStore());
            return true;
        } else {
            return false;
View Full Code Here

     */  
    @Override
    public void performDelete(Triple t) {
        version++;
        if (fdata != null) {
            Graph data = fdata.getGraph();
            if (data != null) {
                data.delete(t);
            }
        }
        if (!this.isPrepared()) {
            fdeductions.getGraph().delete(t);
        }
View Full Code Here

     * wrapper can be reused if present thus enabling preservation of
     * listeners.
     */
    protected Graph createDeductionsGraph() {
        if (fdeductions != null) {
            Graph dg = fdeductions.getGraph();
            if (dg != null) {
                // Reuse the old graph in order to preserve any listeners
                safeDeductions.clear();
                return dg;
            }
        }
        Graph dg = Factory.createGraphMem( );
        safeDeductions = new SafeGraph( dg );
        return dg;
    }
View Full Code Here

        {
            return old ;
        }
        Node resAsNode = old.asNode() ;
        Model model = old.getModel() ;
        Graph graph = model.getGraph() ;
        Graph rawGraph = graph instanceof InfGraph ? ((InfGraph) graph).getRawGraph() : graph ;
        Resource newRes = model.createResource(uri) ;
        Node newResAsNode = newRes.asNode() ;
        
       
        boolean changeOccured = false ;
        List<Triple> triples = new ArrayList<Triple>(WINDOW_SIZE) ;
       
        // An optimization to prevent concatenating the two find() operations together every time through the outer loop
        boolean onFirstIterator = true;

        // It's possible there are triples (old wossname old) that are in triples twice. It doesn't matter.
        ExtendedIterator<Triple> it = rawGraph.find(resAsNode, Node.ANY, Node.ANY) ;
        try
        {
            if ( !it.hasNext() )
            {
                it.close() ;
                onFirstIterator = false ;
                it = rawGraph.find(Node.ANY, Node.ANY, resAsNode) ;
            }
            changeOccured = it.hasNext() ;

            while ( it.hasNext() )
            {
                int count = 0 ;
                while ( it.hasNext() && count < WINDOW_SIZE )
                {
                    triples.add(it.next()) ;
                    count++ ;
                }

                it.close() ;
               
                // Iterate over the triples collection twice (this may be more efficient than interleaving deletes and adds)
                for ( Triple t : triples )
                {
                    rawGraph.delete(t) ;
                }
               
                for ( Triple t : triples )
                {
                    Node oldS = t.getSubject(), oldO = t.getObject() ;
                    Node newS = oldS.equals(resAsNode) ? newResAsNode : oldS ;
                    Node newO = oldO.equals(resAsNode) ? newResAsNode : oldO ;
                   
                    rawGraph.add(Triple.create(newS, t.getPredicate(), newO));
                }
                triples.clear();

                it = onFirstIterator ? rawGraph.find(resAsNode, Node.ANY, Node.ANY) : rawGraph.find(Node.ANY, Node.ANY, resAsNode) ;
                if ( onFirstIterator && !it.hasNext() )
                {
                    it.close() ;
                    onFirstIterator = false ;
                    it = rawGraph.find(Node.ANY, Node.ANY, resAsNode) ;
                }
            }
        }
        finally
        {
View Full Code Here

    private void loadOne(String filename, boolean replace)
    {
        Monitor monitor = null ;
       
        Model model = modGraph.getModel(getStore()) ;
        Graph graph = model.getGraph() ;   

        if ( isVerbose() && replace )
            System.out.println("Emptying: "+filename) ;
        if (replace)
            model.removeAll();

        if ( isVerbose() || getModTime().timingEnabled() )
            System.out.println("Start load: "+filename) ;
        if ( getModTime().timingEnabled() )
        {
            monitor = new Monitor(getStore().getLoader().getChunkSize(), isVerbose()) ;
            graph.getEventManager().register(monitor) ;
        }

        // Crude but convenient
        if ( filename.indexOf(':') == -1 )
            filename = "file:"+filename ;

        String lang = FileUtils.guessLang(filename) ;
       
        // Always time, only print if enabled.
        getModTime().startTimer() ;
       
        // Load here
        model.read(filename, lang) ;

        long timeMilli = getModTime().endTimer() ;
           
        if ( monitor != null )
        {
            System.out.println("Added "+monitor.addCount+" triples") ;
       
            if ( getModTime().timingEnabled() && !isQuiet() )
                System.out.printf("Loaded in %.3f seconds [%d triples/s]\n",
                                  timeMilli/1000.0, (1000*monitor.addCount/timeMilli)) ;
            graph.getEventManager().unregister(monitor) ;
        }
    }
View Full Code Here

        }
   
    public Model createFileModel( File fullName, String lang, boolean create, boolean strict )
        {
        NotifyOnClose notify = NotifyOnClose.ignore;
        Graph fileGraph = new FileGraph( notify, fullName, lang, create, strict );
        return ModelFactory.createModelForGraph( fileGraph );
        }
View Full Code Here

                return null ;
            }
            return namedGraphs.get(graphNode) ;
        }
       
        Graph g = super.getGraph(graphNode) ;
        if ( g == null ) return null ;
        g = new GraphReadOnly(g) ;
        namedGraphs.put(graphNode, g) ;
        return g ;
    }
View Full Code Here

    // ---- DataSourceGraph
   
    @Override
    public void addGraph(Node graphName, Graph graph)
    {
        Graph g = getGraph(graphName) ;
        GraphUtil.addInto(g, graph) ;
    }
View Full Code Here

        }
       
        @Override
        public QueryIterator execute(OpBGP opBGP, QueryIterator input)
        {
            Graph g = execCxt.getActiveGraph() ;
           
            if ( g instanceof GraphTDB )
            {
                BasicPattern bgp = opBGP.getPattern() ;
                Explain.explain("Execute", bgp, execCxt.getContext()) ;
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.