Re: Convert string to float in a SPARQL query

2016-09-15 Thread A. Soroka
https://stackoverflow.com/help/mcve

What data are you using? What is the complete action you are exercising? What 
results do you expect? What results do you get?

---
A. Soroka
The University of Virginia Library

> On Sep 15, 2016, at 5:56 PM, lookman sanni  wrote:
> 
> Hi all,
> 
> I am trying to perform a filter in a SPARQL query, through the below code:
> 
> FILTER ( abs(xsd:float(?tAmount1)) = abs(xsd:float(?tAmount2)) )
> 
> The query is being parsed correctly, but I am not getting the expected
> result. Any clue why this would not convert and compare those amounts
> properly ? The amounts are formatted like this: "+8644,00".
> 
> Thanks in advance for the help.
> 
> -- 
> Best Regards
> 
> Lookman SANNI



Convert string to float in a SPARQL query

2016-09-15 Thread lookman sanni
Hi all,

I am trying to perform a filter in a SPARQL query, through the below code:

FILTER ( abs(xsd:float(?tAmount1)) = abs(xsd:float(?tAmount2)) )

The query is being parsed correctly, but I am not getting the expected
result. Any clue why this would not convert and compare those amounts
properly ? The amounts are formatted like this: "+8644,00".

Thanks in advance for the help.

-- 
Best Regards

Lookman SANNI


Re: Restarting FUSEKI with TDB and OWL reasoner

2016-09-15 Thread Andy Seaborne

I've put a fix in and the latest dev snapshot build has that in.

I've only addressed this one use case, pending some thinking about 
general situation.


Andy

On 15/09/16 11:21, Andy Seaborne wrote:

Hi Filip,

I can recreate the problem with 2.4.0 and development (2.3.1 seems to be
OK).

https://issues.apache.org/jira/browse/JENA-1236

Thank you for the complete report.   I even get the same nodeid offset
numbers which is helpful.

I don't know what's going wrong yet though the area of transaction
isolation is the place to start looking.

Andy

On 14/09/16 14:21, Filip Masri wrote:

So the thing I did is:

1. unzip apache-jena-fuseki-2.4.0.zip
2. run ./fuseki-server --mem /ds -> so the /run directory is created
(Canceled by CTRL+C, but this should not affect the final Dataset)
3. Setup init script (fuseki as attachment with HOME, BASE and CONFIG
confifurations)
4. Start the service = service fuseki start (DB database is created)
5. Upload schema file through GUI (mobilePhonesCustomClasses.ttl) to
/inf dataset
6. Try to query through GUI = 200 OK

PREFIX : 
PREFIX owl: 

Select ?s ?p ?o
WHERE {
   ?s ?p ?o .
}
order by ?p


7. service fuseki restart
8. Query again

Error 500: Invalid id node for subject (null node):
([], [0022], [0054])


Fuseki - version 2.4.0 (Build date: 2016-05-10T11:59:39+)

The attachements are the init script, my turtle data/schema to be
uploaded,
 config file for the dataset referenced in the init script.

Maybe I am doing something wrong so u will correct me :)

Thanks anyways!


2016-09-14 14:53 GMT+02:00 Andy Seaborne >:



On 14/09/16 13:39, Filip Masri wrote:

Well, I could not solve the problem with
apache-jena-fuseki-2.4.0 but
apache-jena-fuseki-2.3.1
 worked without problem.


Ouch!


Do you want me to describe the whole process I did so you could
possiby
stacktrace the problem?


Yes, please.

Andy



Filip

2016-09-14 12:11 GMT+02:00 Andy Seaborne >:

Hi Filip,

Error 500: Invalid id node for object (null node):
([3C3C], [0007AA],
[3D18])


This is usually a sign that the program exits without
sync'ing a
non-transaction TDB database.

It is possible (probably) that building the inference model
in the
assembler is not transactional.  It becomes transactional on
first request.

So has at any time in the past, not the run which caused the
500, have you
exited the server during start up (e.g. control-C) or before
the first
request to the inference model?  or another program access
the same
database?

The other possible cause is two systems trying to modify the
same database
at the same time.  TDB tries to trap this and warn you but
the test is not
perfect.  (It looks like you are on Linux so the test is
much better there
- on Windows, it has been reported that Windows update can
cause restarts
where the process id is reused quiet quickly.)

