Class BLink<K extends Comparable<K>,​V>

  • All Implemented Interfaces:
    Page.Owner, AutoCloseable

    public class BLink<K extends Comparable<K>,​V>
    extends Object
    implements AutoCloseable, Page.Owner
    Java implementation of b-link tree derived from Vladimir Lanin and Dennis Shasha work: A symmetric concurrent b-tree algorithm

    This implementations add variable sized nodes, range scans, truncation and a way to store data pages.

    For original work see:

     LANIN, Vladimir; SHASHA, Dennis. A symmetric concurrent b-tree algorithm.
     In: Proceedings of 1986 ACM Fall joint computer conference.
     IEEE Computer Society Press, 1986. p. 380-389
     
    Author:
    diego.salvi
    • Method Detail

      • close

        public void close()
        Fully close the facility
        Specified by:
        close in interface AutoCloseable
      • truncate

        public void truncate()
        Truncate any tree data. Invokers must ensure to call this method in a not concurrent way.
      • size

        public long size()
        Returns the number of key/value pairs stored into this tree.
        Returns:
        current size of the tree
      • getUsedMemory

        public long getUsedMemory()
        Returns the actually used memory in bytes (only data currently loaded will be accounted).
        Returns:
        current memory occupancy of the tree
      • nodes

        public int nodes()
        Returns the current nodes count.
        Returns:
        current tree nodes count
      • unload

        public void unload​(long pageId)
        Description copied from interface: Page.Owner
        Unload given page from memory.
        Specified by:
        unload in interface Page.Owner
        Parameters:
        pageId - id of page to be unloaded
      • checkpoint

        public BLinkMetadata<K> checkpoint()
                                    throws IOException
        Executes a complete tree checkpoint.

        Invoking method must ensure that there isn't any concurrent update, read operations could be executed concurrently with checkpoint.

        Returns:
        tree checkpoint metadata
        Throws:
        IOException
      • search

        public V search​(K v)
      • scan

        public Stream<Map.Entry<K,​V>> scan​(K from,
                                                 K to)
        Supports both from and to empty.
        Parameters:
        from - inclusive (if not empty)
        to - exclusive
        Returns:
      • insert

        public boolean insert​(K v,
                              V e,
                              V expected)
      • insert

        public V insert​(K v,
                        V e)
      • delete

        public V delete​(K v)
      • toStringFull

        public String toStringFull()
        Build a full string representation of this tree.

        Pay attention: it will load/unload nodes potentially polluting the page replacement policy. Use this method just for test and analysis purposes.

        Returns:
        full tree string representation