|
|
Index
| Recent Threads
| Who's Online
| User List
| Search
| Help
| |
|
Forum has been closed down This forum has been closed down due to extensive spamming activities. Please use the mailing list instead. |
![]() |
openRDF.org Forum » Sesame & Rio: Help » Thread: Inconsistent BindingSet results from same query |
|
Total posts in this thread: 4 |
[Add To My Favorites] [Watch this Thread] |
| Author |
|
|
Aug 9, 2007 10:42:18 AM
gregor Regular
|
Hi there, I'm running a prepared query that produces one of two very different result BindingSet formats one of which I expect and one of which I do not. When I get the "wrong" one I have to restart the app server maybe two or three times to get it to work again, after which it seems to work as expected untill I restart the app server again in which case it might or might not work. It's a bit difficult to explain the difference in words so I have attached a couple of images from my debugger to illustrate. Basically in the "right" case I get a map of my select vars against result values for each tuple returned. In the "wrong" case I do not get a map, I get a pair of lists. The query is: private static String rMapQueryStr = "SELECT " + Names.TERM + "," + Names.LABEL + "," + Names.ID I am hoping this problem is recognisable as I have no idea what is going on here ---------------------------------------- ---------------------------------------- ---------------------------------------- [Edit 1 times, last edit by arjohn at Aug 14, 2007 3:17:24 PM] |
||
|
|
Aug 14, 2007 3:26:57 PM
arjohn OpenRDF project lead The Netherlands Joined: Jan 23, 2004 Posts: 1289 Status: Offline |
This looks just fine to me. Your screenshots show two different implementations of the BindingSet interface, one that uses a Map internally and one that uses two Lists internally (MapBindingSet and ListBindingSet, respectively). Semantically, these implementations are identical and return the same results when the methods defined in BindingSet are used. Unless you're trying to cast the BindingSet objects to a more specific type, this shouldn't be a problem for you. ---------------------------------------- Arjohn Kampman, OpenRDF project lead, Aduna |
||
|
|
Aug 15, 2007 3:08:16 PM
gregor Regular
|
Thanks for the reply arjohn. The big difference from my point of view is that the semantics of BindingSet.hasBinding(..) appear to be different between the Map and ArrayList implementations. In the Map case if a result row does not have a value for a particular variable specified in the query select clause then hasBinding(..) returns false, but in the ArrayList case there is a binding created for each and every variable specified in the select clause irrespective of it having a value therefore hasBinding(..) always returns true. This is why the following code doesn't work when the array implementation is in effect because everything goes into the "SUPER" bucket. public class IpsvRmapServiceImpl extends RemoteServiceServlet implements IpsvRmapService { public RMapCmd getRMap(RMapCmd cmd) { TupleQuery query = QueryBank.getInstance().getRMapQuery(cmd.getTargetID()); RelationMap rMap = new RelationMap(); try { TupleQueryResult result = query.evaluate(); while (result.hasNext()) { BindingSet bindingSet = result.next(); Term term = new Term(bindingSet.getValue(Names.LABEL).toString(), bindingSet.getValue(Names.ID).toString()); if (bindingSet.hasBinding(Names.SUPER)) { rMap.getbroader().add(term); } else if (bindingSet.hasBinding(Names.SUB)) { rMap.getNarrower().add(term); } else if (bindingSet.hasBinding(Names.REL)) { rMap.getRelated().add(term); } else if (bindingSet.hasBinding(Names.SIB)) { rMap.getSiblings().add(term); } else if (bindingSet.hasBinding(Names.TERM)) { rMap.setTerm(term); } } } catch (QueryEvaluationException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } cmd.setRMap(rMap); return cmd; } I'll have to look at rewriting this to cater for both types of BindingSet I guess, but is there a way to force one or other implementation? |
||
|
|
Aug 16, 2007 1:14:23 PM
arjohn OpenRDF project lead The Netherlands Joined: Jan 23, 2004 Posts: 1289 Status: Offline |
The different behaviour of ListBindingSet.hasValue(String) is a bug. I just logged it in our issue tracker as [SES-441]. I'll fix this as soon as possible. ---------------------------------------- Arjohn Kampman, OpenRDF project lead, Aduna |
||
|
| [Show Printable Version of Thread] |