Could you please crosslink the stack overflow question to
this thread?
Thanks.

Andy



On 13/09/16 12:32, Filip Masri wrote:

Dear Jena Community,

I have a following fuseki dataset configuration:

@prefix fuseki: > .
@prefix rdf:
> .
@prefix rdfs: > .
@prefix tdb: > .
@prefix ja: > .
@prefix sdb: > .


[] a fuseki:Server ;
fuseki:services ( <#tdb> ) .


<#tdb> rdf:type fuseki:Service ;
 fuseki:name "ds" ; # http://host/inf
 fuseki:serviceQuery   "query" , "sparql" ;
 fuseki:serviceUpdate "update" ;
 fuseki:dataset <#dataset2> ; #select which set to use
 rdfs:label"TDB ds" ;
 

Re: ConcurrentModificationException

2016-09-15 Thread Andy Seaborne



On 15/09/16 13:16, Laurent Rucquoy wrote:

Hi Andy,

I've moved the model.close() call inside the transaction (sorry for
this careless mistake) and it works now !


Maybe, maybe not!

While investigating I couldn't provoke the error either way round - it 
seems to be related to the update performed and I did not manage to 
guess the right kind.  The stack trace does not suggest it is 
model.close related.


What is the SPARQL Update?

Andy



Thank you very much for your help.
Laurent



On 14 September 2016 at 18:28, Andy Seaborne  wrote:


Hi Laurent,

On 14/09/16 15:16, Laurent Rucquoy wrote:


Hi Andy,

Thank you for your help.

I have tested the following code according to your suggestions (get the
model inside the transaction and remove the use of locks):

dataset.begin(ReadWrite.WRITE);


Model model = dataset.getNamedModel("http://my-model-name;);
try {
UpdateAction.parseExecute(sparql, model);




What is the update?

if(writeMode) {

dataset.commit();
}
} finally {

model.close();




You are using the model after the commit

dataset.end();

}





Andy



When multiple updates are made on our TDB-backed dataset, the java.util.
ConcurrentModificationException is still thrown, leaving the dataset in
an

inaccessible state.
Here is the stacktrace part:

Caused by: java.util.ConcurrentModificationException: Iterator: started
at


5, now 8
at
org.apache.jena.tdb.sys.DatasetControlMRSW.policyError(Datas
etControlMRSW.java:157)
at
org.apache.jena.tdb.sys.DatasetControlMRSW.access$000(Datase
tControlMRSW.java:32)
at
org.apache.jena.tdb.sys.DatasetControlMRSW$IteratorCheckNotC
oncurrent.checkCourrentModification(DatasetControlMRSW.java:110)
at
org.apache.jena.tdb.sys.DatasetControlMRSW$IteratorCheckNotC
oncurrent.hasNext(DatasetControlMRSW.java:118)
at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
at org.apache.jena.atlas.iterator.Iter.hasNext(Iter.java:870)
at org.apache.jena.atlas.iterator.Iter$1.hasNext(Iter.java:192)
at org.apache.jena.atlas.iterator.Iter.hasNext(Iter.java:870)
at
org.apache.jena.atlas.iterator.RepeatApplyIterator.hasNext(
RepeatApplyIterator.java:58)
at
org.apache.jena.tdb.solver.SolverLib$IterAbortable.hasNext(
SolverLib.java:195)
at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
at
org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper
.hasNextBinding(QueryIterPlainWrapper.java:53)
at
org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
Next(QueryIteratorBase.java:111)
at
org.apache.jena.sparql.engine.iterator.QueryIterRepeatApply.
makeNextStage(QueryIterRepeatApply.java:101)
at
org.apache.jena.sparql.engine.iterator.QueryIterRepeatApply.
hasNextBinding(QueryIterRepeatApply.java:65)
at
org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
Next(QueryIteratorBase.java:111)
at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
at
org.apache.jena.atlas.iterator.RepeatApplyIterator.hasNext(
RepeatApplyIterator.java:45)
at
org.apache.jena.tdb.solver.SolverLib$IterAbortable.hasNext(
SolverLib.java:195)
at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
at
org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper
.hasNextBinding(QueryIterPlainWrapper.java:53)
at
org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
Next(QueryIteratorBase.java:111)
at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
at
org.apache.jena.atlas.iterator.RepeatApplyIterator.hasNext(
RepeatApplyIterator.java:45)
at
org.apache.jena.tdb.solver.SolverLib$IterAbortable.hasNext(
SolverLib.java:195)
at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
at
org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper
.hasNextBinding(QueryIterPlainWrapper.java:53)
at
org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
Next(QueryIteratorBase.java:111)
at
org.apache.jena.sparql.engine.iterator.QueryIterConcat.hasNe
xtBinding(QueryIterConcat.java:82)
at
org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
Next(QueryIteratorBase.java:111)
at
org.apache.jena.sparql.engine.iterator.QueryIterRepeatApply.
hasNextBinding(QueryIterRepeatApply.java:74)
at
org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
Next(QueryIteratorBase.java:111)
at
org.apache.jena.sparql.engine.iterator.QueryIterConvert.hasN
extBinding(QueryIterConvert.java:58)
at
org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
Next(QueryIteratorBase.java:111)
at
org.apache.jena.sparql.engine.iterator.QueryIterDistinct.get
InputNextUnseen(QueryIterDistinct.java:104)
at
org.apache.jena.sparql.engine.iterator.QueryIterDistinct.has
NextBinding(QueryIterDistinct.java:70)
at
org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
Next(QueryIteratorBase.java:111)
at
org.apache.jena.sparql.engine.iterator.QueryIteratorWrapper.
hasNextBinding(QueryIteratorWrapper.java:39)
at
org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
Next(QueryIteratorBase.java:111)
at

Re: ConcurrentModificationException

2016-09-15 Thread Laurent Rucquoy
Hi Andy,

I've moved the model.close() call inside the transaction (sorry for
this careless mistake) and it works now !

