Concurrent Search Structure Algorithms Dennis Shasha.

Slides:



Advertisements
Similar presentations
Chapter 13. Red-Black Trees
Advertisements

COSC2007 Data Structures II Chapter 10 Trees I. 2 Topics Terminology.
Trees Types and Operations
Advanced Database Discussion B Trees. Motivation for B-Trees So far we have assumed that we can store an entire data structure in main memory What if.
B+-Trees (PART 1) What is a B+ tree? Why B+ trees? Searching a B+ tree
296.3: Algorithms in the Real World
CSE332: Data Abstractions Lecture 4: Priority Queues Dan Grossman Spring 2010.
CSE332: Data Abstractions Lecture 9: B Trees Dan Grossman Spring 2010.
Binary Search Trees Briana B. Morrison Adapted from Alan Eugenio.
Data Structures: Trees i206 Fall 2010 John Chuang Some slides adapted from Marti Hearst, Brian Hayes, or Glenn Brookshear.
Data Structures and Algorithms1 B-Trees with Minimum=1 2-3 Trees.
1 Trees. 2 Outline –Tree Structures –Tree Node Level and Path Length –Binary Tree Definition –Binary Tree Nodes –Binary Search Trees.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
Data Structures Data Structures Topic #8. Today’s Agenda Continue Discussing Table Abstractions But, this time, let’s talk about them in terms of new.
Lec 15 April 9 Topics: l binary Trees l expression trees Binary Search Trees (Chapter 5 of text)
B + -Trees (Part 1) Lecture 20 COMP171 Fall 2006.
Chapter 4: Transaction Management
B + -Trees (Part 1). Motivation AVL tree with N nodes is an excellent data structure for searching, indexing, etc. –The Big-Oh analysis shows most operations.
B + -Trees (Part 1) COMP171. Slide 2 Main and secondary memories  Secondary storage device is much, much slower than the main RAM  Pages and blocks.
Designing Concurrent Search Structure Algorithms Dennis Shasha.
Data Structures Using C++ 2E Chapter 11 Binary Trees and B-Trees.
B + -Trees COMP171 Fall AVL Trees / Slide 2 Dictionary for Secondary storage * The AVL tree is an excellent dictionary structure when the entire.
AVL Trees / Slide 1 Deletion  To delete a key target, we find it at a leaf x, and remove it. * Two situations to worry about: (1) target is a key in some.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Tree-Structured Indexes Chapter 9.
Tree-Structured Indexes. Range Searches ``Find all students with gpa > 3.0’’ –If data is in sorted file, do binary search to find first such student,
Binary Trees Chapter 6.
0 Course Outline n Introduction and Algorithm Analysis (Ch. 2) n Hash Tables: dictionary data structure (Ch. 5) n Heaps: priority queue data structures.
Data Structures Using C++1 Chapter 11 Binary Trees.
CS 61B Data Structures and Programming Methodology Aug 11, 2008 David Sun.
CPSC 335 BTrees Dr. Marina Gavrilova Computer Science University of Calgary Canada.
B+ Tree What is a B+ Tree Searching Insertion Deletion.
Trees Chapter 8. 2 Tree Terminology A tree consists of a collection of elements or nodes, organized hierarchically. The node at the top of a tree is called.
CHAPTER 71 TREE. Binary Tree A binary tree T is a finite set of one or more nodes such that: (a) T is empty or (b) There is a specially designated node.
COSC2007 Data Structures II
Chapter Tow Search Trees BY HUSSEIN SALIM QASIM WESAM HRBI FADHEEL CS 6310 ADVANCE DATA STRUCTURE AND ALGORITHM DR. ELISE DE DONCKER 1.
B+ Trees COMP
Tree.
1 B Trees - Motivation Recall our discussion on AVL-trees –The maximum height of an AVL-tree with n-nodes is log 2 (n) since the branching factor (degree,
Chapter 19: Binary Trees. Objectives In this chapter, you will: – Learn about binary trees – Explore various binary tree traversal algorithms – Organize.
Chapter 6 Binary Trees. 6.1 Trees, Binary Trees, and Binary Search Trees Linked lists usually are more flexible than arrays, but it is difficult to use.
Chapter 13 B Advanced Implementations of Tables – Balanced BSTs.
B-Trees And B+-Trees Jay Yim CS 157B Dr. Lee.
Balanced Search Trees Fundamental Data Structures and Algorithms Margaret Reid-Miller 3 February 2005.
Data Structures Balanced Trees 1CSCI Outline  Balanced Search Trees 2-3 Trees Trees Red-Black Trees 2CSCI 3110.
2IL50 Data Structures Fall 2015 Lecture 7: Binary Search Trees.
1 Chapter 10 Trees. 2 Definition of Tree A tree is a set of linked nodes, such that there is one and only one path from a unique node (called the root.
B + -Trees. Motivation An AVL tree with N nodes is an excellent data structure for searching, indexing, etc. The Big-Oh analysis shows that most operations.
CMSC 341 B- Trees D. Frey with apologies to Tom Anastasio.
Trees Chapter 8. 2 Tree Terminology A tree consists of a collection of elements or nodes, organized hierarchically. The node at the top of a tree is called.
Starting at Binary Trees
CSE373: Data Structures & Algorithms Lecture 6: Priority Queues Dan Grossman Fall 2013.
CS 61B Data Structures and Programming Methodology Aug 7, 2008 David Sun.
Chapter 7 Trees_Part3 1 SEARCH TREE. Search Trees 2  Two standard search trees:  Binary Search Trees (non-balanced) All items in left sub-tree are less.
3.1. Binary Search Trees   . Ordered Dictionaries Keys are assumed to come from a total order. Old operations: insert, delete, find, …
Chapter 4: Trees Part I: General Tree Concepts Mark Allen Weiss: Data Structures and Algorithm Analysis in Java.
CSE373: Data Structures & Algorithms Lecture 6: Priority Queues Kevin Quinn Fall 2015.
Binary Tree. Some Terminologies Short review on binary tree Tree traversals Binary Search Tree (BST)‏ Questions.
(2,4) Trees1 What are they? –They are search Trees (but not binary search trees) –They are also known as 2-4, trees.
1 More Trees Trees, Red-Black Trees, B Trees.
Binary Search Trees1 Chapter 3, Sections 1 and 2: Binary Search Trees AVL Trees   
8/3/2007CMSC 341 BTrees1 CMSC 341 B- Trees D. Frey with apologies to Tom Anastasio.
CSE332: Data Abstractions Lecture 4: Priority Queues Dan Grossman Spring 2012.
CSE373: Data Structures & Algorithms Priority Queues
Section 8.1 Trees.
Designing Concurrent Search Structure Algorithms
(edited by Nadia Al-Ghreimil)
CSE332: Data Abstractions Lecture 4: Priority Queues
B- Trees D. Frey with apologies to Tom Anastasio
CMSC 202 Trees.
Chapter 20: Binary Trees.
Presentation transcript:

Concurrent Search Structure Algorithms Dennis Shasha

What is a Search Structure? Data structure (typically a B tree, hash structure, R-tree, etc.) that supports a dictionary. Operations are insert key-value pair, delete key-value pair, and search for a key-value pair.

How to make a search structure algorithm concurrent? Naïve approach: use two phase locking (but then the root is at least read-locked so conflicts occur) Semi-naïve: use hierarchical tree locking: lock root; afterwards lock node n (Still tends to hold locks high in tree.)

How can we do better? Fundamental insight: In a search structure algorithm, all that we really care about is that we implement the dictionary operations correctly. Operations on structure need not even be serializable provided they maintain certain constraints.

Train your intuition: parable of the library Bob goes to a library (with books) and looks in the catalogue for a great puzzle book P. He is told it is on stack G. He walks towards G but sees a friend and they have a chat. Alice the librarian moves some books from G to H and leaves a note. She then changes the catalogue. Bob goes to G, sees the note, and finds P on stack H.

Observe: In no serial execution would Bob visit two stacks – if he had gone after Alice, he would have visited only H; if before, only G. But this is still ok. Why? Intuition: the search is always pointed towards a correct final position.

Using this for search structures KeySpace = the set of all possible keys (e.g. all possible integers) Inset of a node n = subset of KeySpace that is either in n, a node reachable from n or nowhere in the data structure. Outset of n towards n’ = The subset of KeySpace associated with the edge from n to n’. Depends on the data structure. Keyset of n = inset(n) – U outset(n,n’)

Binary search tree Root node is 20 Left child is 5 And maybe the left child has descendants. What is the inset of the left child? All values less than 20. Right child of 5 has value 13. What is the outset(5,13) and what is the inset(13)

Example Suppose the root of a binary search tree has the value 20 and a left child L and right child R. Inset(root) = KeySpace Outset(root,L) = {x| x < 20} Outset(root, R) = {x| x > 20} Keyset(root) = {20}

Let’s Return to the Library Suppose that, to start, the shelf G has as its inset all books with last name starting with “S”. Alice moves those between “S” and “Si” to shelf H and leaves a note to that effect. Then the keyset of G becomes {x | x begins with “S”} – {x|x <= “Si”} The keyset of G represents the set of books that are in G or nowhere in the structure.

The Key Invariants If x is in node n, then x is in keyset(n) The keysets partition the KeySpace. If the search for an item x is at node n, then x is in keyset(n) or there is a path from n to node m such that x is in keyset(m) and every edge along the path has x in its outset. The invariants assure that the search, if it terminates, will terminate in the correct place.

Application: link algorithm Recall splits in B trees. Split n into n and n’ and adjust the parent p to reflect the change. Here is how to do a split: lock(n), move the values from n to n’ as desired and leave a forward pointer to that effect, unlock(n), lock(p), and adjust p, then unlock(p). This is exactly the library scenario.

Application: give-up algorithm Instead of including a forwarding pointer, just asset explicitly the inset of each node. When splitting, reduce the asserted inset(n), denoted assertinset(n) and establish assertinset(n’). If a search for x arrives at n and x is not in assertinset(n), the search starts over. Happens rarely enough that performance is very good.

Application: multi-rooted structure Imagine a link B-tree structure with a root at the top of the tree and a root to the left of the leftmost leaf node. Same invariants hold and search can proceed from anywhere.

Conclusion Simple framework for all search structures. Handful of concepts: KeySpace, inset, outset, keyset. Performs well.