> On May 11, 2018, at 6:48 PM, Andy Seaborne <[email protected]> wrote:
> On 11/05/18 20:35, ajs6f wrote:
>>> On May 9, 2018, at 3:31 AM, Dave Reynolds <[email protected]> wrote:
>>> On 08/05/18 16:55, ajs6f wrote:
>>>> Forking a thread off to dev@:
>>>> Do we have a global policy about where null is accepted as a wildcard? I 
>>>> know it works in at least some places...
> 
> You have mentioned one place - any others?

I don't understand-- it was you who mentioned the places it is accepted, not 
me. I just pointed out that for at least some of those places, it is not 
documented. Some places are worse, e.g. DatasetGraph:

/** Find matching quads in the dataset - may include wildcards, Node.ANY or null
* @see Graph#find(Triple)
*/
public Iterator<Quad> find(Quad quad) ;

"wildcards, Node.ANY or null"? But Node.ANY and null _are_ the wildcards and 
they all behave the same way...?! The Javadocs for Graph just don't mention 
null as parameter at all.

I'm happy to make a PR for this-- I just want to make sure I have it straight 
myself. 

> The big pain with nulls is returned values leading to NPEs.
> That's not the case here, which is usage for arguments to functions/methods.

null _is_ a pain here. Accidentally passing a null reference into a method 
where it will be interpreted as wildcard can (e.g.) delete unexpected things or 
return a much larger query result than expected, _without any error_. That 
would be prevented by a null-object pattern. I understand that you may not have 
seen these problems, but I have. I'm not trying to argue that they deserve a 
solution that disrupts deployments (as Dave described) but that doesn't mean 
these kinds of problems don't exist.

>  This overlaps with the debate around Optional as argument.

No one is suggesting introducing Optional at all, or changing any return types, 
or removing null from the whole API or from Java (!). My question was pretty 
clear: are we keeping null-as-wildcard for the extant API, or requiring it for 
all new API, and Dave just answered it as I would: no, new API doesn't have to 
continue the pattern. I'll try to get in a PR for Graph/DatasetGraph Javadocs 
shortly.

ajs6f

> 
>       Andy
> 
> 
> 
>> ajs6f
>>> Dave
>>> 
>>>>> On May 8, 2018, at 11:51 AM, Andy Seaborne <[email protected]> wrote:
>>>>> 
>>>>> Barry,
>>>>> 
>>>>> As a general concept "matching" happens at different levels.
>>>>> 
>>>>> Triple.match corresponds to the matching done by Graph.find - RDF terms 
>>>>> (URI, bnode, literal) match exactly, and Node.ANY is a wildcard.
>>>>> 
>>>>> Triple t1 = Triple.ANY;
>>>>> Triple t2 = SSE.parseTriple("(:s :p :o)");
>>>>> t1.matches(t2) -> true
>>>>> t2.matches(t1) -> false
>>>>> 
>>>>> Variables are a concept for SPARQL - and matches usefully need to return 
>>>>> which variable matched which RDF Term.
>>>>> 
>>>>> Triple patterns match against graphs and return an iterator of ways they 
>>>>> match.
>>>>> 
>>>>> Consider cases like "?x ?p ?x" where the variables impose am additional 
>>>>> shape.
>>>>> 
>>>>> If you want variable bindings, you could build a SPARQL query or wrap up 
>>>>> some of the internal code e.g.
>>>>> 
>>>>> /** Evaluate a triple pattern */
>>>>> private static QueryIterator match(Graph source, Triple pattern) {
>>>>>    ExecutionContext execContext =
>>>>>          new ExecutionContext(ARQ.getContext(), source, null, null) ;
>>>>>    QueryIterator chain = QueryIterRoot.create(execContext)
>>>>>    chain = new QueryIterTriplePattern(chain, pattern, execContext) ;
>>>>>    return chain ;
>>>>> }
>>>>> 
>>>>>    Andy
>>>>> 
>>>>> On 08/05/18 09:21, Nouwt, B. (Barry) wrote:
>>>>>> Hi everybody,
>>>>>> I’m trying to reuse Apache Jena code that parses and matches triples. 
>>>>>> I’m currently looking at the SSE class’s parseTriple() method. This 
>>>>>> seems to fit my purpose for parsing a string representation of a triple 
>>>>>> into a triple object. I also noticed the following Javadoc on the 
>>>>>> Node.maches(Node) method:
>>>>>> Answer true iff this node accepts the other one as a match.
>>>>>> The default is an equality test; it is over-ridden in subclasses to
>>>>>> provide the appropriate semantics for literals, ANY, and variables.
>>>>>> Since this is exactly what I’m looking for, I’ve tried to match two 
>>>>>> triples using the matches() method, but it does not seem to work:
>>>>>> Triple t1 = SSE.parseTriple("(?s ?p ?o)");
>>>>>> Triple t2 = SSE.parseTriple("(test:subject test:predicate test:object)", 
>>>>>> pm);
>>>>>> t1.matches(t2)
>>>>>> The final statement returns false, while I would expect it to return 
>>>>>> true. Either, I’m missing something (which is completely realistic 😊), 
>>>>>> or I should use some other method to match two triples in the way 
>>>>>> described above.
>>>>>> Any help is appreciated!
>>>>>> Regards, Barry
>>>>>> This message may contain information that is not intended for you. If 
>>>>>> you are not the addressee or if this message was sent to you by mistake, 
>>>>>> you are requested to inform the sender and delete the message. TNO 
>>>>>> accepts no liability for the content of this e-mail, for the manner in 
>>>>>> which you use it and for damage of any kind resulting from the risks 
>>>>>> inherent to the electronic transmission of messages.

Reply via email to