xzx - Aarhus Universitet

Download Report

Transcript xzx - Aarhus Universitet

Fully Persistent B-Trees
Gerth Stølting Brodal
Konstantinos Tsakalidis
Aarhus University, Denmark
Spyros Sioutas
Ionian University, Corfu, Greece
Kostas Tsichlas
Aristotle University of Thessaloniki, Greece
23rd Annual ACM-SIAM Symposium on Discrete Algorithms, Kyoto, Japan, January 18, 2012
Binary Tree
3
8
2
1
6
4
9
7
Binary Search Tree
3
8
2
1
6
4
9
7
Insert(5)
3
8
2
1
6
4
9
7
5
Balanced Binary Search Tree
3
Height
O(log n)
8
2
1
6
4
9
7
Report(2,7)
3
Height
O(log n)
8
2
1
6
4
9
7
Time O(log n + t)
Red-Black Tree
3
8
2
1
6
4
9
7
5
Bayer 1972
Red-Black Tree - rebalancing
restructure
O(1)
3
8
2
1
recolor
O(log n)
6
6
4
3
9
7
2
1
8
4
7
9
5
5
Bayer 1972
Partially
FullyEphemeral
Persistent Red-Black Tree
6
3
8
3
3
2 4 7 9
Version
Contributions
of Driscoll et al. 1 5
2 8
1
tree
6
3
3
3
3
3
trees
with2 O(1)
modifications
3
2 8
2 8 per 3
8
31. Red-black
8
2 8
2 8
2 8
1 6 9
1 6 9
6 9
2
2 4 7 9
update
paths)
6(displacement
6 9
7
4 7
7
1
5
3
2. General technique
to make pointer based
2 8only
query
data structures
1 6 fully persistent
6
3
2
1
8
4 7
9
5
Expensive to record updates performing
many modifications
Driscoll, Sarnak, Sleator, Tarjan 1986
IO model
Complexity =
# block transfers
CPU
Memory
Disk
Memory
Fully Persistent
CPU
Search Trees
RAM model
B
Binary Search
Trees
Complexity =
# instructions
Red-Black
Trees
B-Trees
Bayer 1972
Bayer 1972
Maintaining
Order in a List
Incremental
B-Trees
Dietz, Sleator 1987
Red-Black Trees w.
Displacement Paths
Driscoll et al. 1986
IO Efficient
Node Splitting
Fully Persistent
B-Trees
Full Persistence:
Node splitting
Driscoll et al. 1986
Fully Persistent Balanced
Binary Search Trees
Driscoll et al. 1986
Results
n
t
m
B
=
=
=
=
# elements in B-tree
output size
# versions / updates
block size
Incremental B-tree with range searches in O(logB n + t/B) IOs, updates
in O(logB n) IOs with O(1) key and pointer modifications, O(n/B) space
Any emphemeral pointer based IO data structure with O(1) indegree
can be made fully persistent with O(1) overhead per block access and
O(log2 B) IOs amortized overhead per field modification
Fully persistent B-tree with updates in O(logB n + log2 B) IOs amortized,
range searches in O(logB n + t/B) IOs, O(m/B) space
Partial
Full
Persistent B-tree result
Arge, Danner, Teh 2003
Lanka, Mays 1991
This talk
Query
logB n + t/B
(logBn + t/B) ∙ logB m
logB n + t/B
Update
logB n
logB n ∙ logB m
logB n + log2 B
Incremental Search Tree Updates
B-Tree
w
w
degree [B,2B]
height O(logB n)
Incremental B-tree
Range searches visit O(logB n + t/B) nodes.
Updates...
Cascaded
Cascaded
1.
visit
O(log
n)
nodes
B
recoloring
splitting
w
2. modify O(1) pointers and keys
3. creates O(1) new empty nodes
x
x
y
x
y
Displacement path wx
 flip all colors on path + all
red siblings (flag w with x)
Driscoll et al. 1986
...
...
w
Overflow flag
(path wx)
Counts twice
...
w
Splitting pair
...
w
Ready to
overflow
Full persistence : Node Splitting Technique
Driscoll, Sarnak, Sleator, Tarjan 1986
1
4
increasing
version
7
3
5
2
6
1
preorder traversal
4
7
5
3
6
2
Version list
(order maintenance data structure)
Dietz, Sleator 1987
...
in
the
IO
model
Version tree (numbers = version ids)
1. O(B) fields & updates in a node
2. local version list LVL of all version
ids (7,z)
in block
Fat node
field: (1,x)
(5,x) (6,y) (2,x)
Queries
among versions
3.= binary
eachsearch
inpointer
spans O(1) verions
LVL
Updatesin
(1,x)
(6,y) (7,z)
Node splitting (# ekstra fields ≥2∙indegree)
[5,3[
[0,[
[4,3[
field1: (1,a) (4,b) (3,a) (2,c)
field2: (1,f) (7,g) (5,f)
[0,5[
[4,5[
[5,[
split
field1: (1,a) (4,b)
field1: (5,b) (3,a) (2,c)
version 5
field2: (1,f) (7,g)
field2: (5,f)
13
Main result
?
Fully persistent B-tree with updates in O(logB n + log2 B)
IOs, searches in O(logB n + t/B) IOs, using space O(m/B)
Thank You