You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Harri Kiiskinen <ha...@utu.fi> on 2021/01/27 17:16:36 UTC

XPath Duration functions in Jena

Dear all,

This example run with Fuseki 3.17:

--------------------------------------------------------------------
PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?y ?d (xsd:dayTimeDuration(?age) as ?a1)
              (xsd:yearMonthDuration(?age) as ?a2)
where {
   bind ( xsd:date("1984-12-01") as ?y)
   bind ( xsd:date("1944-05-06") as ?d)
   bind ((?y-?d) as ?age )	
}
-------------------------------------------------------------------

Gives unexpected results:

------------------------------------------------------------------
y,d,a1,a2
1984-12-01,1944-05-06,P14484DT0H0M0.000S,P0M
------------------------------------------------------------------

I was expecting the variable "a2" to contain the duration expressed in 
Years and Months, but instead it is zero.


What am I doing wrong here?

Best,

Harri Kiiskinen
-- 
Tutkijatohtori / post-doctoral researcher
Movie Making Finland: Finnish fiction films as audiovisual big data, 
1907–2017 (MoMaF)
Turun yliopisto / University of Turku

Re: XPath Duration functions in Jena

Posted by Andy Seaborne <an...@apache.org>.
Hi Harri,

https://www.w3.org/TR/xpath-functions-3/#func-subtract-dates

The difference of two dates is the duration bwteeen the dates as points 
on the timeline as a xs:dayTimeDuration.

?age is "P14484DT0H0M0.000S"^^xsd:dayTimeDuration

not PnnYnnMnnD

A duration is a defined, fixed length of time.


There two kinds of durations xs:dayTimeDuration and xs:yearMonthDuration
https://www.w3.org/TR/xpath-functions-3/#duration-subtypes

where arithmetic and ordering can be meaningfully defined at all.

A combination of months and days is not a fixed interval of time because 
the number of days in a month isn't the same for all months.

Only xs:dayTimeDuration defines a duration that is of a well-defined 
difference of two points on the timeline (ignoring negative leap seconds).

Once "xsd:date - xsd:date" is calculated, the duration is a fixed length 
of time and does not tie back to which dates were used in the calculation.

So "P14484D.." is right not "P44Y6m??D"

[[
Confusingly the difference of two Gregorian year-months (gYearMonth) is 
also an xs:dayTimeDuration, and not a xs:yearMonthDuration, not that it 
is really defined on gYearMonth (section 9.1), because gYearMonth maps 
to a point on the timeline and the difference is of two points on the 
timeline.
]]


With ?age is "P14484DT0H0M0.000S"^^xsd:dayTimeDuration

For the casting to xsd:yearMonthDuration: (had to check this one!)

Casting xsd:dayTimeDuration to xsd:yearMonthDuration is defined.

https://www.w3.org/TR/xpath-functions-31/#casting-from-primitive-to-primitive

https://www.w3.org/TR/xpath-functions-31/#casting-to-durations
"""
If ST is xs:yearMonthDuration and TT is xs:dayTimeDuration, the cast is 
permitted and returns a xs:dayTimeDuration with value 0.0 seconds.
"""
ST is "source type" TT is target type".

I don't know the rationale - (a guess - treat like it is selecting 
fields from PnnYnnMnnDT..)

     Andy


On 27/01/2021 17:16, Harri Kiiskinen wrote:
> Dear all,
> 
> This example run with Fuseki 3.17:
> 
> --------------------------------------------------------------------
> PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
> 
> SELECT ?y ?d (xsd:dayTimeDuration(?age) as ?a1)
>               (xsd:yearMonthDuration(?age) as ?a2)
> where {
>    bind ( xsd:date("1984-12-01") as ?y)
>    bind ( xsd:date("1944-05-06") as ?d)
>    bind ((?y-?d) as ?age )
> }
> -------------------------------------------------------------------
> 
> Gives unexpected results:
> 
> ------------------------------------------------------------------
> y,d,a1,a2
> 1984-12-01,1944-05-06,P14484DT0H0M0.000S,P0M
> ------------------------------------------------------------------
> 
> I was expecting the variable "a2" to contain the duration expressed in 
> Years and Months, but instead it is zero.
> 
> 
> What am I doing wrong here?
> 
> Best,
> 
> Harri Kiiskinen

