Docsity

Sequence Processing - Lecture Slides - Data Streams | CS 410, Study notes of Computer Science

Toggle sidebar
bg1
Data Streams 07: Lecture 19
1
CS 410/510
Dt St
D
a
t
a
St
reams
Lecture 19: Sequence Processing
David Maier, Kristin Tufte
11/28/2007 Data Streams: Lecture 19 1
Other References
๎š„Lerner, Shasha. AQuery: Query Processing
for Ordered Data, Optimization
Thi d E i t
VLDB 2003
T
ec
h
n
i
ques,
an
d E
xper
i
men
t
s.
VLDB 2003
.
๎š„Lerner, Shasha. The Virtues and
Challenges of Ad Hoc + Streams Querying
in Finance.
DE Bulletin, March 2003
.
11/28/2007 Data Streams: Lecture 19 2
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Sequence Processing - Lecture Slides - Data Streams | CS 410 and more Study notes Computer Science in PDF only on Docsity!

CS 410/

D tData Streams St

Lecture 19: Sequence Processing

David Maier, Kristin Tufte

11/28/2007 Data Streams: Lecture 19 1

Other References

ย„ Lerner, Shasha. AQuery: Query Processing for Ordered Data, Optimization

TTechniques, and Experiments. h i d E i t VLDB 2003VLDB 2003.

ย„ Lerner, Shasha. The Virtues and Challenges of Ad Hoc + Streams Querying

in Finance.DE Bulletin, March 2003.

11/28/2007 Data Streams: Lecture 19 2

Working With Sequences

What if we want a 3-value moving average of temperature over timetemperature over time reading# temp 3VMA 1 60 60 2 66 63 3 60 62

11/28/2007 Data Streams: Lecture 19 3

How About This SQL?

select r1.reading#, (r1.temp + r2r2. temp temp + r3 temp)/3 + r3.temp)/3 asas 3VMA3VMA from Temps r1, Temps r2, Temps r where (r1.reading# - 1) = r2.reading# and (r2.reading# - 1) =

11/28/2007 Data Streams: Lecture 19 4

r3.reading#

AQuery Language

Aimed at sequence data (e.g., financial time series) use arrays in the modelseries), use arrays in the model Arrays are technically 1-dimensional, but can have vector-valued arrays

11/28/2007 Data Streams: Lecture 19 7

Arrable

View ordered relation as record of arrays of the same lengththe same length reading# temp 3VMA 1 60 60 2 66 63 3 60 62

11/28/2007 Data Streams: Lecture 19 8

Array-valued Variables

A query variable (e.g., Temp) represents the whole columnwhole column Operations have array inputs ย‰ array output: prev, sums, mins, reverse, +, < some can be windowed ย‰ scalar output: first, last, sum, min

11/28/2007 Data Streams: Lecture 19 9

Moving Average Query in AQuery

select reading#, avgs (3, temp) from Temps assuming order reading#

11/28/2007 Data Streams: Lecture 19 10

select max (temp โ€“ mins(temp)) from Temps assuming order reading# reading# tempreading# temp mt=mins(temp)mt mins(temp) 1 70 70 2 73 70 3 66 66 4 63 63

11/28/2007 Data Streams: Lecture 19 13

select max (temp โ€“ mins(temp)) from Temps assuming order reading# reading# tempreading# temp mtmt dt=temp-mtdt temp mt 1 70 70 0 2 73 70 3 3 66 66 0 4 63 63 0

11/28/2007 Data Streams: Lecture 19 14

select max (temp โ€“ mins(temp)) from Temps assuming order reading# reading# tempreading# temp mt dt=temp-mtmt dt temp mt 1 70 70 0 2 73 70 3 3 66 66 0 4 63 63 0

11/28/2007 Data Streams: Lecture 19 15

5 68 63 5 max 6 61 61 0 7 63 61 2

VWAP Query

Volume-Weighted Average Price Trades(ts, pr, vol) select sums (3, pr*vol)/ sums (3,vol) from Trades assuming order ts

11/28/2007 Data Streams: Lecture 19 16

select sums (3, pr*vol)/ sums (3,vol) from Trades assuming order ts tts pr vol l pv 3 3pv=sums(3,pv) (3 ) 1 5 100 500 500 2 6 200 1200 1700 3 4 300 1200 2900 4 4 100 400 2800

11/28/2007 Data Streams: Lecture 19 19

select sums (3, pr*vol)/ sums (3,vol) from Trades assuming order ts tts pr vol l pv 3 3pv 3 3v=sums(3,vol) (3 l) 1 5 100 500 500 100 2 6 200 1200 1700 300 3 4 300 1200 2900 600 4 4 100 400 2800 600

11/28/2007 Data Streams: Lecture 19 20

select sums (3, pr*vol)/ sums (3,vol) from Trades assuming order ts tts pr vol l pv 3 3pv 3 3v vwap=3pv/3v 3 / 1 5 100 500 500 100 5. 2 6 200 1200 1700 300 5. 3 4 300 1200 2900 600 4. 4 4 100 400 2800 600 4 6

11/28/2007 Data Streams: Lecture 19 21

ts pr vol pv 3pv 3v vwap

Can Imagine Streaming the

Computation

11/28/2007 Data Streams: Lecture 19 22