将.trig文件加载到TDB中? [英] Loading a .trig file into TDB?

查看:112
本文介绍了将.trig文件加载到TDB中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在Windows 7上使用Jena和TDB用Java编写一些代码.

I am currently writing some code in Java, using Jena and TDB -- on a Windows 7.

我希望能够将一个(大).trig文件加载到TDB数据集中,以便查询更快一些.我目前拥有的代码是:

I want to be able to load a (large) .trig file into TDB Dataset so that querying is a bit faster. The code that I currently have is:

Dataset dataset = TDBFactory.createDataset(directoryPath);
Model tdb = dataset.getDefaultModel();
RDFDataMgr.read(tdb, inputFilePath);
try {
        String theQuery = readFile(testQueryPath, Charset.defaultCharset());        
        Query query = QueryFactory.create(theQuery);
        QueryExecution qe = QueryExecutionFactory.create(query, dataset);
        com.hp.hpl.jena.query.ResultSet results =  qe.execSelect();

        // Output query results    
        ResultSetFormatter.out(System.out, results, query);
        qe.close();

} catch (IOException e) {
        e.printStackTrace();
}

我也尝试过:

FileManager.get().readModel( tdb, inputFilePath);

代替:

RDFDataMgr.read(tdb, inputFilePath);

我收到以下警告:

2014-06-13 13:02:26 WARN暴乱:77-仅预期三元组或默认图形数据:已忽略命名图形数据

2014-06-13 13:02:26 WARN riot:77 - Only triples or default graph data expected : named graph data ignored

我运行的SPARQL查询是:

The SPARQL queries I ran are:

PREFIX xsd: http://www.w3.org/2001/XMLSchema#

PREFIX dc: http://purl.org/dc/elements/1.1/

PREFIX dc: http://purl.org/dc/elements/1.1/

PREFIX:<.>

PREFIX : <.>

选择*

{

{?s?p?o} UNION {图形?g {?s?p?o}}

{ ?s ?p ?o } UNION { GRAPH ?g { ?s ?p ?o } }

}

也是相同的,但是没有UNION和GRAPH的东西.

and also the same one but without the UNION and GRAPH things.

查询不返回任何内容.

有人看到明显的问题或知道如何将.trig文件加载到TDB中吗?

Does anyone see an apparent problem or know how to load .trig files into TDB?

推荐答案

您刚刚读入数据集:

RDFDataMgr.read(dataset, inputFilePath);

内部写事务会更好,否则请在退出前调用TDB.sync(dataset).

Inside write transaction would be better else call TDB.sync(dataset) before you exit.

您的代码每次运行都会加载.如果文件确实很大,请在运行查询程序之前使用tdbloader(大容量加载程序).

You code loads it every run. If the file is really big, use tdbloader, the bulk loader, before running the query program.

这篇关于将.trig文件加载到TDB中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