Holger,
The class class of calculation that we need to do involves sliding a moving
window several objects wide across an ordered set of objects (ordered by time),
performing an aggregate calculation across the objects in the sliding window,
and assigning the resultant to subsequent objects in the ordered series. A
moving average calculation is a good example of this kinds of calculation.
A simpler example involves calculating cumulative values for rates measured by
time, which involves a window two objects wide:
I was able to create a working spin rule for computing cumulative values from
rates. It runs efficiently on small sets (500 records), but we have had to add
an index value to the ordered set of objects to do it and it could get messy
for computations with wider windows. See below (this all works except we have
not yet implemented datetime:daysBetween(arg1, arg2) .
Background: ?this is a :DataSet and it has a :records object property, range
:Record and a :numberOfRecords computed via a spin rule. :Record has properties
:rate (xsd:float), :time (xsd:dateTime), and :cumulative (xsd:float). Each
:Records has :rate and :time values assigned. The :Record :index starts at 1
for the earliest time. The first :record (:index =1 ) has a :cumulative value
0.
CONSTRUCT {
?record2 :cumulative ?cumulative2 }
WHERE {
?this :numberRecords ?N
?j tops:for (2 N ) .
LET ( ?i := ?j -1)
?record1 :index ?i .
?record1 ^:records ?this.
?record1 :time ?t1 .
?record1 :cumulative ?cumulative1
?record2 :index ?j .
?record2 ^:records ?this.
?record2 :time ?t2 .
?record2 :rate ?rate2 .
LET (?cumulative2 := (?cumulative1 + (?rate2 *
datetime:daysBetween(?t1, ?t2)))) .
}
We are concerned about 2 things 1) the scalability of this kind query up to
10,000 records, 2) how to generalize this for arbitrary windows, and 3) the
index could become a problem. That is why we are investigating other ways to
do it.
Kind regards
Arthur
On Mar 10, 2010, at 2:51 PM, Holger Knublauch wrote:
> Hi Arthur,
>
> this would certainly be possible, but it would help me understand your use
> case.
>
> 1) What data structure would you like to operate on? Result sets of SELECT
> queries are basically tables, or would you like the JSON objects?
>
> 2) What kind of operations would you like to perform over those result sets?
>
> I have a new technology available for 3.3: SPIN Result Sets
>
> http://spinrdf.org/spr.html
>
> that might be interesting here. I could leverage the same ideas to become
> available via SPINx as well, but with SPIN Result Sets you could probably do
> a pure SPIN solution?
>
> Regards,
> Holger
>
>
>
> On Mar 10, 2010, at 11:04 AM, Arthur Keen wrote:
>
>> I have created a number of spinx (javascript) functions using simple types
>> like string, integer, and float arguments, and this has been working
>> fantastically, however, I would like to pass bigger chunks of information to
>> Javascript. Is it possible to define arguments and return types that are
>> resultsets?
>>
>> Kind Regards
>> Arthur
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "TopBraid Composer Users" group.
>> To post to this group, send email to
>> [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/topbraid-composer-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "TopBraid Composer Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/topbraid-composer-users?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"TopBraid Composer Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/topbraid-composer-users?hl=en.