


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















CS 245 Notes 4 1
CS 245 Notes 4 2
record
CS 245 Notes 4 3
CS 245 Notes 4 4
Sequential File 2010 4030 6050 8070 10090
CS 245 Notes 4 5
Sequential File 2010 4030 6050 8070 10090
Dense Index (^1020) (^3040) (^5060) (^7080) 10090 (^110120) CS 245 Notes 4 6
Sequential File 2010 4030 6050 8070 10090
Sparse Index (^1030) (^5070) 11090 (^130150) (^170190) (^210230)
CS 245 Notes 4 7
Sequential File 2010 4030 6050 8070 10090
Sparse 2nd level (^1030) (^5070) 11090 (^130150) (^170190) (^210230)
(^1090) (^170250) (^330410) (^490570)
CS 245 Notes 4 8
CS 245 Notes 4 9
Question:
CS 245 Notes 4 10
Notes on pointers:
CS 245 Notes 4 11
Notes on pointers:
CS 245 Notes 4 12
R R R R
CS 245 Notes 4 19
(^1020) (^3040)
Dense index, better way?
Duplicate keys
CS 245 Notes 4 20
(^1010) (^2030)
Sparse index, one way?
Duplicate keys
CS 245 Notes 4 21
(^1010) (^2030)
Sparse index, one way?
Duplicate keys
CS 245 Notes 4 22
(^1020) (^3030)
Sparse index, another way?
Duplicate keys
CS 245 Notes 4 23
(^1020) (^3030)
Sparse index, another way?
Duplicate keys
CS 245 Notes 4 24
Duplicate values, primary index
Summary
a
aa b
CS 245 Notes 4 25
Deletion from sparse index
2010 4030 6050 8070
(^1030) (^5070) 11090 (^130150) CS 245 Notes 4 26
Deletion from sparse index 2010 4030 6050 8070
(^1030) (^5070) 11090 (^130150)
CS 245 Notes 4 27
Deletion from sparse index
2010 4030 6050 8070
(^1030) (^5070) 11090 (^130150)
CS 245 Notes 4 28
Deletion from sparse index 2010 4030 6050 8070
(^1030) (^5070) 11090 (^130150)
CS 245 Notes 4 29
Deletion from sparse index
2010 4030 6050 8070
(^1030) (^5070) 11090 (^130150)
CS 245 Notes 4 30
Deletion from sparse index 2010 4030 6050 8070
(^1030) (^5070) 11090 (^130150)
CS 245 Notes 4 37
Insertion, sparse index case
(^201030) (^504060)
(^1030) (^4060)
CS 245 Notes 4 38
Insertion, sparse index case
(^201030) (^504060)
(^1030) (^4060)
CS 245 Notes 4 39
Insertion, sparse index case
(^201030) (^504060)
(^1030) (^4060)
34
Insertion, sparse index case
(^201030) (^504060)
(^1030) (^4060)
CS 245 Notes 4 41
Insertion, sparse index case
(^201030) (^504060)
(^1030) (^4060)
CS 245 Notes 4 42
Insertion, sparse index case
(^201030) (^504060)
(^1030) (^4060)
CS 245 Notes 4 43
Insertion, sparse index case (^201030) (^504060)
(^1030) (^4060)
CS 245 Notes 4 44
Insertion, sparse index case (^201030) (^504060)
(^1030) (^4060)
CS 245 Notes 4 45
Insertion, dense index case
CS 245 Notes 4 46
Secondary indexes (^) Sequence field 5030 7020 4080 (^10010) 6090
CS 245 Notes 4 47
Secondary indexes (^) Sequence field 5030 7020 4080 (^10010) 6090
CS 245 Notes 4 48
Secondary indexes (^) Sequence field 5030 7020 4080 (^10010) 6090
CS 245 Notes 4 55
Duplicate values & secondary indexes 1020 4020 4010 4010 4030
(^1010) (^1020) (^2030) (^4040) (^4040) ...
CS 245 Notes 4 56
Duplicate values & secondary indexes 1020 4020 4010 4010 4030
4030
20
CS 245 Notes 4 57
Duplicate values & secondary indexes 1020 4020 4010 4010 4030
4030
CS 245 Notes 4 58
Duplicate values & secondary indexes 1020 4020 4010 4010 4030
(^1020) (^3040) (^5060) ...
Another idea (suggested in class):Chain records with same key?
CS 245 Notes 4 59
Duplicate values & secondary indexes 1020 4020 4010 4010 4030
(^1020) (^3040) (^5060) ...
Another idea (suggested in class):Chain records with same key?Problems:
Duplicate values & secondary indexes 1020 4020 4010 4010 4030
(^1020) (^3040) (^5060) ...
CS 245 Notes 4 61
Why “bucket” idea is useful
CS 245 Notes 4 62
Dept. index EMP Floor index Toy 2nd
CS 245 Notes 4 63
Dept. index EMP Floor index Toy 2nd
CS 245 Notes 4 64
This idea used intext information retrieval
...the cat isfat ... ...was rainingcats and dogs... ...Fido thedog ...
CS 245 Notes 4 65
This idea used in text information retrieval
...the cat isfat ... ...was rainingcats and dogs... ...Fido thedog ... Inverted lists
cat dog
CS 245 Notes 4 66
IR QUERIES
CS 245 Notes 4 73
CS 245 Notes 4 74
CS 245 Notes 4 75
CS 245 Notes 4 76
Summary so far
CS 245 Notes 4 77
Conventional indexes
continuous free space
CS 245 Notes 4 79
continuous free space
CS 245 Notes 4 80
Outline:
CS 245 Notes 4 81
CS 245 Notes 4 82
B+Tree Example n=
100 (^30120150180) (^35113035100101110120130150156179180200)
CS 245 Notes 4 83
Sample non-leaf
CS 245 Notes 4 84
Sample leaf node: From non-leaf node 57 81 95 to next leafin sequence
To recordwith key 57To recordwith key 81To recordwith key 85
CS 245 Notes 4 91
Insert into B+tree
CS 245 Notes 4 92
CS 245 Notes 4 93
CS 245 Notes 4 94
CS 245 Notes 4 95
CS 245 Notes 4 96
CS 245 Notes 4 97
CS 245 Notes 4 98
CS 245 Notes 4 99
CS 245 Notes 4 100
CS 245 Notes 4 101
CS 245 Notes 4 102
CS 245 Notes 4 109
n=
CS 245 Notes 4 110
(d) Non-leaf coalese– Delete 37 n= 25
CS 245 Notes 4 111
(d) Non-leaf coalese– Delete 37 n=
CS 245 Notes 4 112
(d) Non-leaf coalese– Delete 37 n=
CS 245 Notes 4 113
(d) Non-leaf coalese– Delete 37 n=
CS 245 Notes 4 114
B+tree deletions in practice
CS 245 Notes 4 115
Comparison: B-trees vs. staticindexed sequential file
CS 245 Notes 4 116
CS 245 Notes 4 117
Example: 1 block static index
127 keys (127+1)4 = 512 Bytes-> pointers in index implicit! up to 127 blocks
k1k k
k k k
1 datablock
CS 245 Notes 4 118
Example: 1 block B-tree
63 keys 63x(4+4)+8 = 512 Bytes-> pointers needed in B-tree up to 63 blocks because index isnot contiguous blocks
k1k k63...
k k k
1 datablock
CS 245 Notes 4 119
Size comparison Ref. #
2 -> 127128 -> 16,129 23 2 -> 6364 -> 3968 (^23) 16,130 -> 2,048,383 4 3969 -> 250,047250,048 -> 15,752,961 (^45)
CS 245 Notes 4 120
Ref. #1 analysis claims