org.terracotta.offheapstore.disk.paging
Class PowerOfTwoFileAllocator

java.lang.Object
  extended by org.terracotta.offheapstore.disk.paging.PowerOfTwoFileAllocator

public class PowerOfTwoFileAllocator
extends Object

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.

Author:
Chris Dennis

Constructor Summary
PowerOfTwoFileAllocator()
          Create a power-of-two allocator using the given buffer source and initial size.
PowerOfTwoFileAllocator(long size)
           
 
Method Summary
 Long allocate(long size)
           
 void free(long address, long length)
           
 void mark(long address, long length)
           
 long occupied()
           
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PowerOfTwoFileAllocator

public PowerOfTwoFileAllocator()
Create a power-of-two 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:
source - source of ByteBuffer instances
initialSize - initial buffer size

PowerOfTwoFileAllocator

public PowerOfTwoFileAllocator(long size)
Method Detail

allocate

public Long allocate(long size)

free

public void free(long address,
                 long length)

mark

public void mark(long address,
                 long length)

occupied

public long occupied()

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2015. All Rights Reserved.