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


Java SailRepository.shutDown方法代码示例

本文整理汇总了Java中org.eclipse.rdf4j.repository.sail.SailRepository.shutDown方法的典型用法代码示例。如果您正苦于以下问题:Java SailRepository.shutDown方法的具体用法?Java SailRepository.shutDown怎么用?Java SailRepository.shutDown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.rdf4j.repository.sail.SailRepository的用法示例。


在下文中一共展示了SailRepository.shutDown方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testEvaluate

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入方法依赖的package包/类
@Test
public void testEvaluate() throws Exception {
    ValueFactory vf = SimpleValueFactory.getInstance();
    Resource subj = vf.createIRI("http://whatever/subj/");
    IRI pred = vf.createIRI("http://whatever/pred/");
    Value obj = vf.createLiteral("whatever");
    CloseableIteration<? extends Statement, SailException> iter;
    HBaseSail sail = new HBaseSail(HBaseServerTestInstance.getInstanceConfig(), "whatevertable", true, 0, true, 0, null, null);
    SailRepository rep = new SailRepository(sail);
    rep.initialize();
    sail.addStatement(subj, pred, obj);
    sail.commit();
    TupleQuery q = rep.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, "select ?s ?p ?o where {<http://whatever/subj/> <http://whatever/pred/> \"whatever\"}");
    TupleQueryResult res = q.evaluate();
    assertTrue(res.hasNext());
    rep.shutDown();
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:18,代码来源:HBaseSailTest.java

示例2: testEvaluateWithContext

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入方法依赖的package包/类
@Test
public void testEvaluateWithContext() throws Exception {
    ValueFactory vf = SimpleValueFactory.getInstance();
    Resource subj = vf.createIRI("http://whatever/subj/");
    IRI pred = vf.createIRI("http://whatever/pred/");
    Value obj = vf.createLiteral("whatever");
    IRI context = vf.createIRI("http://whatever/context/");
    CloseableIteration<? extends Statement, SailException> iter;
    HBaseSail sail = new HBaseSail(HBaseServerTestInstance.getInstanceConfig(), "whatevertable", true, 0, true, 0, null, null);
    SailRepository rep = new SailRepository(sail);
    rep.initialize();
    sail.addStatement(subj, pred, obj, context);
    sail.commit();
    TupleQuery q = rep.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, "select ?s ?p ?o from named <http://whatever/context/> where {<http://whatever/subj/> <http://whatever/pred/> \"whatever\"}");
    TupleQueryResult res = q.evaluate();
    assertFalse(res.hasNext());
    rep.shutDown();
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:19,代码来源:HBaseSailTest.java

