Abstract
XQuery 1.0, while powerful for static XML documents, lacked native support for processing continuous data streams. This paper proposes a robust extension to XQuery to bridge this gap. By introducing the forseq clause for sophisticated windowing and extending the XQuery Data Model (XDM) to accommodate infinite sequences, the authors transform XQuery into a first-class language for stream processing. Evaluation via the MXQuery engine on the Linear Road Benchmark shows that this general-purpose approach can match the performance of specialized, low-level stream management systems.
Introduction
In the mid-2000s, XML became a standard for various streaming data sources, including RSS feeds, financial tickers, and sensor networks. However, XQuery 1.0 was designed primarily for finite, static documents. Querying patterns across sequences—such as identifying consecutive events—required complex and inefficient self-joins. Furthermore, the language lacked a mechanism for "continuous queries" that could operate indefinitely on potentially infinite data streams.
Proposed Extensions
The authors address these limitations through two primary extensions:
The forseq Clause
The core of the proposal is the forseq clause, a new addition to the FLWOR expression. Unlike the standard for clause that binds variables to individual items, forseq binds variables to sub-sequences, or "windows." These windows are defined using XQuery predicates for start and end conditions, allowing for logic based on data content (e.g., session start/end events) rather than just fixed time or count offsets.
The system natively supports several windowing semantics:
- Tumbling: Disjoint windows where one ends and the next begins.
- Sliding: Overlapping windows.
- Landmark: Windows with a fixed starting point and a moving end point.
Infinite Sequences and the XDM
To handle streams that never end, the XQuery Data Model was extended to support infinite sequences, denoted by a double asterisk (e.g., item()**). This distinction allows the compiler to identify blocking operations (like sorting) that are incompatible with infinite streams and to apply appropriate non-blocking alternatives.
Implementation: MXQuery
These features were implemented in MXQuery, an open-source, Java-based XQuery engine. A key component of this implementation is the "Stream Buffer," which utilizes lazy materialization and aggressive garbage collection to maintain a low memory footprint during high-volume stream processing.
Evaluation
The system was evaluated using the Linear Road Benchmark, a standard for Data Stream Management Systems (DSMS) that simulates a real-time highway tolling system. MXQuery was compared against specialized C-based engines like Aurora and IBM Stream Core.
Key results include:
- Performance Parity: MXQuery achieved a scale factor of L=1.5, demonstrating performance parity with specialized systems despite the overhead of the Java Virtual Machine.
- Compliance: It was the first XQuery-based system to meet the benchmark's strict real-time response requirements.
- Optimization: Techniques such as "Predicate Movearound" and "Hopeless Window" detection (early termination of windows that can no longer be satisfied) proved vital for efficiency.
Conclusion and Future Work
This work demonstrates that XQuery's sequence-based nature makes it a natural fit for stream processing. While the prototype required some manual query partitioning and faced JVM-related overhead, it proved the viability of using a general-purpose XML language for complex streaming tasks. This research served as a foundational proposal for the windowing features eventually integrated into the XQuery 3.0 standard.
Summary updated