240 likes | 429 Vues
Constructing Signature Graphs for Signature Files. Dr. Yangjun Chen Dept. Applied Computer Science University of Winnipeg Canada. Motivation Signature Files as Indexes Signature Graph and its Construction Signature Graph and its Construction Searching a Signature Graph
E N D
Constructing Signature Graphs for Signature Files Dr. Yangjun ChenDept. Applied Computer Science University of Winnipeg Canada
Motivation • Signature Files as Indexes • Signature Graph and its Construction • Signature Graph and its Construction • Searching a Signature Graph • Maintenance of Signature Graph • Summary and Future Work
Motivation • Establish Indexes to speed up query evaluation • B+-trees, inverted files, signature files • Signature files: simple and easy for maintenance • Signature graphs: less time for searching
Signature Files as Indexes • Definition A signature for a key word or an attribute value is hash-coded bit string. • Signature construction - Important parameters: m: number of 1s in bit string F: length of bit string D: size of a block (or average number of the key words of an element) - optimal choice of the parameters: Fln2 =mD.
Example: (constructing a signature for a word with m = 4 and F = 12) “database” letter triplets: dat, ata, tab, aba, bas, ase H(dat) = 5, H(ata) = 1, H(tab) = 8, H(aba) = 1, H(bas) = 10, H(ase) = 8. 100 010 010 100
Signature Files as Indexes text: … SGML … database …information … matching word signatures: queries: query signatures: results SGML 010000100110 SGML 010000100110 match with OS database 100010010100 XML 011000100100 no match with OS information 010100011000 informatik 110100100000 false drop object signature 110110111110 (OS)
name sex ... ... John male ... ... Ù query: John male query signature: 1010 0101 Example: relation:
Signature Graph Consider a signature si of length m. We denote it as si = si[1]si[2] ... si[m], where each si[j] {0, 1} (j = 1, ..., F). We also use si(j1, ..., jh) to denote a sequence of pairs w.r.t. si: (j1,si[j1])(j2, si[j2]) ... (jh, si[jh]), where 1 jk m for k {1, ..., h}. Definition (signature identifier)Let S = s1.s2 ... .sn denote a signature file. Consider si (1 in). If there exists a sequence: j1, ..., jh such that for any k i (1 kn)we have si(j1, ..., jh) sk(j1, ..., jh), then we say si(j1, ..., jh) identifies the signature si or say si(j1, ..., jh) is an identifier of si.
Example: s8(5, 1, 4) = (5, 1)(1, 1)(4, 0) (*For any i 8 we have si(5, 1, 4)s8(5, 1, 4). For instance, s5(5, 1, 4) = (5, 0)(1, 0)(4, 1) s8(5, 1, 4), s2(5, 1, 4) = (5, 1)(1, 1)(4, 1) s8(5, 1, 4), and so on.*) s1(5, 4, 1) = (5, 0)(4, 1)(1, 1) (*For anyi 1 we have si(5, 4, 1)s1(5, 4, 1).*)
Signature Graph • Definition (signature graph)A signature graph G for a signature file S = s1.s2 ... .sn, where si sj for i j and |sk| = F for k = 1, ..., n, is a graph G = (V, E) such that 1. each node vV is of the form (p, skip), where p is a pointer to a signature s in S, and skip is a non-negative integer i. If i > 0, it tells that the ith bit of sq will be checked when searching. If i = 0, s will be compared with sq. 2. Let e = (u, v)E. Then, e is labeled with 0 or 1 and skip(u) > 0. Let skip(u) = i. If e is labeled with 0 and i > 0, the ith bit of the signature pointed to by p(v) is 0. If e is labeled with 1 and i > 0, the ith bit of the signature pointed to by p(v) is 1. A node v with skip(u) = 0 does not have any children.
p2 5 0 1 1 0 0 p3 p6 4 1 1 1 1 p4 p7 1 2 p8 0 1 4 0 0 p5 p1 3 0 1 0 S1: 1011 0110 S2: 1011 1001 S3: 1010 0111 S4: 0111 0110 S5: 0111 0101 S6: 0101 1100 S7: 1110 0100 S8: 1010 1011
p1 p1 p2 p3 p1 p1 p2 p2 p3 p4 0 0 5 4 5 0 0 5 1 4 0 0 1 1 1 1 0 0 1 0 Insert s1 Insert s2 Insert s4 Insert s3 Construction of signature graph: 0 1
1 0 1 0 1 0 p5 p2 p1 p3 p6 p3 p2 p4 5 4 5 4 0 3 1 1 p4 1 0 1 0 1 0 1 0 p5 p1 3 0 0 1 1 1 0 Insert s5 Insert s6 Insert s7 Insert s8 p2 p2 5 5 1 1 0 1 0 1 0 0 0 0 p3 p6 p3 p6 4 4 1 1 1 1 1 1 1 p4 p4 p7 p7 1 1 2 2 p8 0 1 0 1 4 0 0 0 0 p5 p1 p5 p1 3 3 0 0 1 1 0
Signature Graph Searching a signature graph Denote sq(i) the i-th position of sq. During the traversal of a signature graph, the inexact matching can be done as follows: (i) Let v be the node encountered and sq (i) be the position to be checked. (ii) If sq (i) = 1, we move to the right child of v (iii)If sq (i) = 0, both the right and left child of v will be visited. (iv)A search along a path stops when a node without any child node or a node is encountered for the second time.
Signature Graph marked p2 5 1 0 marked marked 1 0 0 p3 p6 4 1 1 1 marked marked 1 p4 p7 1 2 p8 0 1 4 0 0 p5 p1 3 0 marked 1 0 marked
Maintenance of Signature Graph - Insertion of a signature s into G Same as the construction of a signature graph • Deletion of a signature s from G (i) Search G from the root until a node v is encountered, which is marked or skip(v) = 0. (ii) If skip(v) = 0, Compare p(v) and s. If s matches p(v) exactly, do the following; otherwise, nothing will be done. Let v1 ... vk-1 vkv be the path explored. Let u1 be another child of vk (not on the path). Remove vk-1 vk, vk u1 and v; and generate a new edge vk-1 u1. skip(vk) := 0.
Maintenance of Signature Graph • - Deletion of a signature s from G (continued) • (iii) If skip(v) 0, Compare p(v’s father) and s. If s matches p(v’s father) exactly, do the following; otherwise, nothing will be done. • Let v1 ... vk-1 vkv be the path explored. • If vkv, replace p(v) with p(vk). Let u1 be another child of vk (not on the path). Let u2 be another parent of vk (not on the path). Replace vk-1 vk with vk u1, and replace vkv with u2v. Remove vk. Note that u2 can be found by searching G from vk with the target signature being p(vk). • If vk= v, replace vk vk with vk-1 u1. Remove vk.
Maintenance of Signature Graph Illustration for (ii) To be removed vk-1 vk-1 v1 vk v1 vk … … v v u1 u1 u2 u2
Example: p2 5 1 0 1 0 0 p6 p3 4 1 1 1 1 p4 p7 1 2 p8 0 1 0 0 0 p5 p1 3 0 1 0 remove p1 p2 5 1 0 1 0 0 p3 p6 4 1 1 1 1 p7 p5 2 3 p8 1 0 0 0 0 p4 0
Maintenance of Signature Graph Illustration for (iii) To be removed vk-1 vk-1 v1 vk v1 vk … … v v u1 u1 u2 u2
p2 5 1 0 1 0 0 p3 p6 4 1 1 1 p4 p7 1 2 0 1 0 0 p5 p1 3 0 1 Example: p2 5 1 0 1 0 0 p6 p3 4 1 1 1 1 p4 p7 1 2 p8 0 1 4 0 0 p5 p1 3 0 1 0 remove p8
To be removed vk-1 vk-1 v1 v1 v … v … u1 u1 Illustration for (iii)
p2 5 1 0 1 0 0 p6 p3 4 1 1 1 1 p4 p7 1 2 p8 0 1 4 0 0 p5 p1 3 0 1 0 p2 5 1 0 1 0 0 p6 p3 4 1 1 1 p4 1 p8 0 1 4 0 p5 p1 3 0 1 0 Example: remove p7
Summary and Future Work • - Signature and signature file • - Signature graph • Construction of a signature graphSearch of a signature graphMaintenance of a signature graph • Future work: • Apply signature techniques to evaluation of • path-oriented queries in document databases.