Thank you very much for your help.
Laurent



On 14 September 2016 at 18:28, Andy Seaborne  wrote:

> Hi Laurent,
>
> On 14/09/16 15:16, Laurent Rucquoy wrote:
>
>> Hi Andy,
>>
>> Thank you for your help.
>>
>> I have tested the following code according to your suggestions (get the
>> model inside the transaction and remove the use of locks):
>>
>> dataset.begin(ReadWrite.WRITE);
>>
>>> Model model = dataset.getNamedModel("http://my-model-name;);
>>> try {
>>> UpdateAction.parseExecute(sparql, model);
>>>
>>
> What is the update?
>
> if(writeMode) {
>>> dataset.commit();
>>> }
>>> } finally {
>>>
>>> model.close();
>>>
>>
> You are using the model after the commit
>
> dataset.end();
>>> }
>>>
>>
>>
> Andy
>
>
>> When multiple updates are made on our TDB-backed dataset, the java.util.
>> ConcurrentModificationException is still thrown, leaving the dataset in
>> an
>>
>> inaccessible state.
>> Here is the stacktrace part:
>>
>> Caused by: java.util.ConcurrentModificationException: Iterator: started
>> at
>>
>>> 5, now 8
>>> at
>>> org.apache.jena.tdb.sys.DatasetControlMRSW.policyError(Datas
>>> etControlMRSW.java:157)
>>> at
>>> org.apache.jena.tdb.sys.DatasetControlMRSW.access$000(Datase
>>> tControlMRSW.java:32)
>>> at
>>> org.apache.jena.tdb.sys.DatasetControlMRSW$IteratorCheckNotC
>>> oncurrent.checkCourrentModification(DatasetControlMRSW.java:110)
>>> at
>>> org.apache.jena.tdb.sys.DatasetControlMRSW$IteratorCheckNotC
>>> oncurrent.hasNext(DatasetControlMRSW.java:118)
>>> at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
>>> at org.apache.jena.atlas.iterator.Iter.hasNext(Iter.java:870)
>>> at org.apache.jena.atlas.iterator.Iter$1.hasNext(Iter.java:192)
>>> at org.apache.jena.atlas.iterator.Iter.hasNext(Iter.java:870)
>>> at
>>> org.apache.jena.atlas.iterator.RepeatApplyIterator.hasNext(
>>> RepeatApplyIterator.java:58)
>>> at
>>> org.apache.jena.tdb.solver.SolverLib$IterAbortable.hasNext(
>>> SolverLib.java:195)
>>> at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper
>>> .hasNextBinding(QueryIterPlainWrapper.java:53)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
>>> Next(QueryIteratorBase.java:111)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIterRepeatApply.
>>> makeNextStage(QueryIterRepeatApply.java:101)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIterRepeatApply.
>>> hasNextBinding(QueryIterRepeatApply.java:65)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
>>> Next(QueryIteratorBase.java:111)
>>> at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
>>> at
>>> org.apache.jena.atlas.iterator.RepeatApplyIterator.hasNext(
>>> RepeatApplyIterator.java:45)
>>> at
>>> org.apache.jena.tdb.solver.SolverLib$IterAbortable.hasNext(
>>> SolverLib.java:195)
>>> at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper
>>> .hasNextBinding(QueryIterPlainWrapper.java:53)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
>>> Next(QueryIteratorBase.java:111)
>>> at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
>>> at
>>> org.apache.jena.atlas.iterator.RepeatApplyIterator.hasNext(
>>> RepeatApplyIterator.java:45)
>>> at
>>> org.apache.jena.tdb.solver.SolverLib$IterAbortable.hasNext(
>>> SolverLib.java:195)
>>> at org.apache.jena.atlas.iterator.Iter$2.hasNext(Iter.java:265)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper
>>> .hasNextBinding(QueryIterPlainWrapper.java:53)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
>>> Next(QueryIteratorBase.java:111)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIterConcat.hasNe
>>> xtBinding(QueryIterConcat.java:82)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
>>> Next(QueryIteratorBase.java:111)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIterRepeatApply.
>>> hasNextBinding(QueryIterRepeatApply.java:74)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
>>> Next(QueryIteratorBase.java:111)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIterConvert.hasN
>>> extBinding(QueryIterConvert.java:58)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
>>> Next(QueryIteratorBase.java:111)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIterDistinct.get
>>> InputNextUnseen(QueryIterDistinct.java:104)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIterDistinct.has
>>> NextBinding(QueryIterDistinct.java:70)
>>> at
>>> org.apache.jena.sparql.engine.iterator.QueryIteratorBase.has
>>> Next(QueryIteratorBase.java:111)
>>> at
>>> 

Re: Programatically adding filters to sparql query

2016-09-15 Thread Andy Seaborne
If you want plain java, the query builder module may help but IIRC it is 
centred around buildign a query from scratch not modifying one.


That leaves 3 choices:

1/ Syntax tree manipulation

query.getQueryPattern

The topmost element of the WHERE clause wil be an ElementGroup.  Create 
an ElementFilter and add it to the group.


2/ Convert to the algebra, and walk down through the project and add a 
OpFilter around the BGP.Call OpToQuery to get a query back. This is 
more work for the simpel case but for more complicated changes, the 
algebra can be easier to work with.


3/ Put in a FILTER(true) or FILTER("Spot this string") to start with as 
a marker to be changed and use


org.apache.jena.sparql.syntax.syntaxtransform.QueryTransformOps

to rewrite it to the thing you want.

Note that syntaxtransform apply to the whole abstract syntax tree so be 
careful not to rewrite other things on more complicated queries.



If it is this simple case shown, (1) is easiest.  It depends on how 
complicated it will get later.


And


On 14/09/16 15:09, Bart van Leeuwen wrote:

I would prefer plain Jena

Met Vriendelijke Groet / With Kind Regards
Bart van Leeuwen

##
# twitter: @semanticfire
# netage.nl
# http://netage.nl
# Esdoornstraat 3
# 3461ER Linschoten
# tel. +31(0)6-53182997
##



From:   Martynas Jusevičius 
To: users@jena.apache.org
Date:   14-09-2016 15:20
Subject:Re: Programatically adding filters to sparql query



Are you able to use SPIN or does it have to be plain Jena?

On Wed, 14 Sep 2016 at 16:08, Bart van Leeuwen

wrote:


Hi,

I'm looking for some documentation on adding additional filters to a
parsed sparql query

I can do:

Query q = new Query('select ?s ?p ?o where { ?s a sem:Event . ?s ?p ?o
}');

now I'd like to use the Query object Q to extend this query with a

FIlter

clause.

any documentation pointers are appreciated.

Met Vriendelijke Groet / With Kind Regards
Bart van Leeuwen

##
# twitter: @semanticfire
# netage.nl
# http://netage.nl
# Esdoornstraat 3
# 3461ER Linschoten
# tel. +31(0)6-53182997
##






Re: Restarting FUSEKI with TDB and OWL reasoner

2016-09-15 Thread Andy Seaborne

Hi Filip,

I can recreate the problem with 2.4.0 and development (2.3.1 seems to be 
OK).


https://issues.apache.org/jira/browse/JENA-1236

Thank you for the complete report.   I even get the same nodeid offset 
numbers which is helpful.


I don't know what's going wrong yet though the area of transaction 
isolation is the place to start looking.


Andy

On 14/09/16 14:21, Filip Masri wrote:

So the thing I did is:

1. unzip apache-jena-fuseki-2.4.0.zip
2. run ./fuseki-server --mem /ds -> so the /run directory is created
(Canceled by CTRL+C, but this should not affect the final Dataset)
3. Setup init script (fuseki as attachment with HOME, BASE and CONFIG
confifurations)
4. Start the service = service fuseki start (DB database is created)
5. Upload schema file through GUI (mobilePhonesCustomClasses.ttl) to
/inf dataset
6. Try to query through GUI = 200 OK

PREFIX : 
PREFIX owl: 

Select ?s ?p ?o
WHERE {
   ?s ?p ?o .
}
order by ?p


7. service fuseki restart
8. Query again

Error 500: Invalid id node for subject (null node): ([], 
[0022], [0054])


Fuseki - version 2.4.0 (Build date: 2016-05-10T11:59:39+)

The attachements are the init script, my turtle data/schema to be uploaded,
 config file for the dataset referenced in the init script.

Maybe I am doing something wrong so u will correct me :)