示例3: run

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入方法依赖的package包/类
void run(Configuration configuration) throws ExportException {
    try {
        SailRepository rep = new SailRepository(new HBaseSail(configuration, htableName, false, 0, true, 0, elasticIndexURL, null));
        rep.initialize();
        try {
            writer.initTimer();
            log.logStatus("Query execution started");
            Query q = rep.getConnection().prepareQuery(QueryLanguage.SPARQL, sparqlQuery);
            if (q instanceof TupleQuery) {
                writer.writeTupleQueryResult(((TupleQuery)q).evaluate());
            } else if (q instanceof GraphQuery) {
                writer.writeGraphQueryResult(((GraphQuery)q).evaluate());
            } else {
                throw new ExportException("Only SPARQL Tuple and Graph query types are supported.");
            }
            log.logStatus("Export finished");
        } finally {
            rep.shutDown();
        }
    } catch (RepositoryException | MalformedQueryException | QueryEvaluationException e) {
        throw new ExportException(e);
    } finally {
        writer.close();
    }
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:26,代码来源:HalyardExport.java

示例4: timestampTest

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入方法依赖的package包/类
@Test
public void timestampTest() throws Exception {
    CloseableIteration<? extends Statement, SailException> iter;
    HBaseSail sail = new TimeAwareHBaseSail(HBaseServerTestInstance.getInstanceConfig(), "timestamptable", true, 0, true, 0, null, null);
    SailRepository rep = new SailRepository(sail);
    rep.initialize();
    SailRepositoryConnection con = rep.getConnection();
    assertTrue(testUpdate(con, "insert {<http://whatever> <http://whatever> <http://whatever>} where {bind(2 as ?HALYARD_TIMESTAMP_SPECIAL_VARIABLE)}"));
    assertTrue(testUpdate(con, "delete {<http://whatever> <http://whatever> <http://whatever>} where {bind(1 as ?HALYARD_TIMESTAMP_SPECIAL_VARIABLE)}"));
    assertFalse(testUpdate(con, "delete {<http://whatever> <http://whatever> <http://whatever>} where {bind(4 as ?HALYARD_TIMESTAMP_SPECIAL_VARIABLE)}"));
    assertFalse(testUpdate(con, "insert {<http://whatever> <http://whatever> <http://whatever>} where {bind(3 as ?HALYARD_TIMESTAMP_SPECIAL_VARIABLE)}"));
    assertTrue(testUpdate(con, "insert {<http://whatever> <http://whatever> <http://whatever>} where {bind(4 as ?HALYARD_TIMESTAMP_SPECIAL_VARIABLE)}"));
    rep.shutDown();
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:15,代码来源:TimeAwareHBaseSailTest.java

示例5: evaluate

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入方法依赖的package包/类
public Map<String, List<List<Object>>> evaluate(String queries, String cfgName, List<String> endpoints) throws Exception {
	List<List<Object>> report = new ArrayList<List<Object>>();
	List<List<Object>> sstreport = new ArrayList<List<Object>>();
	Map<String, List<List<Object>>> result = new HashMap<String, List<List<Object>>>();
	result.put("report", report);
	result.put("sstreport", sstreport);
	
	List<String> qnames = Arrays.asList(queries.split(" "));
	for (String curQueryName : qnames)
	{
		List<Object> reportRow = new ArrayList<Object>();
		report.add(reportRow);
		String curQuery = qp.getQuery(curQueryName);
		reportRow.add(curQueryName);
		
		List<Object> sstReportRow = new ArrayList<Object>();
		sstreport.add(sstReportRow);
		sstReportRow.add(curQueryName);
		
		Config config = new Config(cfgName);
		SailRepository repo = null;
		TupleQueryResult res = null;
		
		try {
			repo = FedXFactory.initializeSparqlFederation(config, endpoints);
			TupleQuery query = repo.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, curQuery);
			
		   	long startTime = System.currentTimeMillis();
		   	res = query.evaluate();
		    long count = 0;
		
		    while (res.hasNext()) {
		    	BindingSet row = res.next();
		    	System.out.println(count+": "+ row);
		    	count++;
		    }
		  
		    long runTime = System.currentTimeMillis() - startTime;
		    reportRow.add((Long)count); reportRow.add((Long)runTime);
		    sstReportRow.add((Long)count);
		    sstReportRow.add(QueryInfo.queryInfo.get().numSources.longValue());
		    sstReportRow.add(QueryInfo.queryInfo.get().totalSources.longValue());
		    log.info(curQueryName + ": Query exection time (msec): "+ runTime + ", Total Number of Records: " + count + ", Source count: " + QueryInfo.queryInfo.get().numSources.longValue());
		    //log.info(curQueryName + ": Query exection time (msec): "+ runTime + ", Total Number of Records: " + count + ", Source Selection Time: " + QueryInfo.queryInfo.get().getSourceSelection().time);
		} catch (Throwable e) {
			e.printStackTrace();
			log.error("", e);
			File f = new File("results/" + curQueryName + ".error.txt");
			ByteArrayOutputStream os = new ByteArrayOutputStream();
			PrintStream ps = new PrintStream(os);
			e.printStackTrace(ps);
			ps.flush();
			FileUtils.write(f, os.toString("UTF8"));
			reportRow.add(null); reportRow.add(null);
		} finally {
			if (null != res) {
	    		res.close();
	    	}
			
	    	if (null != repo) {
	    	    repo.shutDown();
	    	}
        }
	}
	return result;
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:67,代码来源:QueryEvaluation.java

示例6: testBulkLoad

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入方法依赖的package包/类
@Test
public void testBulkLoad() throws Exception {
    File root = File.createTempFile("test_triples", "");
    root.delete();
    root.mkdirs();
    try (PrintStream ps = new PrintStream(new File(root, "test_triples.jsonld"))) {
        ps.println("{\"@graph\": [");
        for (int i = 0; i < 10; i++) {
            if (i > 0) ps.print(',');
            ps.println("{\"@id\": \"http://whatever/subj" + i +"\"");
            for (int j=0; j < 10; j++) {
                ps.println(",\"http://whatever/pred" + j +"\": [");
                for (int k=0; k < 9; k++) {
                    if (k > 0) ps.print(',');
                    ps.print("\"literal" + k + "\"");
                }
                ps.println(']');
            }
            ps.println("}");
        }
        ps.println("]}");
    }
    try (PrintStream ps = new PrintStream(new GZIPOutputStream(new FileOutputStream(new File(root, "test_triples.nt.gz"))))) {
        for (int i = 0; i < 100; i++) {
            ps.println("<http://whatever/NTsubj> <http://whatever/NTpred" + i + "> \"whatever NT value" + i + "\" .");
        }
    }
    try (PrintStream ps = new PrintStream(new File(root, "test_triples_invalid.nt"))) {
        ps.println("this is an invalid NT file content");
    }
    File htableDir = File.createTempFile("test_htable", "");
    htableDir.delete();
    assertEquals(0, ToolRunner.run(HBaseServerTestInstance.getInstanceConfig(), new HalyardBulkLoad(), new String[]{"-Dhalyard.table.splitbits=-1", "-Dhalyard.parser.skipinvalid=true", root.toURI().toURL().toString(), htableDir.toURI().toURL().toString(), "bulkLoadTable"}));

    HBaseSail sail = new HBaseSail(HBaseServerTestInstance.getInstanceConfig(), "bulkLoadTable", false, 0, true, 0, null, null);
    SailRepository rep = new SailRepository(sail);
    rep.initialize();
    TupleQuery q = rep.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, "select (count(*) as ?c) where {?s ?p ?o}");
    TupleQueryResult res = q.evaluate();
    assertTrue(res.hasNext());
    Value c = res.next().getValue("c");
    assertNotNull(c);
    assertTrue(c instanceof Literal);
    assertEquals(1000, ((Literal)c).intValue());
    rep.shutDown();
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:47,代码来源:HalyardBulkLoadTest.java


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