[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Partitioning data by date

Ghislain Fourny gfourny at inf.ethz.ch
Thu May 20 12:11:48 PDT 2010


  Partitioning data by date
Hi Andrew,

If you are interested, with the tumbling windows Michael is mentioning (again, assuming your metrics are ordered by date) it could look like this:

<metrics>{
  for tumbling window $w in doc("metricsCollection.xml")//metric
  start at $s when fn:true()
  end $m at $e next $n when
    xs:date(xs:dateTime($m/timestamp)) ne xs:date(xs:dateTime($n/timestamp))
  return
  <metric>
    <date>{xs:date(xs:dateTime($m/timestamp))}</date>
    <num_actions>{$e - $s + 1}</num_actions>
  </metric>
}</metrics>

Tumbling windows cannot overlap, so you can start one whenever it is possible, and end a window as soon as the date in an item $m is not the same as in the following item $n. $s and $e indicate the start and end positions of the current window.

You can test this query in Zorba (http://try.zorba-xquery.com).

Kind regards,
Ghislain


> One would also expect a solution using XQuery 1.1 "tumbling windows" to be O(n)




PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.