Package org.apache.jena.riot.lang

Examples of org.apache.jena.riot.lang.StreamRDFCounting


        StreamRDF s = StreamRDFLib.sinkNull() ;
        if ( ! modLangParse.toBitBucket() )
            s = StreamRDFLib.writer(output) ;
        if ( setup != null )
            s = InfFactory.inf(s, setup) ;
        StreamRDFCounting sink = StreamRDFLib.count(s) ;
        s = null ;
       
        ReaderRIOT reader = RDFDataMgr.createReader(lang) ;
        try {
            if ( checking ) {
                if ( lang == RDFLanguages.NTRIPLES || lang == RDFLanguages.NQUADS )
                    reader.setParserProfile(RiotLib.profile(baseURI, false, true, errHandler)) ;
                else
                    reader.setParserProfile(RiotLib.profile(baseURI, true, true, errHandler)) ;
            } else
                reader.setParserProfile(RiotLib.profile(baseURI, false, false, errHandler)) ;

            if ( labelsAsGiven )
                reader.getParserProfile().setLabelToNode(LabelToNode.createUseLabelAsGiven()) ;
            modTime.startTimer() ;
            reader.read(in, baseURI, ct, sink, null) ;
        } catch (RiotException ex) {
            // Should have handled the exception and logged a message by now.
            // System.err.println("++++"+ex.getMessage());

            if ( modLangParse.stopOnBadTerm() )
                return ;
        } finally {
            // Not close - we may write again to the underlying output stream in another call to parse a file. 
            sink.finish() ;
            IO.close(in) ;
        }
        long x = modTime.endTimer() ;
        long n = sink.countTriples()+sink.countQuads() ;

        if ( modTime.timingEnabled() )
            output(filename, n, x, handler) ;
       
        totalMillis += x ;
View Full Code Here


        StreamRDF s = StreamRDFLib.sinkNull() ;
        if ( ! modLangParse.toBitBucket() )
            s = StreamRDFLib.writer(output) ;
        if ( setup != null )
            s = InfFactory.inf(s, setup) ;
        StreamRDFCounting sink = StreamRDFLib.count(s) ;
        s = null ;
       
        // Need low level control over the parser.
        LangRIOT parser = RiotReader.createParser(in, lang, baseURI, sink) ;
        try
        {
            if ( checking )
            {
                if ( parser.getLang() == RDFLanguages.NTRIPLES ||  parser.getLang() == RDFLanguages.NQUADS )
                    parser.setProfile(RiotLib.profile(baseURI, false, true, errHandler)) ;
                else
                    parser.setProfile(RiotLib.profile(baseURI, true, true, errHandler)) ;
            }
            else
                parser.setProfile(RiotLib.profile(baseURI, false, false, errHandler)) ;
           
            if ( labelsAsGiven )
                parser.getProfile().setLabelToNode(LabelToNode.createUseLabelAsGiven()) ;
            modTime.startTimer() ;
            parser.parse() ;
        }
        catch (RiotException ex)
        {
            // Should have handled the exception and logged a message by now.
            //System.err.println("++++"+ex.getMessage());
          
            if ( modLangParse.stopOnBadTerm() )
                return ;
        }
        finally {
            // Not close - we may write again to the underlying output stream in another call to parse a file. 
            sink.finish() ;
            IO.close(in) ;
        }
        long x = modTime.endTimer() ;
        long n = sink.countTriples()+sink.countQuads() ;

        if ( modTime.timingEnabled() )
            output(filename, n, x, handler) ;
       
        totalMillis += x ;
View Full Code Here

    }

    @Override
    protected long parseCount(String... strings)
    {
        StreamRDFCounting sink = StreamRDFLib.count() ;
        parse(sink, strings) ;
        return sink.count() ;
    }
View Full Code Here

    final protected void parseCheck(String... strings)
    {
        String string = StrUtils.strjoin("\n", strings) ;
        Tokenizer tokenizer = tokenizer(string) ;
        StreamRDFCounting sink = StreamRDFLib.count() ;
        LangRIOT x = RiotReader.createParserNQuads(tokenizer, sink) ;
        x.setProfile(RiotLib.profile(null, false, true, new ErrorHandlerEx())) ;
        x.parse() ;
    }
View Full Code Here

          s = new StreamRDF2(s,  StreamRDFLib.writer(destOut));
       
        if ( setup != null )
            s = InfFactory.inf(s, setup) ;
       
        StreamRDFCounting sink = StreamRDFLib.count(s) ;
        s = null ;
       
        ReaderRIOT reader = RDFDataMgr.createReader(lang) ;
        try {
            if ( checking ) {
                if ( lang == RDFLanguages.NTRIPLES || lang == RDFLanguages.NQUADS )
                    reader.setParserProfile(RiotLib.profile(baseURI, false, true, errHandler)) ;
                else
                    reader.setParserProfile(RiotLib.profile(baseURI, true, true, errHandler)) ;
            } else
                reader.setParserProfile(RiotLib.profile(baseURI, false, false, errHandler)) ;

            if ( labelsAsGiven )
                reader.getParserProfile().setLabelToNode(LabelToNode.createUseLabelAsGiven()) ;
            modTime.startTimer() ;
            reader.read(in, baseURI, ct, sink, null) ;
        } catch (RiotException ex) {
            // Should have handled the exception and logged a message by now.
            // System.err.println("++++"+ex.getMessage());

            if ( modLangParse.stopOnBadTerm() )
                return ;
        } finally {
            // Not close - we may write again to the underlying output stream in another call to parse a file. 
            sink.finish() ;
            IO.close(in) ;
        }
        long x = modTime.endTimer() ;
        long n = sink.countTriples()+sink.countQuads() ;

        if ( modTime.timingEnabled() )
            output(filename, n, x, handler) ;
       
        totalMillis += x ;