Benchmarks [was: XPath Duration functions in Jena]

Posted by Andy Seaborne <an...@apache.org>.
Asking unrelated questions on a thread is risky - people don't 
necessarily read the thread if the subject is not of interest to them. 
Especially here when it is about the (extremely!) fine detail of how XSD 
durations work and have evolved over versions.


The reason why public query benchmarks have faded is the realisation 
that useful numbers come from (1) significant attention to the runtime 
environment and (2) the use case of interest.

A benchmark execute by someone else on their use case and data has only 
so much use.

Ultimately the question becomes "is it fast enough for my usage with the 
configuration I want in the environment I will be using?" and the way to 
know, is to try.

The same is true in the SQL world with TPC.
The fastest databases aren't the ones growing in usage like crazy at the 
moment.

BSBM is better than LUMB in being a bit more realistic (LUBM is, as the 
original authors have said, no longer that helpful) but it is quite 
small and focuses on pattern-filter queries. There are two optimizations 
that ARQ does that determine the efficiency - all the other 
optimizations don't have much effect on the queries+data of BSBM but do 
elsewhere.

Straight loads tests are more reliable as loading has less dimensions - 
the shape of the data does matter but in query there is the whole 
universe of query possibilities and features.

LDBC publish some benchmarks (data and query sets) by use case and they 
do run professional benchmarking. It is on a pay-to-participate basis 
for certified results (think TPC).

What are you interested in?
Inference?
Data publishing or data analytics?
...

     Andy

On 28/01/2021 02:01, Fang, Xiao Shan wrote:
> Dear all,
> 
> Does TDB has a latest benchmarking performance test result?  I found a Berlin sparql test benchmarking result. But it reports on 2008.
> 
> Thanks,
> -xiaoshan
> 
> 
> -----Original Message-----
> From: Andy Seaborne [mailto:andy@apache.org]
> Sent: 2021年1月28日 6:26
> To: users@jena.apache.org
> Subject: Re: XPath Duration functions in Jena
> 
> Hi Harri,
> 
> https://www.w3.org/TR/xpath-functions-3/#func-subtract-dates
> 
> The difference of two dates is the duration bwteeen the dates as points on the timeline as a xs:dayTimeDuration.
> 
> ?age is "P14484DT0H0M0.000S"^^xsd:dayTimeDuration
> 
> not PnnYnnMnnD
> 
> A duration is a defined, fixed length of time.
> 
> 
> There two kinds of durations xs:dayTimeDuration and xs:yearMonthDuration https://www.w3.org/TR/xpath-functions-3/#duration-subtypes
> 
> where arithmetic and ordering can be meaningfully defined at all.
> 
> A combination of months and days is not a fixed interval of time because the number of days in a month isn't the same for all months.
> 
> Only xs:dayTimeDuration defines a duration that is of a well-defined difference of two points on the timeline (ignoring negative leap seconds).
> 
> Once "xsd:date - xsd:date" is calculated, the duration is a fixed length of time and does not tie back to which dates were used in the calculation.
> 
> So "P14484D.." is right not "P44Y6m??D"
> 
> [[
> Confusingly the difference of two Gregorian year-months (gYearMonth) is also an xs:dayTimeDuration, and not a xs:yearMonthDuration, not that it is really defined on gYearMonth (section 9.1), because gYearMonth maps to a point on the timeline and the difference is of two points on the timeline.
> ]]
> 
> 
> With ?age is "P14484DT0H0M0.000S"^^xsd:dayTimeDuration
> 
> For the casting to xsd:yearMonthDuration: (had to check this one!)
> 
> Casting xsd:dayTimeDuration to xsd:yearMonthDuration is defined.
> 
> https://www.w3.org/TR/xpath-functions-31/#casting-from-primitive-to-primitive
> 
> https://www.w3.org/TR/xpath-functions-31/#casting-to-durations
> """
> If ST is xs:yearMonthDuration and TT is xs:dayTimeDuration, the cast is permitted and returns a xs:dayTimeDuration with value 0.0 seconds.
> """
> ST is "source type" TT is target type".
> 
> I don't know the rationale - (a guess - treat like it is selecting fields from PnnYnnMnnDT..)
> 
>       Andy
> 
> 
> On 27/01/2021 17:16, Harri Kiiskinen wrote:
>> Dear all,
>>
>> This example run with Fuseki 3.17:
>>
>> --------------------------------------------------------------------
>> PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
>> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
>>
>> SELECT ?y ?d (xsd:dayTimeDuration(?age) as ?a1)
>>                (xsd:yearMonthDuration(?age) as ?a2) where {
>>     bind ( xsd:date("1984-12-01") as ?y)
>>     bind ( xsd:date("1944-05-06") as ?d)
>>     bind ((?y-?d) as ?age )
>> }
>> -------------------------------------------------------------------
>>
>> Gives unexpected results:
>>
>> ------------------------------------------------------------------
>> y,d,a1,a2
>> 1984-12-01,1944-05-06,P14484DT0H0M0.000S,P0M
>> ------------------------------------------------------------------
>>
>> I was expecting the variable "a2" to contain the duration expressed in
>> Years and Months, but instead it is zero.
>>
>>
>> What am I doing wrong here?
>>
>> Best,
>>
>> Harri Kiiskinen

