Download Data Streams Lecture 17: Publish-Subscribe - Prof. David E. Maier and more Study notes Computer Science in PDF only on Docsity!
CS 410/
D tData Streams St
Lecture 17: Publish-Subscribe
David Maier, Kristin Tufte
h h k l
11/19/2007 Data Streams: Lecture 17 1
with thanks to Yanlei Diao
Other References
Diao, Franklin. Query Processing for High-
Volume XML Message Brokering.CIDR
Diao, Rizvi, Franklin. Towards an Internet-
Scale XML Dissemination Service.VLDB
11/19/2007 Data Streams: Lecture 17 2
The Need for Push-Based
Movement of Information
Having every interested application monitor
a data source doesn’t scalea data source doesn t scale
Imagine a nationwide database of classified
advertisements
Say that 1M people each want to find out when
any new ad shows up in a certain classification
ll
11/19/2007 Data Streams: Lecture 17 3
What if all 1M were submitting a query to the
database every 10 seconds?
Poll-based monitoring doesn’t scale
Notification and Dissemination
Many push-based scheme for monitoring
D t bDatabase triggers, Event-Condition-Action t i E t C diti A ti
(ECA) rules
Continuous queries (CQs)
Broadcast mechanisms: Datacycle, broadcast
disks
Semantic message routing
11/19/2007 Data Streams: Lecture 17 4
Semantic message routing
Publish-subscribe
Simple Subscriptions
Consider classified ads
Mi ht bMight be set of attribute-value pairs t f tt ib t l i
S1: Category=Autos & Loc.State=Oregon
S2: Category=Autos & Make=Toyota
S3: Category=Cameras
Suppose S1 and S2 registered with broker
11/19/2007 Data Streams: Lecture 17 7
B1 and S3 registered with B
Avoid Broadcast of Everything
B3 forwards auto ads to B1 and camera ads
to B
UUses a routing table that associates predicates ti t bl th t i t di t
with B1 and with B
B
11/19/2007 Data Streams: Lecture 17 8
B B
S S
S
Considerations
Trading amount of work at broker for
precision in forwardingprecision in forwarding
B3 might just check Category
Less local work, more content forwarded
Could transform content on the way
Drop images in ads headed for handhelds
11/19/2007 Data Streams: Lecture 17 9
Custom results can increase result volume
ONYX: Operator Network using
YFilter for XML dissemination
Works with XML content
PP ermits user profiles (interests,i fil (i
subscriptions) to be XML queries with
result transformation
Based on YFilter
11/19/2007 Data Streams: Lecture 17 10
Protocol: Publishers
Register a data source w/ reg. service
PP rovide location, schema, rate, message sizeid l ti h t i
Get an ID &root broker
root broker notified first
Publish data: Send message to root broker
with ID, content
11/19/2007 Data Streams: Lecture 17 13
Protocol: Subscribers
Register data interest w/ reg. service
PP rovide profile (query) & network addressid fil ( ) & t k dd
Get an ID &host broker
Notifies host broker first
Update data interest w/ host broker
11/19/2007 Data Streams: Lecture 17 14
Note: No explicit “get content” call
Brokers Route with Queries
Routing Table: B
P
B
Q1: B
Q2: B1, B
Q3: B
B
B B
S S
S
S
Q
Q
Q
Q
Q1 ∧ Q
Q3 ∧ Q
11/19/2007 Data Streams: Lecture 17 15
S
YFilter: path matching engine for XML queries
YFilter
Q1=/a/b Q2=/a/c Q3=/a/b/c Q4=/a//b/c Q5=/a//c Q6=/a//c Q7=/a//*/c Q8=/a/b/c
A set of linear path expressions.
{Q1} b
Non-Deterministic Finite c {Q3, Q8}
Automaton with shared
11/19/2007 Data Streams: Lecture 17 16
{Q6}
{Q7}
{Q4}
{Q5}
{Q2} a
c ε c c
*b
c
c
Automaton with shared
prefixes
Running the NFA
/a/b/a
11 12
c
start: 1
/a: 2, 11, 6
/b: 3, 11, 6, 7
/a: 4 , 11, 6, 8
1 2 3 4
a * a
6 7 8
ε a
b
ε
11/19/2007 Data Streams: Lecture 17 19
Adding Transformation
Want to create customized query results
for each subscriptionfor each subscription
Can the shared-path matching capability
help with other parts of result generation?
11/19/2007 Data Streams: Lecture 17 20
YFilter Broker Architecture
XML messages (^) XML messagescustomized
message listener
ner
SAX XML parser
node- labeled tree
results in an inter- mediate format
message sender
message factory
path-tuple
post-processing module
11/19/2007 Data Streams: Lecture 17 21
Query Processor
queries
query listen
XQuery parser
parsed queries runtime
query compi- ler
p p streams shared path matching engine
Query Specification
Profiles (user queries) based on XQuery FLWR
expressions (for-let-where-result)
binding path
predicate
paths
return
for $s in $doc//section
where $s/title = “XML”
and $s/figure/title = “XML processing”
return
{ $s//section//title }
11/19/2007 Data Streams: Lecture 17 22
paths
{ $s//figure }
Three Approaches to Post-
Processing
Post-process PathTuple streams in
d ffdifferent ways to get final results f l l
Use XML-algebra style operators: dup-elim,
joins, evaluating path predicates
Push different amount of work into path
matcher.
N ll d
11/19/2007 Data Streams: Lecture 17 25
Not all user queries are interested in same
elements, nor in same order
for $s in $doc//section where $s/title = “XML” and $s/figure/title = “XML processing”
Alternative 1: PathSharing-F
Wh Filt
Return-Select //section (^2) 4
//section
and $s/figure/title XML processing return { $s//section//title } { $s//figure }
Path engine handles path from the for clauses An external plan per query:
Query i
DupElim
Where-Filter
shared path matching engine
σ
4 7 11 13 …
11/19/2007 Data Streams: Lecture 17 26
- Selection: value-based comparisons (//section[@id <= 2]).
- DupElim: same node might be bound multiple times
- Where-Filter: path predicates fromwhere clause.
- Return-Select: handles thereturn clause.
Why Duplicate Elimination?
{ for $f in
1 section
Return-Select
{ Where-Filter $doc//section[@id<=2]//figure where … return … }
Duplicates for the binding path:
PathTuples containing the same node id
2 section
figure^3
id = 1
id = 2
1 3 2 3
DupElim
1 3
11/19/2007 Data Streams: Lecture 17 27
PathTuples containing the same node id
in the last field.
YFilter
//section//figure 1 3 2 3
XQuery semantics says they should
be bound once.
σ^ id <=
for $s in $doc//section where $s/title = “XML” and $s/figure/title = “XML processing”
Alternative 2: PathSharing-FW
//section^ Query^ i^ Return-Select //section/title and $s/figure/title XML processing return { $s//section//title } { $s//figure }
Add predicate paths from the where clause (^) shared path matching engine
//section/figure/title
DupElim
σ
σ σ
11/19/2007 Data Streams: Lecture 17 28
Semijoins: find query matches after paths in the for and the where clause are matched. 2 4 7 11 13 …
//section (^) //section/title 3 8 12 …
2 7 11 …
2 7 11 …
//section/figure/title 2 7 11 …
//section 5 9 16 …
4 2 11 …
6 10 17 …
2 11 …
Performance Comparison
Bib DTD, number of distinct queries = 5000
Multi-Query Processing Time (MQPT) number of distinct queries = 5000, = number of predicate paths = 1, number of return paths = 2,
wall clock time not counting parsing
600
800
1000
T (ms)
Pat hSharing- F Pat hSharing- FW Pat hSharing- FWR
11/19/2007 Data Streams: Lecture 17 31
0
200
400
NoOpt Opt(q) Opt(q+dtd) Optim izations applied
MQP
Use of YFilter in ONYX
Routing table is one big YFilter, with
operator trees hanging off foroperator trees hanging off for
broker queries
user queries
incremental transform queries
11/19/2007 Data Streams: Lecture 17 32
Routing Table Construction
Three steps:
1. MMap: Put queries in canonical form (DNF) P i i i l f (DNF)
2. Collect: Get routing queries from children
brokers, merge, annotate with destination
YFilters can be merged. Can include local user
queries
11/19/2007 Data Streams: Lecture 17 33
3. Aggregate: Take merged query, make
yourself the destination in all cases, pass
to parent broker
Incremental Transform
Sometime useful to transform content
before it reaches the host brokerbefore it reaches the host broker
For example, if you know another broker only
services handheld, might trim all images
before forwarding anything there
11/19/2007 Data Streams: Lecture 17 34