Hi,
1)  I am sure. Everything works fine if remove OPTIONAL clause. Any change on 
rdf namespace also works, but you know, resultset is empty.
2) Code failed while modelUri is not null. We always use a named graph.


We use `TDBFactory.createDataset(tdbDir)` creating dataset. I think it's a in 
memory dataset. No .lock file was found in our data directory.


Thanks for your reply.
Best regards.


------------------
Wang Tonghe


 




------------------ Original ------------------
From:  "Marc Agate";<[email protected]>;
Date:  Wed, Dec 27, 2017 11:01 AM
To:  "users"<[email protected]>;

Subject:  Re:  RDF namespace is not compatible with OPTIONAL in ARQ



Hi,

1) Are you sure the placeholder substitution is coorect in : PREFIX
kg:<%s> ? (print out the query string after substitution)
2) in which case is your code failing , modelUri null or modelUri not
null ?

Are you switching between a named graph and the default model ?

Is this a in memory dataset or not ? If not check for a .lock file in
your data directory.



Marc


Le mercredi 27 décembre 2017 à 10:42 +0800, hetong583 a écrit :
> Yes, this is my execution function
> ```
>   public ResultSet execSelect(String queryStr) {
>     ds.begin(ReadWrite.READ);
>     try {
>       Query query = QueryFactory.create(queryStr);
>       QueryExecution qexec;
>       if (modelUri != null) {
>         qexec = QueryExecutionFactory.create(query,
> ds.getNamedModel(modelUri));
>       } else {
>         qexec = QueryExecutionFactory.create(query, ds);
>       }
>       return qexec.execSelect();
>     } catch (Exception e) {
>       logger.error(e.getMessage(), e);
>     } finally {
>       ds.end();
>     }
>     return null;
>   }
> 
> 
> 
> ```
> 
> 
> ------------------
> Wang Tonghe
> 
> 
>  
> 
> 
> 
> 
> ------------------ Original ------------------
> From:  "Marc Agate";<[email protected]>;
> Date:  Wed, Dec 27, 2017 10:35 AM
> To:  "users"<[email protected]>;
> 
> Subject:  Re: RDF namespace is not compatible with OPTIONAL in ARQ
> 
> 
> 
> Hi!
> 
> Did you first start the transaction with
> yourdataset.begin(ReadWrite.READ) ?
> 
> Marc
> 
> Le mercredi 27 décembre 2017 à 10:24 +0800, hetong583 a écrit :
> > Hello,
> > I tried to access TDB via SPARQL. However following query always
> > throws a TDBTransactionException: Not in a transaction.
> > ```
> > PREFIX kg:<%s>
> > PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
> > SELECT ?entityUri ?name ?unit 
> > WHERE
> > { ?entityUri      rdf:type         kg:AtomicMetric. 
> >   ?entityUri       kg:Name            ?name. 
> >   OPTIONAL { ?entityUri      kg:Unit     ?unit } }
> > 
> > ```
> > After several tries, I found that rdf namespace and `OPTIONAL`
> > cannot
> > appear simultaneously. And any modification on "http://www.w3.org/1
> > 99
> > 9/02/22-rdf-syntax-ns#" will solve the problem. I use Jena 3.5 and
> > I
> > found 3.6 also has this problom.
> > 
> > 
> > Following is the stacktrace.
> > ```
> > org.apache.jena.tdb.transaction.TDBTransactionException: Not in a
> > transaction
> > 
> > 
> >     at
> > org.apache.jena.tdb.transaction.DatasetGraphTransaction.get(Dataset
> > Gr
> > aphTransaction.java:117)
> >     at
> > org.apache.jena.tdb.transaction.DatasetGraphTransaction.getDatasetG
> > ra
> > phToQuery(DatasetGraphTransaction.java:80)
> >     at
> > org.apache.jena.tdb.store.GraphTxnTDB.getDatasetGraphTDB(GraphTxnTD
> > B.
> > java:49)
> >     at
> > org.apache.jena.tdb.store.GraphTDB.getNodeTupleTable(GraphTDB.java:
> > 74
> > )
> >     at
> > org.apache.jena.tdb.solver.SolverLib.execute(SolverLib.java:66)
> >     at
> > org.apache.jena.tdb.solver.StageGeneratorDirectTDB.execute(StageGen
> > er
> > atorDirectTDB.java:56)
> >     at
> > org.apache.jena.tdb2.solver.StageGeneratorDirectTDB.execute(StageGe
> > ne
> > ratorDirectTDB.java:53)
> >     at
> > org.apache.jena.sparql.engine.main.OpExecutor.execute(OpExecutor.ja
> > va
> > :128)
> >     at
> > org.apache.jena.sparql.engine.main.ExecutionDispatch.visit(Executio
> > nD
> > ispatch.java:58)
> >     at org.apache.jena.sparql.algebra.op.OpBGP.visit(OpBGP.java:49)
> >     at
> > org.apache.jena.sparql.engine.main.ExecutionDispatch.exec(Execution
> > Di
> > spatch.java:46)
> >     at
> > org.apache.jena.sparql.engine.main.OpExecutor.exec(OpExecutor.java:
> > 11
> > 7)
> >     at
> > org.apache.jena.sparql.engine.main.OpExecutor.execute(OpExecutor.ja
> > va
> > :88)
> >     at org.apache.jena.sparql.engine.main.QC.execute(QC.java:52)
> >     at
> > org.apache.jena.sparql.engine.main.iterator.QueryIterOptionalIndex.
> > ne
> > xtStage(QueryIterOptionalIndex.java:51)
> >     at
> > org.apache.jena.sparql.engine.iterator.QueryIterRepeatApply.makeNex
> > tS
> > tage(QueryIterRepeatApply.java:108)
> >     at
> > org.apache.jena.sparql.engine.iterator.QueryIterRepeatApply.hasNext
> > Bi
> > nding(QueryIterRepeatApply.java:65)
> >     at
> > org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(Qu
> > er
> > yIteratorBase.java:114)
> >     at
> > org.apache.jena.sparql.engine.iterator.QueryIterConvert.hasNextBind
> > in
> > g(QueryIterConvert.java:58)
> >     at
> > org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(Qu
> > er
> > yIteratorBase.java:114)
> >     at
> > org.apache.jena.sparql.engine.iterator.QueryIteratorWrapper.hasNext
> > Bi
> > nding(QueryIteratorWrapper.java:39)
> >     at
> > org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(Qu
> > er
> > yIteratorBase.java:114)
> >     at
> > org.apache.jena.sparql.engine.iterator.QueryIteratorWrapper.hasNext
> > Bi
> > nding(QueryIteratorWrapper.java:39)
> >     at
> > org.apache.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(Qu
> > er
> > yIteratorBase.java:114)
> >     at
> > org.apache.jena.sparql.engine.ResultSetStream.hasNext(ResultSetStre
> > am
> > .java:74)
> >     at
> > org.apache.jena.sparql.engine.ResultSetCheckCondition.hasNext(Resul
> > tS
> > etCheckCondition.java:55)
> >     at
> > com.quantchi.intelquery.etl.LtpDict.getEntityFromTdb(LtpDict.java:8
> > 7)
> > 
> > ```
> > 
> > 
> > Thanks for your help.  Let me know if you need any other
> > infomation.
> > Best regards.
> > 
> > 
> > 
> > 
> > ------------------
> > Wang Tonghe

Reply via email to