Skip to content

Commit

Permalink
[ontodev#978] lowering memory consumption of convertModel.
Browse files Browse the repository at this point in the history
  • Loading branch information
psiotwo committed Mar 22, 2022
1 parent 3dffd12 commit b606910
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,14 @@ public static OWLOntology convertModel(Model model) throws OWLOntologyCreationEx
*/
public static OWLOntology convertModel(Model model, IOHelper ioHelper, String catalogPath)
throws IOException {
ByteArrayOutputStream os = new ByteArrayOutputStream();
RDFDataMgr.write(os, model, Lang.TTL);
return ioHelper.loadOntology(new ByteArrayInputStream(os.toByteArray()), catalogPath);
final File tempFile = File.createTempFile("robot", ".owl");
try (final BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile))) {
RDFDataMgr.write(os, model, Lang.TTL);
}
final OWLOntology ontology =
ioHelper.loadOntology(new BufferedInputStream(new FileInputStream(tempFile)), catalogPath);
tempFile.delete();
return ontology;
}

/**
Expand Down

0 comments on commit b606910

Please sign in to comment.