Reputation: 419
I created a model in jena with this java code
Model m = ModelFactory.createDefaultModel();
Resource a1 = m.createResource("<http://Actor1>");
Resource a2 = m.createResource("<http://Actor2>");
Resource a3 = m.createResource("<http://Actor3>");
Property p3 = m.createProperty("<http://MovieTitle>");
Resource m1 = m.createResource("<http://Movie1>");
m1.addProperty(p3, "<http://M1>");
Resource m2 = m.createResource("<http://Movie2>");
m2.addProperty(p3, "<http://M2>");
Resource m3 = m.createResource("<http://Movie3>");
m3.addProperty(p3, "<http://M3>");
Resource m4 = m.createResource("<http://Movie4>");
m4.addProperty(p3, "<http://M4>");
Property p1 = m.createProperty("<http://dateOfbirth>");
Property p2 = m.createProperty("<http://played>");
m.add(a1,p1 , "1980");
m.add(a2,p1 , "1981");
m.add(a3,p1 , "1982");
m.add(a1,p2 , m1);
m.add(a1,p2 , m2);
m.add(a1,p2 , m3);
m.add(a1,p2 , m4);
m.add(a2,p2 , m1);
m.add(a2,p2 , m3);
m.add(a3,p2 , m1);
m.add(a3,p2 , m3);
m.add(a3,p2 , m4);
now i want to convert this model into a jena tdb to create the stats.opt file for optimizing queries executed over this model. I know that rdf files can be loaded into tdb and create stats.opt using the command line. but i want to do it with my code. Is there a way to do it? Thanks!
Upvotes: 0
Views: 250
Reputation: 834
You can create your tdb in jena using -->
// First create an empty tdb
Dataset tdb = TDBFactory.createDataset(path2NewTdb);
// Then get its Model
Model tdbModel = tdb.getDefaultModel();
// Then update tdbModel. For example use the code you wrote
// above or if you already have a model use tdbModel.add(anotherModel)
// After that make sure to close everything
tdbModel.close();
tdb.close();
Upvotes: 1