当前位置: 首页>>代码示例>>Java>>正文


Java PipedRDFIterator类代码示例

本文整理汇总了Java中org.apache.jena.riot.lang.PipedRDFIterator的典型用法代码示例。如果您正苦于以下问题:Java PipedRDFIterator类的具体用法?Java PipedRDFIterator怎么用?Java PipedRDFIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PipedRDFIterator类属于org.apache.jena.riot.lang包,在下文中一共展示了PipedRDFIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import org.apache.jena.riot.lang.PipedRDFIterator; //导入依赖的package包/类
public static PipedRDFIterator<Triple> parse(String dump){
    PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
    final String d=dump;
    System.out.println(d);
    final PipedRDFStream<Triple> inputStream = new PipedTriplesStream(iter);
    // PipedRDFStream and PipedRDFIterator need to be on different threads
    ExecutorService executor = Executors.newSingleThreadExecutor();
    // Create a runnable for our parser thread
    Runnable parser = new Runnable() {
        @Override
        public void run() {
            // Call the parsing process.
            RDFDataMgr.parse(inputStream, d);
        }
    };

    // Start the parser on another thread
    executor.submit(parser);
    return iter;
}
 
开发者ID:WDAqua,项目名称:PageRankRDF,代码行数:21,代码来源:Parser.java

示例2: runExtraction

import org.apache.jena.riot.lang.PipedRDFIterator; //导入依赖的package包/类
/**
 * (Variation 2)
 * @param iter Iterator
 * @param streamDecorator Stream decorator
 * @param task Task
 * @param extractors Extractors
 * @return TRUE or FALSE
 */
