org.terracotta.offheapstore.disk.storage
Class AATreeFileAllocator
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<T>
org.terracotta.offheapstore.util.AATreeSet<org.terracotta.offheapstore.disk.storage.Region>
org.terracotta.offheapstore.disk.storage.AATreeFileAllocator
- All Implemented Interfaces:
- Iterable<org.terracotta.offheapstore.disk.storage.Region>, Collection<org.terracotta.offheapstore.disk.storage.Region>, Set<org.terracotta.offheapstore.disk.storage.Region>, SortedSet<org.terracotta.offheapstore.disk.storage.Region>
public class AATreeFileAllocator
- extends AATreeSet<org.terracotta.offheapstore.disk.storage.Region>
An augmented AA tree based allocator.
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:
- if the requested size is smaller than or equal to the smallest contiguous
region then find the smallest contiguous region and use it
- if the current node is perfectly sized then use it
- pick the child with the smallest contiguous subnode that will hold us - and then go to 2
- if no such child exists use the current node
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.
- Author:
- Chris Dennis
| Methods inherited from class org.terracotta.offheapstore.util.AATreeSet |
add, clear, comparator, first, getRoot, headSet, isEmpty, iterator, last, remove, size, subSet, tailSet |
AATreeFileAllocator
public AATreeFileAllocator(long size)
- Create an abstract allocator using the given buffer source and initial
size.
This initial size will be used to size the buffer returned from the clear
call.
- Parameters:
size - initial buffer size
AATreeFileAllocator
public AATreeFileAllocator(long size,
DataInput input)
throws IOException
- Throws:
IOException
allocate
public long allocate(long size)
free
public void free(long address,
long length)
removeAndReturn
public org.terracotta.offheapstore.disk.storage.Region removeAndReturn(Object o)
- Overrides:
removeAndReturn in class AATreeSet<org.terracotta.offheapstore.disk.storage.Region>
find
public org.terracotta.offheapstore.disk.storage.Region find(Object o)
- Overrides:
find in class AATreeSet<org.terracotta.offheapstore.disk.storage.Region>
occupied
public long occupied()
capacity
public long capacity()
toString
public String toString()
-
- Overrides:
toString in class AbstractCollection<org.terracotta.offheapstore.disk.storage.Region>
Copyright © 2015. All Rights Reserved.