Thanks anyways!


2016-09-14 14:53 GMT+02:00 Andy Seaborne >:



On 14/09/16 13:39, Filip Masri wrote:

Well, I could not solve the problem with
apache-jena-fuseki-2.4.0 but
apache-jena-fuseki-2.3.1
 worked without problem.


Ouch!


Do you want me to describe the whole process I did so you could
possiby
stacktrace the problem?


Yes, please.

Andy



Filip

2016-09-14 12:11 GMT+02:00 Andy Seaborne >:

Hi Filip,

Error 500: Invalid id node for object (null node):
([3C3C], [0007AA], [3D18])


This is usually a sign that the program exits without sync'ing a
non-transaction TDB database.

It is possible (probably) that building the inference model
in the
assembler is not transactional.  It becomes transactional on
first request.

So has at any time in the past, not the run which caused the
500, have you
exited the server during start up (e.g. control-C) or before
the first
request to the inference model?  or another program access
the same
database?

The other possible cause is two systems trying to modify the
same database
at the same time.  TDB tries to trap this and warn you but
the test is not
perfect.  (It looks like you are on Linux so the test is
much better there
- on Windows, it has been reported that Windows update can
cause restarts
where the process id is reused quiet quickly.)

Could you please crosslink the stack overflow question to
this thread?
Thanks.

