1 / 18

Implementing Concurrent R-trees in Java

Implementing Concurrent R-trees in Java. Mehdi Kargar Department of Computer Science and Engineering. R-trees. R-tree is useful for indexing and representing multidimensional objects. An R-tree is a depth balanced tree with a dynamic index structure Leaf nodes point to actual keys

reynoldsr
Download Presentation

Implementing Concurrent R-trees in Java

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. Implementing Concurrent R-trees in Java Mehdi Kargar Department of Computer Science and Engineering

  2. R-trees • R-tree is useful for indexing and representing multidimensional objects. • An R-tree is a depth balanced tree with a dynamic index structure • Leaf nodes point to actual keys • The number of entries in a node is between m and N (1 < m ≤ N) • Root might have between 1 and N entries. • All leaf nodes areat the same level • The key for each internal node is the minimum bounding rectangle of its child nodes • keys at all levels might have overlap with each other

  3. R-trees

  4. R-trees • During the search for a key, it might be necessary to descend multiple sub-trees • Insertion is more complex than search • After inserting a new key, the new bounding rectangle should be propagated up to the tree. • If a node overflows, it should be split. The split should also be propagated up to the tree. • During the Insertion, only one sub-tree is traversed at each level. We should not descend multiple sub-trees.

  5. Three Implementations • The Monitor Solution • The Readers-Writers Solution • Locking Nodes (RLink-Tree)

  6. The Monitor Solution public class MonitorRTree { public synchronized void add(Rectangle rect) { . . . } public synchronized boolean search(Rectangle rect) { . . . } }

  7. The Readers Writers Solution import java.util.concurrent.locks.ReentrantReadWriteLock; public class ReadWriteLockRTree { private ReentrantReadWriteLocklock; . . . . public void add(Rectangle rect) { this.lock.writeLock().lock(); . . this.lock.writeLock().unlock(); } public boolean search(Rectangle rect) { this.lock.readLock().lock(); . . this.lock.readLock().unlock(); } }

  8. RLink-Tree • Basic idea : • Logical Serial Number (LSN) is used to capture unfinished splits. • Right Links is used to follow the split nodes.

  9. RLink-Tree (Locking Problem) • RLink-Tree uses the lock couplingstrategy for inserting new entries. • The normal implementation of lock coupling leads to deadlocks. Write-Lock Read-Lock 2 1 Process 2 After Inserting new entry, the split and new bounding rectangle should be propagated Write-Lockthe nodes in a bottom-up approach x Process 1 Finding the best node for inserting new entries Read-Lock the nodes in a top-down approach 1 2 Y Z

  10. RLink-Tree (Locking Problem) • The previous situation is called phantom problem. • It can be solved by predicate locks. • What are predicate locks ?? • You can find more about it here : • K. Eswaren, J. Gray, R. Lorie and I. Traiger, On the Notions of Consistency and Predicate Locks in a Database System, Comm. ACM, November 1976, Vol. 19, No. 11, pp. 624–633.

  11. What is implemented? • Here, the root node is kept write-lock for the insertion of new nodes. Thus, only one process can insert at any time and we do not have multiple insertions. • The LSN and right links are the same as the original RLink-Tree. • Search algorithm and the read-lock mechanism is also the same as RLink-Tree.

  12. Read Lock and Write Lock of Nodes public synchronized void writeLock() { while (this.readers != 0 || state == WRITE) { try { this.wait(); } catch (InterruptedException e) {} } this.state = WRITE; } public synchronized void writeUnlock() { this.state = READ; this.notifyAll(); } public synchronized void readLock() { while (this.state == WRITE) { try { this.wait(); } catch (InterruptedException e) {} } this.increment(); } public synchronized void readUnlock() { this.decrement(); this.notifyAll(); }

  13. Running time comparison

  14. Running time comparison

  15. Running time comparison

  16. Possible Improvements • Having multiple insertion process without locking the root. • Finding better solution for phantom problem. • . . .

  17. Next Phase • Verifying the implementations using different applications and tools such as Java PathFinder

  18. Thank you for you attention

More Related