1 / 32

Labeling and Querying Dynamic XML Trees

Labeling and Querying Dynamic XML Trees. Jiaheng Lu and Tok Wang Ling School of Computing National University of Singapore. Contents. Introduction Introduction to structural join Introduction to labeling scheme Our Method s Preliminary definition

pahana
Download Presentation

Labeling and Querying Dynamic XML Trees

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Labeling and Querying Dynamic XML Trees Jiaheng Lu and Tok Wang Ling School of Computing National University of Singapore

  2. Contents • Introduction • Introduction to structural join • Introduction to labeling scheme • Our Methods • Preliminary definition • Group based prefix labeling scheme • Group based join algorithm • Our Experiments

  3. Introduction to Structural Join • XML employs tree-structured model for representing data • XML query can be decomposed into a set of basic structural ( parent-child or ancestor-descendant ) relationships between pairs of nodes

  4. book <book title=“XML”> <allauthors> <author>John</author> <author>Tom</author> </allauthors> <year>2003</year> <chapter> <head>….</head> <section>…</section> </chapter> </book> title allauthors year chapter XML author author 2003 head section John Tom …. …. b) XML tree parent-child a) XML source Any node in XML tree may be an element, attribute, valueof XML source. book ancestor-descendant book Title book Author Title author Author John XML John Title XML c) Xpath Tree Pattern d) Basic Structural relationship

  5. Contents • Introduction • Introduction to structural join • Introduction to labeling scheme • Our Method • Preliminary definition • Group based prefix labeling scheme • Group based join algorithm • Our Experiments

  6. Labeling scheme • In order to perform structural join, each node in an XML tree is assigned an unique label. • We can determine the ancestor-descendant (or parent-child) relationship for any two nodes from their labels. • The method of assigning the labels is called as labeling scheme.

  7. Range labeling scheme • In the range labeling scheme, the label of a node v is interpreted as a pair of numbers <av, bv>: av is called as the start position, while bv is the end position. A node v (<av, bv> ) is an ancestor of u (<au, bu> ) iff av≤au≤bu≤ bv. In other words, range <au, bu> is contained in range <av, bv>.

  8. Range labeling scheme Book <1,12> Allauthors <3,6> Year <7,8> Title <1,2> Chapter <9,11> Author <3,4> Author <5,6> 2003 <7,7> Head <9,9> Section <10,10> XML <1,1> John <3,3> Tom <5,5>

  9. Range labeling scheme • Pros: Ancestor-descendants relationship can be decided in constant time. • Cons: This method lacks of flexibility. There is a renumbering problem for insertion nodes. To get around this problem, some papers propose to leave some “gaps” between the numbers of the leaves. However, if one part of the documents is heavily updated, the available numbers may be still not enough and the tree needs to be renumbered. So this approach cannot ultimately solve this problem.

  10. Prefix labeling scheme • Edith Cohen in PODS 2002 proposes a simple prefix labeling scheme, which can avoid renumbering in any case. • For any new node v, the label L(v) = L(u) + 1…10 • where u is the parent of v, i is the number of labeled children of u. Root node is labeled as an empty string. • (1) Edith Cohen, Haim Kaplan, Tova Milo Labeling Dynamic XML Trees ACM PODS 2002.

  11. How to generate simple prefix label • L(v)=L(u) + 1…10 • u is the parent of v and i is the number of labeled children of u. Book “” “10” “0” Title Authors Author Author Author “100” “1010” “10110”

  12. Simple Prefix labeling scheme • Pros: Compared other labeling scheme, such as range labeling scheme, simple prefix scheme does not need renumbering for any insertion sequence. • Cons: The index size is too large. The tight bound of size is O(N2) in the worst case, where N is the number of nodes in an XML tree.

  13. Contents • Introduction • Introduction to structural join • Introduction to labeling scheme • Our Method • Preliminary definition • Group based prefix labeling scheme • Group based join algorithm • Our Experiments

  14. Group • Definition: Given a XML tree T, a group is a set of subtrees. All root nodes of subtrees in this set have the common parent node in T. A F B H G C D I J One Subtree Two subtrees E Group

  15. Group • Property 1: Given a XML tree T and a group S, for any node n∈T, but n S, one of the following two conditions must be satisfied: (1) n is an ancestor of all nodes in S; (2) n is not an ancestor of any node in S. • In other words, it is impossible that n is an ancestor of part of nodes in S.

  16. Contents • Introduction • Introduction to structural join • Introduction to labeling scheme • Our Method • Preliminary definition • Group based prefix labeling scheme • Group based join algorithm • Our Experiments

  17. GRP Labeling Scheme • Group based Prefix (GRP) labeling scheme associates each node n in the XML tree with a pair of number <groupID, prefix-label>, where groupID is a nonegtive integer and prefix-label is a binary string. All nodes on the same group have the same groupID, and are distinguished by their prefix-label .

  18. GRP label example: 1,“0” Root 1,“010” A B 1,“00” E C D 2,“0” 2,“10” 2,“110” In this example, the maximal number of each group is three.

  19. Contents • Introduction • Introduction to structural join • Introduction to labeling scheme • Our Method • Preliminary definition • Group based prefix labeling scheme • Group based join algorithm • Our Experiments

  20. Group based Structural Join (GRJ) Algorithm • The main idea in GRJ is to divide the join operations into two classes, one is intra-group join, and the other is inter-group join. • Intra-group join means the join happens among the elements in the same group. • Inter-group join means the join happens among the elements in different groups.

  21. Intra-group Join • Intra-group join is easy to understand. There are two alternative methods to perform this join: • (i) simply comparing the prefix labels of any two elements to identify their relationship, like nested-loop join in RDBMS. • (ii) A clever method is first to sort the prefix-label, then use a stack to cache the potential ancestor and only scan the join data once, like sort-merge join in RDBMS.

  22. Inter-group Join algorithm • The key point of inter-group join is to use a hash table to cache the ancestor nodes of each group. • A key of hash table is a group ID of the descendant set and a value of hash table is the parent element of this group.

  23. Algorithm. GRJ algorithm • Input:A is the ancestor list and D is the descendant list • Output: Pairs of ancestor-descendant elements • 1.Scan A,D list once to assign every element to their respective group bucket; • 2. Initialize DgroupHash as a hash table, where keys are group IDs of Dlist, and each value is initialized as an empty set. • /* DgroupHash will cache the ancestors of any group in Dlist. */ • 3. Fori:=2 to max group do • /*since group 1 only contains root node, here begin from group 2 * • Output each elements in set DgroupHash(i) as the ancestor of each element in Dlist of group i ; • Delete key i from DgroupHash; • 6. Perform Intra-group join for group i; • 7. Perform Inter-group join for group i (join result is stored in the hash table DgroupHash). • 8. End For

  24. Contents • Introduction • Introduction to structural join • Introduction to labeling scheme • Our Method • Preliminary definition • Group based prefix labeling scheme • Group based join algorithm • Our Experiments

  25. Experiment setup • Comprehensive experiments were conducted to study the effectiveness and efficiency of GRJ algorithm. • We use synthetic and real-life data including XMARK, IBM XML generator and DBLP.

  26. Query performance • For GRP scheme, we use GRJ algorithm. • For SP scheme, we first use block nested loop (BNL) algorithm. Because if the label of node is given directly according to their inserted order, they are usually unsorted, we cannot use more efficient algorithm. • Experiment result: GRJ is much efficient than BNL.

  27. Query Performance • When the special efforts are taken to guarantee that element lists are sorted, for SP labeling scheme, we may use a more efficient algorithm, called Stack-Tree-Desc(2) to perform structural join. Stack-Tree-Desc is like sort-merge join in RDBMS. • Since the original Stack-Tree-Desc algorithm is based on range labeling scheme, here we first modify it to utilize SP labeling scheme (but the main idea is the same). • (2):D. Srivastava, S.Al-khalifa, H. V. Jagadish, N. Koudas, J. M. Patel and Yuqing Wu. Structural Joins: A primitive for efficient XML query pattern matching. In ICDE 2002

  28. Query Performance • Interestingly, we find that although GRJ algorithm needs to scan the element lists twice and Stack-Tree-Desc algorithm scan them only once, GRJ algorithm still performs better than Stack-Tree-Desc algorithm for the large data.

  29. Query Performance • This can be explained as follows: Stack-Tree-Desc algorithm is based on SP labeling scheme, while GRJ is based on GRP scheme. Since the size of labels of SP is much larger than that of GRP, the time of accessing the GRP labels twice may be still smaller than accessing SP labels once. As a result, GRJ algorithm outperforms Stack-Tree-Desc algorithm. • This result shows the importance of the size of labels.

  30. ------ End------- • Thank you ! • Question and Answer

More Related