Top Banner
COMP 9314 XML – Part 2
61

week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

May 09, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

COMP 9314

XML – Part 2

Page 2: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Agenda

�Last week, we discuss mainly XML basics & XML storage

�This week:

�Some basic XML indexing

�XPath containment

�From distributed XML data to XML data synchronization

Page 3: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Path indexing

�Traversing graph almost = query processing for semistructured / XML databases (the whole point)

�Normally, it requires to traverse the data from the root and return all nodes X reachable by a path matching the given regular path expression

�Motivation: allows the system to answer regular path expressions without traversing the whole graph

Page 4: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Major Criteria for indexing

�Speed up the search (by cutting the search space down)

�Relatively smaller size than the original data graph

�Easy to maintain (during data loading during updates)

Page 5: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Two more techniques

�Based on the idea of language-equivalence

�Idea like Data Guide in Lore

Page 6: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

An Example of DAG Data

root

o12

o1

o2

o3 o4

o5 o6

o7

o8

o9 o10

o11

o13

member

deptdept

support

membermember

dept

staff staff staff

membermember

member

name name namephone

staff

Page 7: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Index graph based on

language-equivalence

�a reduced graph that summarizes all paths from the root in the data graph

�The paths from root to o12

�staff

�dept/member

�support/member

Page 8: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Language-equivalent nodes

� Let L(x) := {w | ∃ a path from the root to x labeled w}

�The set L(x) may be infinite when there are cycles

�Nodes x, y are language-equivalent (x ≡y) if L(x) = L(y)

�We construct index I by taking the nodes to be the equivalent classes for ≡

Page 9: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Language-equivalent

�The paths from root to o3

�staff

�dept/member

�Paths to o4 happen to be exactly the same 2 sequences

�Same for o8 and o12

�o3 ≡ o4 ≡ o8 ≡ o12

Page 10: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Equivalence classes

root

o12

o1

o2

o3 o4

o5 o6

o7

o8

o9 o10

o11

o13

member

deptdept

support

membermember

dept

staff staff staff

membermember

member

name name namephone

staff

o3 ≡ o4 ≡ o8 ≡ o12

o1 ≡ o2 ≡ o7

o12 ≡ o13

o5 ≡ o6 ≡ o9

o10

o11

Page 11: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

The index graph

o3 ≡ o4 ≡ o8 ≡ o12o1 ≡ o2 ≡ o7o12 ≡ o13o5 ≡ o6 ≡ o9o10o11

root

o1, o2, o7

o3, o4, o8, o12

o12, o13

o5, o6, o9 o10

o11

member

support

staff dept

name phone

member

Page 12: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Query processing based on

the index graph

root

o1, o2, o7

o3, o4, o8, o12

o12, o13

o5, o6, o9 o10

o11

member

supportstaff dept

name phone

member

dept/member/(name | phone)

-> dept/member/name UNION dept/member/phone

-> {o5, o6, o9} UNION {o10}

-> {o5, o6, o9, o10}

Page 13: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

About this indexing scheme

�The index graph is never > the data

�In practice, the index graph is small enough to fit in memory

�Construct the index is however a problem

�check two nodes are language-equivalent is very expensive (are PSPACE)

�approximation based on bisimulation exists

Page 14: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

A Data Guide

root

o1, o2, o7 o3, o4, o8, o12

deptstaff

support

o11

o12, o13

member

o3, o4, o8, o12

member name

o5, o6, o9

name

o5, o6, o9

o10

phone

o10

phone

Page 15: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

About Data Guide

�unique labels at each node

�(hence) extents are no longer disjoint

�query processing proceeds as before

�size of the index may >= data size

�not desirable when the data is irregular & has many cycles

Page 16: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Intro to distributed query

evaluation

�Web data is inherently distributed

�Reuse some techniques from distributed RDBMS if some schema info is known

�New techniques required if no schema info is known

�In XML, these links are denoted in XLinksand XPointers.

Page 17: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Example query without

schema knowledge

�Assume data are distributed in 3 sites

�Assume the RPE: a.b*.c

�The query starts from site 1

s1 s2 s3

a

b

c

Page 18: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

The database

x1

x3

x2

x4

y1

y2

y3

z1 z2

z3z4

a

a

cd

d

bb

bb

b

a

c

c

cSite 1

Site 2

Site 3

b

b

b

c

d

Page 19: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Naïve approach

�A naïve approach takes too many communication steps

�=> we have to do more work locally

�A better approach needs to

�1. identify all external references

�2. identify targets of external references

Page 20: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Input and output nodes

