-
把TBD数据导入allegrograph
普通类 -
- 支持
- 批判
- 提问
- 解释
- 补充
- 删除
-
-
1.需求
tdb免费但有时会出错,我们希望能够发现那些地方出错了,我们可以尝试把数据导入allegrograph,看看具体哪个三元组有问题。
-
2.代码实现
- package allegroph;
- /**
- * 把JENA TDB数据导入allegrograph
- * @author : 丁国柱
- * @date : 2014-10-13 上午9:43:21
- */
- import bnu.edu.lcell.graphdatabase.AllegrographConnection;
- import com.franz.agraph.jena.AGGraph;
- import com.franz.agraph.jena.AGGraphMaker;
- import com.franz.agraph.jena.AGModel;
- import com.franz.agraph.jena.AGReasoner;
- import com.hp.hpl.jena.query.Dataset;
- import com.hp.hpl.jena.query.ReadWrite;
- import com.hp.hpl.jena.rdf.model.InfModel;
- import com.hp.hpl.jena.rdf.model.Model;
- import com.hp.hpl.jena.rdf.model.Statement;
- import com.hp.hpl.jena.rdf.model.StmtIterator;
- import com.hp.hpl.jena.tdb.TDBFactory;
- import com.hp.hpl.jena.tdb.base.file.Location;
- public class ImportRDFtoAllegrograph {
- static AGGraphMaker maker = null;
- static AGGraph graph = null;
- static AGModel model = null;
- AGReasoner reasoner = null;
- InfModel infmodel = null;
- public static void main(String[] args) throws Exception {
- maker = AllegrographConnection.getConn("test");
- graph = maker.getGraph();
- model = new AGModel(graph);
- Location location = new Location("lcellDB/learningcell3");
- //获取jena tdb数据集
- Dataset dataset = TDBFactory.createDataset(location);
- //开始只读事务
- dataset.begin(ReadWrite.READ);
- //获取默认的model
- Model jenaModel =dataset.getDefaultModel();
- //获得所有的Statement
- StmtIterator iterator = jenaModel.listStatements();
- int i=1;
- while (iterator.hasNext()) {
- Statement statement = (Statement) iterator.next();
- model.add(statement);
- model.commit();
- System.out.println("增加第 " + i + "条数据");
- i++;
- }
- model.close();
- }
- }
-
-
- 标签:
- 导入
- jenatdb
- graph
- 获取
- 数据
- null
- 代码
- tbd
- statement
- 实现
- 2.
- 1.
- allegrograph
-
学习元评论 (0条)
聪明如你,不妨在这 发表你的看法与心得 ~