[
https://issues.apache.org/jira/browse/JENA-362?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14876738#comment-14876738
]
François-Paul Servant commented on JENA-362:
--------------------------------------------
Hy Andy,
sorry with my comment, which is badly formulated. When O is null of course,
there's nothing to hope. My question is about the case when L is null, and S
also is. The current codebase (which includes the change that I had proposed)
has a very poor performance for this case.
For instance, calling
listStatements(null, RDFS.label, "some text", null)
is terrible when you have a large dataset.
It is very slow, because in this case, my code calls
listStatements(null, RDFS.label, Node.ANY)
I don't say that I have a better solution. I don't know whether there is one in
the general case. The only thing that I can think of is looping over the ISO
langs and call
listStatements(null, RDFS.label, "some text", lang). If the dataset is large,
that would be much faster. A triple store may provide a better implementation
of the method (depending on the way it indexes the things). I don't know what
TDB does internally (when indexing string literal, do the keys include the lang
or not?) - but I can say that calling
(null,rdfs:label,"some text",null)
on a moderately large TDB triple store is *very* slow - so, my code is called
:-(
Maybe, at least, the documentation about the method in question should warn
about this performance issue - which is not obvious: of the 3 components of a
triple, you may think that you gave 2 of them, and that this should be enough
to get a fast result.
> model.listStatements(s,p,o,lang) has problems when o or lang is null
> --------------------------------------------------------------------
>
> Key: JENA-362
> URL: https://issues.apache.org/jira/browse/JENA-362
> Project: Apache Jena
> Issue Type: Bug
> Components: Jena
> Affects Versions: Jena 2.7.4
> Reporter: François-Paul Servant
> Assignee: Andy Seaborne
> Priority: Minor
> Fix For: Jena 2.10.0
>
> Attachments: ListStatementTest.java, ModelCom.java
>
>
> 1) model.listStatements(s,p,null,lang) doesn't filter on lang param
> 2) model.listStatements(s,p,o,null) only returns statements whose object has
> lang "" (when o != null)
> TEST 1
> import org.junit.Test;
> import com.hp.hpl.jena.rdf.model.*;
> public class LstStmt1 {
> @Test
> public final void test() {
> Model m = ModelFactory.createDefaultModel();
> Resource s = m.createResource("http://www.a.com/s");
> Property p = m.createProperty("http://www.a.com/p");
> m.add(s,p,m.createResource("http://www.a.com/o"));
> m.add(s,p,"texte","fr");
> m.add(s,p,"text","en");
>
> StmtIterator it = m.listStatements(s, p, null,"en");
> // list all the statements - not what one can expect
> for (;it.hasNext();) {
> System.out.println(it.next());
> }
> }
> }
> TEST2
> public class LstStmt2 {
> @Test
> public final void test() {
> Model m = ModelFactory.createDefaultModel();
> Resource s = m.createResource("http://www.a.com/s");
> Property p = m.createProperty("http://www.a.com/p");
> m.add(s,p,"text","en");
> m.add(s,p,"text");
>
> StmtIterator it = m.listStatements(s, p,"text",null);
> // should list the 2 statements, but doesn't: only the one
> without lang
> for (;it.hasNext();) {
> System.out.println(it.next());
> }
> }
> }
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)