You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Christoper Blunck <ch...@thebluncks.com> on 2011/05/18 05:18:33 UTC
Creating an OntModel without first loading all triples from SDB
Hi all,
I have a question about SDB and loading triples from a store before
instantiating an OntModel and I was hoping for some help.
I use the following boiler-plate to use SDB to instantiate a Model and then
create an OntModel from my Model:
Store store = SDBFactory.connectStore("/Users/chris/sdb.ttl");
Model model = SDBFactory.connectDefaultModel(store);
OntModel ontology =
ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, model);
I need the OntModel because I use owl2java to translate an OWL to Jena java
classes and I then want to instantiate them and use them.
The JavaDocs for ModelFactory.createOntologyModel clearly state: Answer a
new ontology model, constructed according to the given ontology model
specification, and starting with the ontology data in the given model.
Note the "starting with the ontology data in the given model". I've seen
that the resulting OntModel does in fact contain all of the triples loaded
from the SDB store.
In my code I'm not interested in querying. I'm "write-only" and I'm simply
trying to insert triples into the store using the owl2java Jena based
classes I instantiate and populate.
Is there a way for me to use SDB to persist data in a "write-only" way where
I don't read the existing triples out of the store first?
Perhaps there's a better way for me to create an OntModel than going through
ModelFactory.createOntologyModel()?
Any advice you can offer would be greatly appreciated. Thanks!
-c
--
Christopher Blunck
chris@thebluncks.com
Re: Creating an OntModel without first loading all triples from SDB
Posted by Ian Dickinson <ia...@epimorphics.com>.
Hi Christopher,
On 18/05/11 04:18, Christoper Blunck wrote:
> I have a question about SDB and loading triples from a store before
> instantiating an OntModel and I was hoping for some help.
>
> I use the following boiler-plate to use SDB to instantiate a Model and then
> create an OntModel from my Model:
> Store store = SDBFactory.connectStore("/Users/chris/sdb.ttl");
> Model model = SDBFactory.connectDefaultModel(store);
> OntModel ontology =
> ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, model);
>
> I need the OntModel because I use owl2java to translate an OWL to Jena java
> classes and I then want to instantiate them and use them.
>
> The JavaDocs for ModelFactory.createOntologyModel clearly state: Answer a
> new ontology model, constructed according to the given ontology model
> specification, and starting with the ontology data in the given model.
>
> Note the "starting with the ontology data in the given model". I've seen
> that the resulting OntModel does in fact contain all of the triples loaded
> from the SDB store.
Contain in this context means "has access to". No data is copied out of
the SDB model into memory - every interaction with the model, whether a
write or a read, gets translated behind-the-scenes into a call into the
database. The term "OWL_MEM" is slightly unfortunate here: _MEM in this
case means "just the raw model with no inference", not "everything
exists in memory"
> In my code I'm not interested in querying. I'm "write-only" and I'm simply
> trying to insert triples into the store using the owl2java Jena based
> classes I instantiate and populate.
Then what you have should be fine.
> Is there a way for me to use SDB to persist data in a "write-only" way where
> I don't read the existing triples out of the store first?
It's more the other way around: using an SDB-backed model, you have to
go an extra step to get the triples into memory, e.g. for performance
enhancement.
Ian
--
____________________________________________________________
Ian Dickinson Epimorphics Ltd, Bristol, UK
mailto:ian@epimorphics.com http://www.epimorphics.com
cell: +44-7786-850536 landline: +44-1275-399069
------------------------------------------------------------
Epimorphics Ltd. is a limited company registered in England
(no. 7016688). Registered address: Court Lodge, 105 High St,
Portishead, Bristol BS20 6PT, UK
Re: Creating an OntModel without first loading all triples from SDB
Posted by Chris Dollin <ch...@epimorphics.com>.
Christopher Blunck said:
> The JavaDocs for ModelFactory.createOntologyModel clearly state: Answer a
> new ontology model, constructed according to the given ontology model
> specification, and starting with the ontology data in the given model.
>
> Note the "starting with the ontology data in the given model". I've seen
> that the resulting OntModel does in fact contain all of the triples loaded
> from the SDB store.
Yes -- but it contains them because the SDB model is part of the OntModel.
When you query an OntModel, it queries the base model (your SDB model
in this case) and any imported models. The OntModel doesn't have a copy
of the base model; it just refers to it.
> In my code I'm not interested in querying. I'm "write-only" and I'm simply
> trying to insert triples into the store using the owl2java Jena based
> classes I instantiate and populate.
That's fine. If you add triples to an OntModel, they are pushed into the
base model.
> Is there a way for me to use SDB to persist data in a "write-only" way where
> I don't read the existing triples out of the store first?
If you (or the OntModel code when doing its onw queries) don't ask for the triples,
they aren't pulled out of the store.
Chris
PS Things are rather different if your OntModel does inference, since it
then has to store intermediate results in memory and consult possibly
all of the base & imported models involved.
--
"You're down as expendable. You don't get a weapon." /Dark Lord of Derkholm/
Epimorphics Ltd, http://www.epimorphics.com
Registered address: Court Lodge, 105 High Street, Portishead, Bristol BS20 6PT
Epimorphics Ltd. is a limited company registered in England (number 7016688)