RE: XPath Duration functions in Jena

Posted by "Fang, Xiao Shan" <xi...@siemens.com>.
Dear all,

Does TDB has a latest benchmarking performance test result?  I found a Berlin sparql test benchmarking result. But it reports on 2008. 

Thanks,
-xiaoshan


-----Original Message-----
From: Andy Seaborne [mailto:andy@apache.org] 
Sent: 2021年1月28日 6:26
To: users@jena.apache.org
Subject: Re: XPath Duration functions in Jena

Hi Harri,

https://www.w3.org/TR/xpath-functions-3/#func-subtract-dates

The difference of two dates is the duration bwteeen the dates as points on the timeline as a xs:dayTimeDuration.

?age is "P14484DT0H0M0.000S"^^xsd:dayTimeDuration

not PnnYnnMnnD

A duration is a defined, fixed length of time.


There two kinds of durations xs:dayTimeDuration and xs:yearMonthDuration https://www.w3.org/TR/xpath-functions-3/#duration-subtypes

where arithmetic and ordering can be meaningfully defined at all.

A combination of months and days is not a fixed interval of time because the number of days in a month isn't the same for all months.

Only xs:dayTimeDuration defines a duration that is of a well-defined difference of two points on the timeline (ignoring negative leap seconds).

Once "xsd:date - xsd:date" is calculated, the duration is a fixed length of time and does not tie back to which dates were used in the calculation.

So "P14484D.." is right not "P44Y6m??D"

[[
Confusingly the difference of two Gregorian year-months (gYearMonth) is also an xs:dayTimeDuration, and not a xs:yearMonthDuration, not that it is really defined on gYearMonth (section 9.1), because gYearMonth maps to a point on the timeline and the difference is of two points on the timeline.
]]


With ?age is "P14484DT0H0M0.000S"^^xsd:dayTimeDuration

For the casting to xsd:yearMonthDuration: (had to check this one!)

Casting xsd:dayTimeDuration to xsd:yearMonthDuration is defined.

https://www.w3.org/TR/xpath-functions-31/#casting-from-primitive-to-primitive

https://www.w3.org/TR/xpath-functions-31/#casting-to-durations
"""
If ST is xs:yearMonthDuration and TT is xs:dayTimeDuration, the cast is permitted and returns a xs:dayTimeDuration with value 0.0 seconds.
"""
ST is "source type" TT is target type".

I don't know the rationale - (a guess - treat like it is selecting fields from PnnYnnMnnDT..)

     Andy


