Search the web
Sign In
New User? Sign Up
jena-dev · Jena Developers
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Updating a Model   Message List  
Reply | Forward Message #40670 of 42071 |
Re: [jena-dev] Updating a Model

sanjayvenkat2000 wrote:
> I have an application where I need to update some resources in a dataset
(MasterModel). The information for the updates comes from another model
(UpdateModel) .
>
> I would like to get your opinion on how best to proceed. Data is stored using
TDB named graphs.
>
> Plan A:
> Use the Jena API to iterate over Resources in the UpdateModel.
> For each Resource, identify properties in the UpdateModel.
> Get MasterModel resource and delete identified properties.
> Add identified properties from UpdateModel into MasterModel.
>
> Plan B:
> Construct a string containing a SPARUL by listingStatements in the model.
>
> DELETE GRAPH <MasterModel> {
> <UpdateModel:uri> <UpdateModel:prop> ?any
> ...
> ...
> }
>
> INSERT GRAPH <MasterModel> {
> <UpdateModel:uri> <UpdateModel:prop> <UpdateModel:val>
> ...
> ...
> }
>
>
> I see Plan B getting into trouble if the UpdateModel is large as I will
unnecessarily create a query string that will get parsed again.

Normally the cost of disk accesses involved in the update will swamp
everything else and the cost of parsing the SPARUL is very unlikely to
be a bottleneck.

> With Plan A, I fear leaving hanging blank nodes around.

You have to account for bNodes in either case. If you have bNodes then
you'll need to scan the to-be-deleted data to check for bNodes,
reference count and add them to the deletion list. In that case I'd be
inclined towards plan A since you are scanning anyway.

If you do have blank nodes but are guaranteed they are only tree
structured then you simply need to scan the object values of the
to-be-deleted properties and for any that are bNodes scan all their
properties deleting them and recursively checking for bNodes.

If you are not guaranteed that the bNodes are tree structured but they
are only lattices with no cycles then you can use reference counting to
decide when to delete. In the most general case reference counting isn't
sufficient.

> I have noticed model.difference() but not sure which way to proceed.

Model.difference creates an in-memory copy of your base model, less the
model being subtracted, not relevant in your case.

Dave



Sun Jul 5, 2009 11:35 am

derihy
Offline Offline
Send Email Send Email

Forward
Message #40670 of 42071 |
Expand Messages Author Sort by Date

I have an application where I need to update some resources in a dataset (MasterModel). The information for the updates comes from another model (UpdateModel)...
sanjayvenkat2000
sanjayvenkat...
Offline Send Email
Jul 2, 2009
7:03 pm

... Normally the cost of disk accesses involved in the update will swamp everything else and the cost of parsing the SPARUL is very unlikely to be a...
Dave Reynolds
derihy
Offline Send Email
Jul 5, 2009
11:35 am

Dave ... Thanks for the detailed analysis. If I could eliminate the scanning by altering the SPARUL will it change the outcome towards Plan B? DELETE ?blank ?p...
sanjayvenkat2000
sanjayvenkat...
Offline Send Email
Jul 6, 2009
12:38 pm

... I'm not sure what fn:is_Blank_Node is supposed to do in the case where ?o is not a blank node, further you need to this recursively to catch cases where...
Dave Reynolds
derihy
Offline Send Email
Jul 6, 2009
3:27 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help