无法使用耶拿(Jena)写入大猫头鹰文件 [英] Can't write large owl file with Jena

查看:112
本文介绍了无法使用耶拿(Jena)写入大猫头鹰文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图以一组三元组的形式转换数据库表中包含的数据,所以我正在使用Jena Java库编写一个owl文件. 我已经用少量的表记录(100)成功地做到了这一点,它对应于.owl文件中的近20.000行,对此我感到满意.

I'm trying to convert data contained in a database table in a set of triples so I'm writing an owl file using Jena java library. I have successfully done it with a small number of table records (100) which corresponds to nearly 20.000 rows in the .owl file and I'm happy with it.

要编写猫头鹰文件,我使用了以下代码(mOntModel对象):

To write the owl file I have used the following code (m is an OntModel object):

 BufferedWriter out = null;
 try {
    out = new BufferedWriter (new FileWriter(FILENAME));        
    m.write(out);
    out.close();
 }catch(IOException e) {};

不幸的是,当我尝试对表的整个结果集(800.000条记录)执行相同操作时,eclipse控制台向我显示了以下异常:

Unfortunately when I try to do the same with the entire result set of the table (800.000 records) eclipse console shows me the exception:

Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded

该异常是由

m.write(out);

我绝对确定模型已正确填充,因为我尝试在不创建owl文件的情况下执行程序,并且一切正常. 要解决此问题,我尝试在run->configuration->vm arguments中增加堆内存设置-Xmx4096M,但错误仍然出现.

I'm absolutely sure the model is correctly filled because I tried to execute the program without creating the owl file and all worked fine. To fix it, I tried to increase heap memory setting -Xmx4096Minrun->configuration->vm arguments but the error still appears.

我正在Macbook上执行应用程序,因此我没有无限的内存.有机会完成任务吗?也许有一种更有效的方法来存储模型吗?

I'm executing the application on a macbook so I have no unlimited memory. Are there chances to complete the task? maybe is there a more efficient way to store the model?

推荐答案

默认格式为RDF/XML是一种漂亮的形式,但是要计算漂亮",在开始编写之前需要完成很多工作.这包括建立内部数据结构.某些形状的数据导致需要进行大量的工作来搜索最漂亮的"变化.

The default format is RDF/XML is a pretty form, but to calculate the "pretty", quite a lot of work needs to be done before writing starts. This includes building up internal datstructures. Some shapes of data cause quite extensive work to be done searching for the "most pretty" variation.

RDF/XML的漂亮格式是最昂贵的格式.即使漂亮的Turtle形式也更便宜,尽管它仍然涉及一些准备工作计算.

RDF/XML in pretty form is the most expensive format. Even the pretty Turtle form is cheaper though it still involves some preparation calculations.

以更简单的格式用RDF/XML编写,没有复杂的漂亮功能:

To write in RDF/XML in a simpler format, with no complex pretty features:

RDFDataMgr.write(System.out, m, RDFFormat.RDFXML_PLAIN);

首选输出流,输出将为UTF-8-"new BufferedWriter (new FileWriter(FILENAME));"将使用平台默认字符集.

Output streams are preferred, and the output will be UTF-8 - "new BufferedWriter (new FileWriter(FILENAME));" will use the platform default character set.

有关其他格式和变体,请参阅文档:

See the documentation for other formats and variations:

https://jena.apache.org/documentation/io/rdf- output.html

,例如RDFFormat.TURTLE_BLOCKS.

这篇关于无法使用耶拿(Jena)写入大猫头鹰文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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