protected boolean runExtraction(PipedRDFIterator<Triple> iter, BlockingStreamRDFDecorator streamDecorator,
        Task task, Extractor extractors[]) {
   	// management
    streamerThread = Thread.currentThread();
    overseer.startTask( task );
    
    // wait before execution
    try {
        streamDecorator.waitToStart();
    }
    catch ( InterruptedException e ) {
        LOGGER.error("Interrupted while waiting for the producer. Aborting.", e);
        return false;
    }
    
    // call function again
    runExtraction(iter, extractors);
    return true;
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:28,代码来源:RDF2ExtractionStreamer.java

示例3: test00GetVoidInformation

import org.apache.jena.riot.lang.PipedRDFIterator; //导入依赖的package包/类
/**
 * Test method for VoidParsingExtractor#getVoidInformation()
 * 0.nt
 */
@Test
public final void test00GetVoidInformation() {
	// set input file
	String inFile = "src/test/data/0.nt";
	// run extraction
	try {
		// setup
		InputStream inStream = new FileInputStream( inFile );
		PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
		PipedRDFStream<Triple> rdfStream = new PipedTriplesStream( iter );
		// run
		RDFDataMgr.parse(rdfStream,	inStream, "", RDFLanguages.resourceNameToLang( inFile ) );
		VoidParsingExtractor extractor = new VoidParsingExtractor();
		extractor.extract( iter );
		// print
		System.out.println( "0.nt\n  " + extractor.getVoidInformation().toString() );
		// test
		assertEquals( 0, extractor.getVoidInformation().size() );
	}
	catch( Exception e ) {
		fail( e.toString() );
	}
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:28,代码来源:VoidParsingExtractorTest.java

示例4: test051GetVoidInformation

import org.apache.jena.riot.lang.PipedRDFIterator; //导入依赖的package包/类
/**
 * Test method for VoidParsingExtractor#getVoidInformation()
 * 5.nt
 */
@Test
public final void test051GetVoidInformation() {
	// set input file
	String inFile = "src/test/data/5.nt";
	// run extraction
	try {
		// setup
		InputStream inStream = new FileInputStream( inFile );
		PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
		PipedRDFStream<Triple> rdfStream = new PipedTriplesStream( iter );
		// run
		RDFDataMgr.parse(rdfStream,	inStream, "", RDFLanguages.resourceNameToLang( inFile ) );
		VoidParsingExtractor extractor = new VoidParsingExtractor();
		extractor.extract( iter );
		// print
		System.out.println( "5.nt:\n  " + extractor.getVoidInformation().toString() );
		// test
		assertEquals( 0, extractor.getVoidInformation().size() );
	}
	catch( Exception e ) {
		fail( e.toString() );
	}
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:28,代码来源:VoidParsingExtractorTest.java

示例5: test052GetVoidInformation

import org.apache.jena.riot.lang.PipedRDFIterator; //导入依赖的package包/类
/**
 * Test method for VoidParsingExtractor#getVoidInformation()
 * expected_5.nt
 */
@Test
public final void test052GetVoidInformation() {
	// set input file
	String inFile = "src/test/data/expected_5.nt";
	// run extraction
	try {
		// setup
		InputStream inStream = new FileInputStream( inFile );
		PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
		PipedRDFStream<Triple> rdfStream = new PipedTriplesStream( iter );
		// run
		RDFDataMgr.parse(rdfStream,	inStream, "", RDFLanguages.resourceNameToLang( inFile ) );
		VoidParsingExtractor extractor = new VoidParsingExtractor();
		extractor.extract( iter );
		// print
		System.out.println( "expected_5.nt:\n  " + extractor.getVoidInformation().toString() );
		// test
		assertEquals( 11, extractor.getVoidInformation().size() );
	}
	catch( Exception e ) {
		fail( e.toString() );
	}		
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:28,代码来源:VoidParsingExtractorTest.java

示例6: open

import org.apache.jena.riot.lang.PipedRDFIterator; //导入依赖的package包/类
@Override
public void open(Map conf, TopologyContext context,	SpoutOutputCollector collector) {
	this.collector = collector;
	
	//Sink<Triple> output = new SinkTripleOutput(System.out, null, SyntaxLabels.createNodeToLabel());
	iterator = new PipedRDFIterator<Triple>();
       final PipedRDFStream<Triple> inputStream = new PipedTriplesStream(iterator);

	// PipedRDFStream and PipedRDFIterator need to be on different threads
       ExecutorService executor = Executors.newSingleThreadExecutor();

       // Create a runnable for our parser thread
       Runnable parser = new Runnable() {

           @Override
           public void run() {
               // Call the parsing process.
               RDFDataMgr.parse(inputStream, filePath, Lang.TURTLE);
           }
       };

       // Start the parser on another thread
       executor.submit(parser);
}
 
开发者ID:allaves,项目名称:storm-query-operators,代码行数:25,代码来源:RDFStreamSpout.java

示例7: reinitialiseProcessors

import org.apache.jena.riot.lang.PipedRDFIterator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void reinitialiseProcessors(){
	if (!this.executor.isShutdown()){
		this.executor.shutdownNow();
	}
	
	Lang lang  = RDFLanguages.filenameToLang(datasetURI);
	
	if ((lang == Lang.NQ) || (lang == Lang.NQUADS)){
		this.iterator = new PipedRDFIterator<Quad>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
		this.rdfStream = new PipedQuadsStream((PipedRDFIterator<Quad>) iterator);
	} else {
		this.iterator = new PipedRDFIterator<Triple>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
		this.rdfStream = new PipedTriplesStream((PipedRDFIterator<Triple>) iterator);
	}
	
	
	this.isInitalised = true;
	
	this.executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
	
	lstMetricConsumers = new ArrayList<MetricProcess>();
	for(String className : this.metricInstances.keySet()) {
		this.lstMetricConsumers.add(new MetricProcess(this.metricInstances.get(className)));
	}
}
 
开发者ID:EIS-Bonn,项目名称:Luzzu,代码行数:27,代码来源:LargeStreamProcessor.java

示例8: setUpProcess

import org.apache.jena.riot.lang.PipedRDFIterator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void setUpProcess() {
		Lang lang  = RDFLanguages.filenameToLang(datasetURI);

		if ((lang == Lang.NQ) || (lang == Lang.NQUADS)){
			this.iterator = new PipedRDFIterator<Quad>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
			this.rdfStream = new PipedQuadsStream((PipedRDFIterator<Quad>) iterator);
		} else {
			this.iterator = new PipedRDFIterator<Triple>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
			this.rdfStream = new PipedTriplesStream((PipedRDFIterator<Triple>) iterator);
		}
		logger.debug("PipedRDFIterator initialized with: Buffer Size {}, Fair Lock {}, Poll Timeout {}, Max Polls {}", 
				rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
		
		this.isInitalised = true;
		
		try {
			this.loadMetrics();
		} catch (ExternalMetricLoaderException e) {
			logger.error(e.getLocalizedMessage());
		}
		
		this.executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
}
 
开发者ID:EIS-Bonn,项目名称:Luzzu,代码行数:25,代码来源:LargeStreamProcessor.java

示例9: setUpProcess

import org.apache.jena.riot.lang.PipedRDFIterator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void setUpProcess() {

	Lang lang  = RDFLanguages.filenameToLang(datasetURI);
	
	if ((lang == Lang.NQ) || (lang == Lang.NQUADS)){
		this.iterator = new PipedRDFIterator<Quad>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
		this.rdfStream = new PipedQuadsStream((PipedRDFIterator<Quad>) iterator);
	} else {
		this.iterator = new PipedRDFIterator<Triple>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
		this.rdfStream = new PipedTriplesStream((PipedRDFIterator<Triple>) iterator);
	}
	
	this.isInitalised = true;
	
	try {
		this.loadMetrics();
	} catch (ExternalMetricLoaderException e) {
		logger.error(e.getLocalizedMessage());
	}
	
	this.executor = Executors.newSingleThreadExecutor();
}
 
开发者ID:EIS-Bonn,项目名称:Luzzu,代码行数:25,代码来源:GZNTMemoryProcessor.java

示例10: reinitialiseProcessors

import org.apache.jena.riot.lang.PipedRDFIterator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void reinitialiseProcessors(){
	if (!this.executor.isShutdown()){
		this.executor.shutdownNow();
	}
	
	Lang lang  = RDFLanguages.filenameToLang(datasetURI);
	
	if ((lang == Lang.NQ) || (lang == Lang.NQUADS)){
		this.iterator = new PipedRDFIterator<Quad>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
		this.rdfStream = new PipedQuadsStream((PipedRDFIterator<Quad>) iterator);
	} else {
		this.iterator = new PipedRDFIterator<Triple>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
		this.rdfStream = new PipedTriplesStream((PipedRDFIterator<Triple>) iterator);
	}
	
	this.isInitalised = true;
	
	this.executor = Executors.newSingleThreadExecutor();
	
	lstMetricConsumers = new ArrayList<MetricProcess>();
	for(String className : this.metricInstances.keySet()) {
		this.lstMetricConsumers.add(new MetricProcess(this.metricInstances.get(className)));
	}
}
 
开发者ID:EIS-Bonn,项目名称:Luzzu,代码行数:26,代码来源:StreamProcessor.java

示例11: setUpProcess

import org.apache.jena.riot.lang.PipedRDFIterator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void setUpProcess() {
		Lang lang  = RDFLanguages.filenameToLang(datasetURI);

		if ((lang == Lang.NQ) || (lang == Lang.NQUADS)){
			this.iterator = new PipedRDFIterator<Quad>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
			this.rdfStream = new PipedQuadsStream((PipedRDFIterator<Quad>) iterator);
		} else {
			this.iterator = new PipedRDFIterator<Triple>(rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
			this.rdfStream = new PipedTriplesStream((PipedRDFIterator<Triple>) iterator);
		}
		logger.debug("PipedRDFIterator initialized with: Buffer Size {}, Fair Lock {}, Poll Timeout {}, Max Polls {}", 
				rdfIterBufferSize, rdfIterFairBufferLock, rdfIterPollTimeout, rdfIterMaxPolls);
		
		this.isInitalised = true;
		
		try {
			this.loadMetrics();
		} catch (ExternalMetricLoaderException e) {
			logger.error(e.getLocalizedMessage());
		}
		
		this.executor = Executors.newSingleThreadExecutor();
}
 
开发者ID:EIS-Bonn,项目名称:Luzzu,代码行数:25,代码来源:StreamProcessor.java

示例12: streamParser

import org.apache.jena.riot.lang.PipedRDFIterator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public PipedRDFIterator<?> streamParser(final String fileName){
	PipedRDFIterator<?> iterator = new PipedRDFIterator<Triple>();
	final PipedRDFStream<?> rdfStream = new PipedTriplesStream((PipedRDFIterator<Triple>) iterator);
	
	ExecutorService executor = Executors.newSingleThreadExecutor();

	Runnable parser = new Runnable(){
		@Override
		public void run() {
			try{
				RDFDataMgr.parse(rdfStream, fileName);
			} catch (Exception e){
				rdfStream.finish();
			}
		}			
	};
	executor.submit(parser);

	
	return iterator;
}
 
开发者ID:diachron,项目名称:quality,代码行数:23,代码来源:TestLoader.java

示例13: testExternalDataProviders

import org.apache.jena.riot.lang.PipedRDFIterator; //导入依赖的package包/类
@Test
	public void testExternalDataProviders() {
		metric = new EstimatedLinkExternalDataProviders();
		metric.setDatasetURI("http://www.myexperiment.org");

		 PipedRDFIterator<?> iter =loader.streamParser("/Users/jeremy/Desktop/www.myexperiment.org.nt.gz");
		// Load quads...
//		List<Quad> streamingQuads = loader.getStreamingQuads();
//		int counter = 0;
		
//		for(Quad quad : streamingQuads){
//			metric.compute(quad);
//			counter++;
//		}
//		System.out.println(counter);
		
		while(iter.hasNext()){
			Object nxt = iter.next();
			Object2Quad quad = new Object2Quad(nxt);
			metric.compute(quad.getStatement());
		}
//		
		assertEquals(0.052,metric.metricValue(),0.001);
	}
 
开发者ID:diachron,项目名称:quality,代码行数:25,代码来源:LinkExternalDataProvidersTest.java

示例14: load

import org.apache.jena.riot.lang.PipedRDFIterator; //导入依赖的package包/类
private AQuiXEvent load(final RDFStreamSource source) {
	// Create a PipedRDFStream to accept input and a PipedRDFIterator to
	// consume it
	// You can optionally supply a buffer size here for the
	// PipedRDFIterator, see the documentation for details about recommended
	// buffer sizes
	// this.iter = new PipedRDFIterator<Tuple<Node>>();
	this.iter = new PipedRDFIterator<Triple>();
	// final PipedRDFStream<Tuple<Node>> tripleStream = new
	// PipedTuplesStream(this.iter);
	final StreamRDF tripleStream = new PipedTriplesStream(this.iter);
	final TypedInputStream tis = source.asTypedInputStream();
	// PipedRDFStream and PipedRDFIterator need to be on different threads
	this.executor = Executors.newSingleThreadExecutor();

	// Create a runnable for our parser thread
	final Runnable parser = () -> {
           // Call the parsing process.
           // System.out.println("started thread before");
           RDFDataMgr.parse(tripleStream, tis, Lang.N3);
           // System.out.println("started thread after");
       };

	// Start the parser on another thread
	this.executor.execute(parser);
	return AQuiXEvent.getStartRDF();
}
 
开发者ID:Innovimax-SARL,项目名称:QuiXDM,代码行数:28,代码来源:RDFQuiXEventStreamReader.java

示例15: runExtraction

import org.apache.jena.riot.lang.PipedRDFIterator; //导入依赖的package包/类
public boolean runExtraction(String rdfData, String baseUri, Lang language, Extractor... extractors) {
    PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
    PipedRDFStream<Triple> rdfStream = new PipedTriplesStream(iter);
    BlockingStreamRDFDecorator streamDecorator = new BlockingStreamRDFDecorator(rdfStream);
    return runExtraction(iter, streamDecorator,
            new String2RDFStreamingTask(streamDecorator, new StringReader(rdfData), baseUri, language), extractors);
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:8,代码来源:RDF2ExtractionStreamer.java


注:本文中的org.apache.jena.riot.lang.PipedRDFIterator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。