public class AATreeFileAllocator extends AATreeSet<org.terracotta.offheapstore.disk.storage.Region>
This allocator maintains an augmented AA tree of free regions. Tree nodes are augmented with the size of the maximum and minimum contiguous free region linked beneath them in the tree. Regions being freed are merged with adjacent free regions and the tree structure updated to reflect the resultant region.
Allocations are performed in a very approximate best fit manner. Assuming that there is a large enough free region in the tree, tree navigation decisions proceed as follows:
This allocator will experience bad fragmentation affects when not used with uniformly sized allocations calls. Since the AA Tree is stored in the Java object heap this can lead to excessive heap usage.
AATreeSet.AbstractTreeNode<E extends Comparable<? super E>>, AATreeSet.Node<E extends Comparable<? super E>>| Constructor and Description |
|---|
AATreeFileAllocator(long size)
Create an abstract allocator using the given buffer source and initial
size.
|
AATreeFileAllocator(long size,
DataInput input) |
| Modifier and Type | Method and Description |
|---|---|
long |
allocate(long size) |
long |
capacity() |
org.terracotta.offheapstore.disk.storage.Region |
find(Object o) |
void |
free(long address,
long length) |
long |
occupied() |
org.terracotta.offheapstore.disk.storage.Region |
removeAndReturn(Object o) |
String |
toString() |
add, clear, comparator, first, getRoot, headSet, isEmpty, iterator, last, remove, size, subSet, tailSetequals, hashCode, removeAlladdAll, contains, containsAll, retainAll, toArray, toArrayclone, finalize, getClass, notify, notifyAll, wait, wait, waitspliteratoraddAll, contains, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArrayparallelStream, removeIf, streampublic AATreeFileAllocator(long size)
This initial size will be used to size the buffer returned from the clear call.
size - initial buffer sizepublic AATreeFileAllocator(long size,
DataInput input)
throws IOException
IOExceptionpublic long allocate(long size)
public void free(long address,
long length)
public org.terracotta.offheapstore.disk.storage.Region removeAndReturn(Object o)
removeAndReturn in class AATreeSet<org.terracotta.offheapstore.disk.storage.Region>public org.terracotta.offheapstore.disk.storage.Region find(Object o)
public long occupied()
public long capacity()
public String toString()
toString in class AbstractCollection<org.terracotta.offheapstore.disk.storage.Region>Copyright © 2015–2024. All rights reserved.