本文整理汇总了Java中org.apache.jena.query.Dataset.close方法的典型用法代码示例。如果您正苦于以下问题:Java Dataset.close方法的具体用法?Java Dataset.close怎么用?Java Dataset.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.query.Dataset
的用法示例。
在下文中一共展示了Dataset.close方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.jena.query.Dataset; //导入方法依赖的package包/类
public static void main(String[] args) {
if (args.length != 3) {
System.err.println("Wrong arguments");
showUsage();
}
System.out.println("Model file : " + args[0]);
System.out.println("Model URI : " + args[1]);
System.out.println("Model tdb dir: " + args[2]);
Dataset dataset = TDBFactory.createDataset(args[2]);
try {
Model model = dataset.getNamedModel(args[1]);
TDBLoader.loadModel(model, args[0]);
} finally {
dataset.close();
}
}
示例2: queryData
import org.apache.jena.query.Dataset; //导入方法依赖的package包/类
public static List<String> queryData(String query){
Dataset db = TDBFactory.createDataset("temp/dataset");
db.begin(ReadWrite.READ);
Model model = db.getDefaultModel();
Query q = QueryFactory.create(query);
QueryExecution qexec = QueryExecutionFactory.create(query, model);
ResultSet results = qexec.execSelect();
List<String> answer = new ArrayList<String>();
while(results.hasNext()){
QuerySolution t = results.nextSolution();
RDFNode x = t.get("x");
String s = x.toString();
System.out.println(s);
answer.add(s.substring(7));
}
qexec.close();
db.close();
return answer;
}
示例3: getFragmentTriples
import org.apache.jena.query.Dataset; //导入方法依赖的package包/类
/**
* Return all triples from the given dataset in one model, i.e., all graphs in the dataset are merged.
* @param dataset The dataset to get the model from
* @return The model containing all triples from the graphs from the dataset.
*/
private Model getFragmentTriples(final Dataset dataset) {
Model fragmentTriples = ModelFactory.createDefaultModel();
// add unnamed graph
Model defaultModel = dataset.getDefaultModel();
fragmentTriples.add(defaultModel);
// add named graph(s)
Iterator<String> names = dataset.listNames();
while (names.hasNext()) {
String name = names.next();
Model namedModel = dataset.getNamedModel(name);
fragmentTriples.add(namedModel);
namedModel.close();
}
dataset.close();
return fragmentTriples;
}
示例4: main
import org.apache.jena.query.Dataset; //导入方法依赖的package包/类
public static void main(String... argv)
{
// Direct way: Make a TDB-back Jena model in the named directory.
String directory = "MyDatabases/DB1" ;
Dataset dataset = TDBFactory.createDataset(directory) ;
// Potentially expensive query.
String sparqlQueryString = "SELECT (count(*) AS ?count) { ?s ?p ?o }" ;
// See http://incubator.apache.org/jena/documentation/query/app_api.html
Query query = QueryFactory.create(sparqlQueryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, dataset) ;
try {
ResultSet results = qexec.execSelect() ;
for ( ; results.hasNext() ; )
{
QuerySolution soln = results.nextSolution() ;
int count = soln.getLiteral("count").getInt() ;
System.out.println("count = "+count) ;
}
} finally { qexec.close() ; }
// Close the dataset.
dataset.close();
}
示例5: main
import org.apache.jena.query.Dataset; //导入方法依赖的package包/类
public static void main(String... argv)
{
// Direct way: Make a TDB-back Jena model in the named directory.
String directory = "MyDatabases/DB1" ;
Dataset dataset = TDBFactory.createDataset(directory) ;
// Potentially expensive query.
String sparqlQueryString = "SELECT (count(*) AS ?count) { ?s ?p ?o }" ;
// See http://incubator.apache.org/jena/documentation/query/app_api.html
Query query = QueryFactory.create(sparqlQueryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, dataset) ;
ResultSet results = qexec.execSelect() ;
ResultSetFormatter.out(results) ;
qexec.close() ;
dataset.close();
}
示例6: oneTimeTearDown
import org.apache.jena.query.Dataset; //导入方法依赖的package包/类
@AfterClass
public static void oneTimeTearDown() {
// Close dataset
Dataset ds = ThingDirectory.get().dataset;
ds.close();
deleteAll(dbPath); // FIXME returns false?
deleteAll(idxPath);
}
示例7: queryData2
import org.apache.jena.query.Dataset; //导入方法依赖的package包/类
public static Boolean queryData2(String query){
Dataset db = TDBFactory.createDataset("temp/dataset");
db.begin(ReadWrite.READ);
Model model = db.getDefaultModel();
Query q = QueryFactory.create(query);
QueryExecution qexec = QueryExecutionFactory.create(query, model);
List<String> answer = new ArrayList<String>();
Boolean t = (qexec.execAsk());
qexec.close();
db.close();
return t;
}
示例8: oneTimeTearDown
import org.apache.jena.query.Dataset; //导入方法依赖的package包/类
@AfterClass
public static void oneTimeTearDown() {
// Close dataset
Dataset ds = Repository.get().dataset;
ds.close();
deleteAll(dbPath); // FIXME returns false?
deleteAll(idxPath);
}
示例9: main
import org.apache.jena.query.Dataset; //导入方法依赖的package包/类
public static void main(String... argv)
{
// Direct way: Make a TDB-back Jena model in the named directory.
String directory = "MyDatabases/DB1" ;
Dataset ds = TDBFactory.createDataset(directory) ;
Model model = ds.getDefaultModel() ;
// ... do work ...
// Close the dataset.
ds.close();
}
示例10: main
import org.apache.jena.query.Dataset; //导入方法依赖的package包/类
public static void main(String... argv)
{
String assemblerFile = "Store/tdb-assembler.ttl" ;
Dataset ds = TDBFactory.assembleDataset(assemblerFile) ;
// ... do work ...
ds.close() ;
}