Class PowerOfTwoFileAllocator
java.lang.Object
org.terracotta.offheapstore.disk.paging.PowerOfTwoFileAllocator
An augmented AA tree allocator with unusual alignment/allocation properties.
This allocator allocates only power-of-two size chunks. In addition these chunks are then only allocated on alignment with their own size. Hence a chunk of 2n size can only be allocated to an address satisfying a=2nx where x is a long.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classClass that represents the regions held within this set. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final booleanprivate PowerOfTwoFileAllocator.Regionprivate PowerOfTwoFileAllocator.Regionprivate PowerOfTwoFileAllocator.Regionprivate static final PowerOfTwoFileAllocator.Regionprivate longprivate PowerOfTwoFileAllocator.Regionprivate static final boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallocate(long size) private voidprivate PowerOfTwoFileAllocator.Regionfind(long size) Find a region of the given size.private PowerOfTwoFileAllocator.RegionFind an item in the tree.voidfree(long address, long length) private voidprivate voidprivate voidInsert into the tree.private PowerOfTwoFileAllocator.RegionInternal method to insert into a subtree.voidmark(long address, long length) private voidlongoccupied()private PowerOfTwoFileAllocator.RegionRemove from the tree.private PowerOfTwoFileAllocator.RegionInternal method to remove from a subtree.private static PowerOfTwoFileAllocator.RegionRotate binary tree node with left child.private static PowerOfTwoFileAllocator.RegionRotate binary tree node with right child.private static PowerOfTwoFileAllocator.RegionSkew primitive for AA-trees.private static PowerOfTwoFileAllocator.RegionSplit primitive for AA-trees.toString()
-
Field Details
-
DEBUG
private static final boolean DEBUG -
VALIDATING
private static final boolean VALIDATING -
NULL_NODE
-
root
-
deletedNode
-
lastNode
-
deletedElement
-
occupied
private long occupied
-
-
Constructor Details
-
PowerOfTwoFileAllocator
public PowerOfTwoFileAllocator() -
PowerOfTwoFileAllocator
public PowerOfTwoFileAllocator(long size)
-
-
Method Details
-
allocate
-
free
public void free(long address, long length) -
mark
public void mark(long address, long length) -
occupied
public long occupied() -
allocated
-
freed
-
mark
-
free
-
insert
Insert into the tree.- Parameters:
x- the item to insert.
-
remove
Remove from the tree.- Parameters:
x- the item to remove.
-
find
Find a region of the given size. -
find
Find an item in the tree.- Parameters:
x- the item to search for.- Returns:
- the matching item of null if not found.
-
insert
private PowerOfTwoFileAllocator.Region insert(PowerOfTwoFileAllocator.Region x, PowerOfTwoFileAllocator.Region t) Internal method to insert into a subtree.- Parameters:
x- the item to insert.t- the node that roots the tree.- Returns:
- the new root. if x is already present.
-
remove
private PowerOfTwoFileAllocator.Region remove(PowerOfTwoFileAllocator.Region x, PowerOfTwoFileAllocator.Region t) Internal method to remove from a subtree.- Parameters:
x- the item to remove.t- the node that roots the tree.- Returns:
- the new root.
-
skew
Skew primitive for AA-trees.- Parameters:
t- the node that roots the tree.- Returns:
- the new root after the rotation.
-
split
Split primitive for AA-trees.- Parameters:
t- the node that roots the tree.- Returns:
- the new root after the rotation.
-
rotateWithLeftChild
private static PowerOfTwoFileAllocator.Region rotateWithLeftChild(PowerOfTwoFileAllocator.Region k2) Rotate binary tree node with left child. -
rotateWithRightChild
private static PowerOfTwoFileAllocator.Region rotateWithRightChild(PowerOfTwoFileAllocator.Region k1) Rotate binary tree node with right child. -
toString
-