View Full Code Here

    private static Triple triple1 = SSE.parseTriple("(<s> <p> <o>)") ;
    private static Quad quad1 = SSE.parseQuad("(<g> <s> <p> <o>)") ;
   
   
    @Test public void stream_count_01() {
        StreamRDFCounting stream = StreamRDFLib.count() ;
        stream.start();
        assertEquals(0, stream.count()) ;
        stream.triple(triple1) ;
        assertEquals(1, stream.count()) ;
        stream.triple(triple1) ;
        assertEquals(2, stream.count()) ;
        stream.finish() ;
       
        assertEquals(2, stream.count()) ;
        assertEquals(2, stream.countTriples()) ;
        assertEquals(0, stream.countQuads()) ;
    }
View Full Code Here

        assertEquals(2, stream.countTriples()) ;
        assertEquals(0, stream.countQuads()) ;
    }
   
    @Test public void stream_count_02() {
        StreamRDFCounting stream = StreamRDFLib.count() ;
        stream.start();
        stream.triple(triple1) ;
        stream.quad(quad1) ;
       
        assertEquals(2, stream.count()) ;
        assertEquals(1, stream.countTriples()) ;
        assertEquals(1, stream.countQuads()) ;
       
        stream.finish();
    }
View Full Code Here

                    log.info(format("[%d] Upload: Filename: %s, Content-Type=%s, Charset=%s => %s",
                                    action.id, name,  ct.getContentType(), ct.getCharset(), lang.getName())) ;
                   
                    StreamRDF x = StreamRDFLib.graph(graphTmp) ;
                    StreamRDFCounting dest =  StreamRDFLib.count(x) ;
                    SPARQL_REST.parse(action, dest, stream, lang, base);
                    count = dest.count() ;
                }
            }   

            if ( graphName == null || graphName.equals("") )
                graphName = HttpNames.valueDefault ;
View Full Code Here

        StreamRDF s = StreamRDFLib.sinkNull() ;
        if ( ! modLangParse.toBitBucket() )
            s = StreamRDFLib.writer(output) ;
        if ( setup != null )
            s = InfFactory.inf(s, setup) ;
        StreamRDFCounting sink = StreamRDFLib.count(s) ;
        s = null ;
       
        ReaderRIOT reader = RDFDataMgr.createReader(lang) ;
        try {
            if ( checking ) {
                if ( lang == RDFLanguages.NTRIPLES || lang == RDFLanguages.NQUADS )
                    reader.setParserProfile(RiotLib.profile(baseURI, false, true, errHandler)) ;
                else
                    reader.setParserProfile(RiotLib.profile(baseURI, true, true, errHandler)) ;
            } else
                reader.setParserProfile(RiotLib.profile(baseURI, false, false, errHandler)) ;

            if ( labelsAsGiven )
                reader.getParserProfile().setLabelToNode(LabelToNode.createUseLabelAsGiven()) ;
            modTime.startTimer() ;
            reader.read(in, baseURI, ct, sink, null) ;
        } catch (RiotException ex) {
            // Should have handled the exception and logged a message by now.
            // System.err.println("++++"+ex.getMessage());

            if ( modLangParse.stopOnBadTerm() )
                return ;
        } finally {
            // Not close - we may write again to the underlying output stream in another call to parse a file. 
            sink.finish() ;
            IO.close(in) ;
        }
        long x = modTime.endTimer() ;
        long n = sink.countTriples()+sink.countQuads() ;

        if ( modTime.timingEnabled() )
            output(filename, n, x, handler) ;
       
        totalMillis += x ;
View Full Code Here

                    log.info(format("[%d] Upload: Filename: %s, Content-Type=%s, Charset=%s => %s",
                                    action.id, name,  ct.getContentType(), ct.getCharset(), lang.getName())) ;
                   
                    StreamRDF x = StreamRDFLib.graph(graphTmp) ;
                    StreamRDFCounting dest =  StreamRDFLib.count(x) ;
                    SPARQL_REST.parse(action, dest, stream, lang, base);
                    count = dest.count() ;
                }
            }   

            if ( graphName == null || graphName.equals("") )
                graphName = HttpNames.valueDefault ;
View Full Code Here

TOP

Related Classes of org.apache.jena.riot.lang.StreamRDFCounting

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.