Andy



On 13/09/16 12:32, Filip Masri wrote:

Dear Jena Community,

I have a following fuseki dataset configuration:

@prefix fuseki: > .
@prefix rdf:
> .
@prefix rdfs: > .
@prefix tdb: > .
@prefix ja: > .
@prefix sdb: > .


[] a fuseki:Server ;
fuseki:services ( <#tdb> ) .


<#tdb> rdf:type fuseki:Service ;
 fuseki:name "ds" ; # http://host/inf
 fuseki:serviceQuery   "query" , "sparql" ;
 fuseki:serviceUpdate "update" ;
 fuseki:dataset <#dataset2> ; #select which set to use
 rdfs:label"TDB ds" ;
 fuseki:serviceReadGraphStore  "get" ;
 fuseki:serviceReadWriteGraphStore
   "data" ;
 fuseki:serviceUpload  "upload" .

[] ja:loadClass 

Re: org.apache.jena.system.JenaSystem.logLifecycle NoSuchMethodError

2016-09-15 Thread Andy Seaborne

Wrong mix of jars at runtime.

https://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodError.html

"""
Normally, this error is caught by the compiler; this error can only 
occur at run time if the definition of a class has incompatibly changed.

"""

Andy

On 14/09/16 19:46, George News wrote:

Hi all,

I have posted an error on deploying a REST webservice using Jena in WildFly.

http://stackoverflow.com/q/39497473/422680

I know crossposting is not the way to go, but I don't know which would
be better not only for getting a possible answer but also for making it
publicly available.

Regards,
Jorge