On 27/01/2021 17:16, Harri Kiiskinen wrote:
> Dear all,
> 
> This example run with Fuseki 3.17:
> 
> --------------------------------------------------------------------
> PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
> 
> SELECT ?y ?d (xsd:dayTimeDuration(?age) as ?a1)
>               (xsd:yearMonthDuration(?age) as ?a2) where {
>    bind ( xsd:date("1984-12-01") as ?y)
>    bind ( xsd:date("1944-05-06") as ?d)
>    bind ((?y-?d) as ?age )
> }
> -------------------------------------------------------------------
> 
> Gives unexpected results:
> 
> ------------------------------------------------------------------
> y,d,a1,a2
> 1984-12-01,1944-05-06,P14484DT0H0M0.000S,P0M
> ------------------------------------------------------------------
> 
> I was expecting the variable "a2" to contain the duration expressed in 
> Years and Months, but instead it is zero.
> 
> 
> What am I doing wrong here?
> 
> Best,
> 
> Harri Kiiskinen

Re: XPath Duration functions in Jena

Posted by Andy Seaborne <an...@apache.org>.
Hi Harri,

https://www.w3.org/TR/xpath-functions-3/#func-subtract-dates

The difference of two dates is the duration bwteeen the dates as points 
on the timeline as a xs:dayTimeDuration.

?age is "P14484DT0H0M0.000S"^^xsd:dayTimeDuration

not PnnYnnMnnD

A duration is a defined, fixed length of time.


There two kinds of durations xs:dayTimeDuration and xs:yearMonthDuration
https://www.w3.org/TR/xpath-functions-3/#duration-subtypes

where arithmetic and ordering can be meaningfully defined at all.

A combination of months and days is not a fixed interval of time because 
the number of days in a month isn't the same for all months.

Only xs:dayTimeDuration defines a duration that is of a well-defined 
difference of two points on the timeline (ignoring negative leap seconds).

Once "xsd:date - xsd:date" is calculated, the duration is a fixed length 
of time and does not tie back to which dates were used in the calculation.

So "P14484D.." is right not "P44Y6m??D"

[[
Confusingly the difference of two Gregorian year-months (gYearMonth) is 
also an xs:dayTimeDuration, and not a xs:yearMonthDuration, not that it 
is really defined on gYearMonth (section 9.1), because gYearMonth maps 
to a point on the timeline and the difference is of two points on the 
timeline.
]]


With ?age is "P14484DT0H0M0.000S"^^xsd:dayTimeDuration

For the casting to xsd:yearMonthDuration: (had to check this one!)

Casting xsd:dayTimeDuration to xsd:yearMonthDuration is defined.

https://www.w3.org/TR/xpath-functions-31/#casting-from-primitive-to-primitive

https://www.w3.org/TR/xpath-functions-31/#casting-to-durations
"""
If ST is xs:yearMonthDuration and TT is xs:dayTimeDuration, the cast is 
permitted and returns a xs:dayTimeDuration with value 0.0 seconds.
"""
ST is "source type" TT is target type".

I don't know the rationale - (a guess - treat like it is selecting 
fields from PnnYnnMnnDT..)

     Andy


On 27/01/2021 17:16, Harri Kiiskinen wrote:
> Dear all,
> 
> This example run with Fuseki 3.17:
> 
> --------------------------------------------------------------------
> PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
> 
> SELECT ?y ?d (xsd:dayTimeDuration(?age) as ?a1)
>               (xsd:yearMonthDuration(?age) as ?a2)
> where {
>    bind ( xsd:date("1984-12-01") as ?y)
>    bind ( xsd:date("1944-05-06") as ?d)
>    bind ((?y-?d) as ?age )
> }
> -------------------------------------------------------------------
> 
> Gives unexpected results:
> 
> ------------------------------------------------------------------
> y,d,a1,a2
> 1984-12-01,1944-05-06,P14484DT0H0M0.000S,P0M
> ------------------------------------------------------------------
> 
> I was expecting the variable "a2" to contain the duration expressed in 
> Years and Months, but instead it is zero.
> 
> 
> What am I doing wrong here?
> 
> Best,
> 
> Harri Kiiskinen