Adding 'only_inverse' parameter to Resource.load()
8 views
Skip to first unread message
Pēteris Caune
unread,
Apr 25, 2012, 11:16:40 AM4/25/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to surfrdf
Hi All,
I'm thinking of adding 'only_inverse' optional parameter to
Resource.load() method, for optimization purposes.
Resource.load() currently loads all direct and inverse attributes for
a given resource, and is very handy.
When using sparql_protocol plugin, this results in two SPARQL queries
getting executed.
I'm looking at optimizing client code and trying to cut down on number
of SPARQL queries executed. In cases I know inverse attributes won't
be accessed, and I'd like to be able to load just the direct
attributes.
It would work like this:
some_resource.load() <-- same as now, loads direct and inverse
attributes in two queries
some_resource.load(only_direct=True) <-- loads just direct
attributes, one query
On implementation side, it would then make sense to replace
Resource.__full boolean flag with Resource.__full_direct and
Resource.__full_inverse to keep track of what's loaded.
Any objections?
Cosmin Basca
unread,
Apr 25, 2012, 3:18:41 PM4/25/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sur...@googlegroups.com
Hi Peteris,
Since SuRF distinguishes between direct and indirect RDF attributes, I agree with your proposition. My only "objection" :) would be related to naming of the parameter. I feel that calling
some_resource.load(inverse=False) feels cleaner and is just as expressive as calling some_resource.load(only_direct=True), in addition the "inverse" attribute should be set to True by default, to keep SuRF contract API consistent. What do you think?
Cheers,
Cosmin
cuu...@gmail.com
unread,
Apr 27, 2012, 9:39:57 AM4/27/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sur...@googlegroups.com
Hi Cosmin,
yeah, "inverse" is shorter and looks cleaner than "only_direct". I
propose "only_direct" because it's already used in attribute queries
like:
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sur...@googlegroups.com
Hi,
If there was not an already existing property, I'd call it
"direct_only" rather than "only_direct" (sounds more "english" to me).
But if the name is already in use then there's no need to change it.