�Site 1�Inputs: x1 (root), x4

�Outputs: y1, y3

�Site 2�Inputs: y1, y3

�Outputs: z2

�Site 3�Inputs: z2

�Outputs: x4

Page 21: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Query Processing

�Given a query, we compute its automaton

�Send it to each site

�Start an identical process at each site

�Compute two sets Stop(n, s) and Result(n, s)

�Transmits the relations to a central location and get their union

Page 22: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Stop and Result at site 2

Start Stop

(y1, s2) (z2, s2)

(y3, s2) (z2, s2)

Start Result

(y1, s2) y3

(y1, s3) y1

(y3, s3) y3

Page 23: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Union of the relations

Start Stop

(x1, s1) (y1, s2)

(x4, s2) (y3, s3)

(y1, s2) (z2, s2)

(y3, s2) (z2, s2)

(z2, s2) (x4, s2)

Start Result

(x1, s3) x1

(x4, s2) x3

(x4, s3) x4

(y1, s2) y3

(y1, s3) y1

(y3, s3) y3

(z2, s1) z3

(z2, s2) z2

(z2, s3) z2

The result of the query

is {y3, z2, x3}

Page 24: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

XPath Containment

*Credits: slides in this topic authored by Dan Suciu

Page 25: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Visual representation of

XPath

/db/person/name/db/person/name/db//title/db//title

db

person

name

root

db

title

root

Page 26: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

More graphical XPath

//person[name][*//@zip=“12345”]/phone//person[name][*//@zip=“12345”]/phone

person

root

phonename *

@zip

“12345”

Page 27: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Assumptions

Additional things in XPath, which we ignore:

