Package herddb.index.blink
Class BLink<K extends Comparable<K>,V>
- java.lang.Object
-
- herddb.index.blink.BLink<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 algorithmThis 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceBLink.SizeEvaluator<X,Y>Support structure to evaluates memory byte size occupancy of keys and values
-
Constructor Summary
Constructors Constructor Description BLink(long maxSize, BLink.SizeEvaluator<K,V> evaluator, PageReplacementPolicy policy, BLinkIndexDataStorage<K,V> storage)BLink(long maxSize, BLink.SizeEvaluator<K,V> evaluator, PageReplacementPolicy policy, BLinkIndexDataStorage<K,V> storage, BLinkMetadata<K> metadata)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BLinkMetadata<K>checkpoint()Executes a complete tree checkpoint.voidclose()Fully close the facilityVdelete(K v)longgetUsedMemory()Returns the actually used memory in bytes (only data currently loaded will be accounted).Vinsert(K v, V e)booleaninsert(K v, V e, V expected)intnodes()Returns the current nodes count.Stream<Map.Entry<K,V>>scan(K from, K to)Supports both from and to empty.Stream<Map.Entry<K,V>>scan(K from, K to, boolean toInclusive)Vsearch(K v)longsize()Returns the number of key/value pairs stored into this tree.StringtoString()StringtoStringFull()Build a full string representation of this tree.voidtruncate()Truncate any tree data.voidunload(long pageId)Unload given page from memory.
-
-
-
Constructor Detail
-
BLink
public BLink(long maxSize, BLink.SizeEvaluator<K,V> evaluator, PageReplacementPolicy policy, BLinkIndexDataStorage<K,V> storage)
-
BLink
public BLink(long maxSize, BLink.SizeEvaluator<K,V> evaluator, PageReplacementPolicy policy, BLinkIndexDataStorage<K,V> storage, BLinkMetadata<K> metadata)
-
-
Method Detail
-
close
public void close()
Fully close the facility- Specified by:
closein interfaceAutoCloseable
-
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.OwnerUnload given page from memory.- Specified by:
unloadin interfacePage.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
-
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:
-
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
-
-