�13 axes:�child (/), descendant (//), parent (..), etc

�Order:�second child, following sibling, etc

�Complex predicates:�@age>25 AND @age<35

�Functions

�Boolean operations�AND, OR, NOT

Page 28: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Remark 1: Branches May Overlap

/department[person/project]/person/phone/department[person/project]/person/phone

department

root

phone

personperson

project

<department>

<person>

<name> Smith </name>

<project> optimizer </project>

<phone> 1234 </phone>

</phone>

</department>

<department>

<person>

<name> Smith </name>

<project> optimizer </project>

<phone> 1234 </phone>

</phone>

</department>

root

department

person

projectname phone

XMLXPath

Page 29: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Remark 2: Query Types

root

department

person

“Smith”

phone

root

department

person

“Smith”

phoneperson person

department

Query written by human: Query generated automatically:

Page 30: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Equivalence, Containment

�E = E’ if they return the same result

�E ⊆ E’ if the result returned by E is a subset of that returned by E’

�Applications:�Checking constraints:

⌧K is a key expression

⌧is E a key too ?

⌧Yes, if E ⊆ K

�Expression simplification

�Query rewriting

�Smart Caching

Page 31: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Prior Work

�Define XPath*,// to be:

�Similarly, XPath* and XPath//

[Wood’00]DecidableXPath*,//

[Amer-Yahia et al’01]

PTIMEXPath//

[Yannakakis’81]PTIMEXPath*

E ::= nodeType | * | E/E | E//E | E[E]E ::= nodeType | * | E/E | E//E | E[E]

Page 32: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Examples of Containment

/person[name]/name/person[name]/name/person/name/person/name

name

person

name

person

name

E E’

Page 33: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Examples of Containment

A homomorphism from E’ to E is always sufficient

For XPath* and XPath// it is also necessary

a

a

b *

a c

b

a

a

c d

a c

b a

Page 34: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Containment for XPath*,//

�Interaction between * and // turns out to be hard

�Study linear XPath*,// first

�Then full XPath*,//

Page 35: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Linear XPath*,//

/person//*/name /person//*/name /person/*//name /person/*//name

person

name

*

person

name

* ?

Page 36: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Practical Algorithm for

Linear XPath*,//

�Define a block in E’=

�Starts with a symbol (not *)

�Ends with a symbol (not *)

�Does not have any //

�Define a rubber band in E’ =

�Has only * nodes, at least one // edge

Page 37: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Practical Algorithm for

Linear XPath*,//

Fact E ⊆ E’ iff there exists a homomorphism from the blocks/rubber-bands of E’ to E

Algorithm Match greedily blocks in E’ to E, skipping nodes for rubber bands

Worst case: O(mn)

[Milo&Suciu’99]

Page 38: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Example 1

/person//*/name /person//*/name /person/*//name /person/*//name

person

name

*

person

name

*

person

name

≥1

≥0

Page 39: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Example 2a

b

b

c

*

a

d

b

a

c

a

b

d

a

*

b

*

c

*

*

d

a

b

*

c

d

≥1

≥2

E E’

Page 40: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Example 3

/person//name /person//name /person/*//name /person/*//name

person

name

*

person

name

≥0

person

name

≥1

≥0

?

Page 41: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Branching XPath*,//

�Single homomorphism doesn’t suffices �

a

b

c

d

b

c

d

b

c

d

*

a

b

c

d

b

c

d

*

=0

=0≥1 ≥1

??

OR

Need to reason by cases !

Page 42: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Practical Algorithms for

Branching XPath*,//

�Will be EXPTIME in general

�Should run in PTIME for:

�Linear XPath*,//

�XPath*

�XPath//

Page 43: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Practical Algorithms for

Branching XPath*,//

�Better: should be parametric PTIME:

�Linear XPath*,// plus small number of branches

�XPath* plus small number of //’s

�XPath// plus small number of *’s

�Reason: users may use branches, //’s, *’s occasionally

Page 44: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Practical Algorithms for

Branching XPath*,//

Running time is exponential in general, but…

Let m = number of //’s in E

Let n = number of *’s in E’

Theorem The algorithm runs in time:O(|E| x |E’| x nm)

Parametric PTIME: XPath* + some //’s

PTIME: XPath//

Page 45: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

From distributed XML to

mobile XML

�Other than query processing

�Mobile users care about Data Sync

Page 46: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

A Mobile DB System

Page 47: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Traditional Approach

1 2 3

update

Page 48: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Assumptions

�Data stored in XML documents/databases

�Data retrieved using XQL or XPath

�Data updated using some extended update operations, e.g.,

�author/name!update(“smith”)

�book/remarks!delete()

�/db/book!moveAfter(/db/magazine)

Page 49: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Update Scenario 1

/a/b /a/b/c /c

1 2 3

c/d !update(“23”)

Page 50: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Update Scenario 2

/a/b /a/b/c /c

1 2 3

d/e/f !update(“10”)

Page 51: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Update Scenario 3a

/a/b /a/b/c /c

1 2 3

d/e/f !update(“15”)

Page 52: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Update Scenario 3b

/a/b /a/b/c /c

1 2 3

d/e/f !update(“15”)

Page 53: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Example snapshot

Page 54: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Containment Index

10

12, 16

15, 2 6 -1

9, 11, 1 13

4

3, 2 2

cid path len ptr

10 / 1

12 /* 2

15 /a

6 /b

16 //*

2 //a

9 /a/b 4

13 /a/c

11 /a//b

3 /b/a

1 //a//b

4 /a/*/d 6

-1 /c 2

Page 55: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Outline of the Algorithms

�Insertion

�Sort the PEs according to

⌧#tokens, /, //, *, literal

�For each PE:

⌧Search for a match from the root node

⌧Insert the CID into the appropriate place

⌧Special attention to // & * (details in the paper)

Page 56: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Synchronization Algorithm

� Assume CID = c and its local db = path1 and its update = path2!upd(x), do the following using the constructed containment index:

�Notify CIDs in all c’s ancestors

�Perform either:�(A) Notify CIDs in all c’s descendants

�(B) Perform the containment test on each descendant node against path1/path2. If contained, notify all CIDs of that node.

�(A) or (B) or their mixture depending on the ratio bet’n server-load and network-load

Page 57: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Update merging

�Idea: merging several update statements to minimize the mobile device’s connection time

�Solution: conflict detection & resolution

�Conflict detection: similar to the previous containment index except now dealing with operations instead of cids

Page 58: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Conflicts

�Direct conflict (DC)

�e.g., a/b!insert(d); a!delete( )

�Syntax conflict (SC)

op opAfter opBefore

op Yes No No

opAfter No Yes Yes

opBefore No Yes Yes

Page 59: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Operation Index

opid cid path op len ptr

1 11 / ins 1

2 12 /a del 2

3 13 /b insB 2

4 14 //b insB 2

5 15 /a/c ins 4

1

2 3, 4

5

SC

DC

Page 60: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Performance

Page 61: week13 - Computer Science and Engineeringcs9314/07s1/lectures/week13-1.pdf · 2007-05-28 · An Example of DAG Data root o12 o1 o2 o3 o4 o5 o6 o7 o8 o9 o10 o11 o13 member dept dept

Results

�Update notification based on containment relationship

�“False negative” is acceptable when the server-load is more critical than the network-load

�Efficient index & its algorithm to support the containment checking

�Mechanism for merging updates to further enhance the performance