co.teapot.mmalloc

MemoryMappedAllocator

Related Docs: object MemoryMappedAllocator | package mmalloc

class MemoryMappedAllocator extends Allocator

Allocates memory backed by an underlying memory-mapped file. If the given file is empty, initializes it. The file grows automatically as allocations are performed.

For tuning performance, the parameter blockSize controls the unit of memory internally allocated. The parameter pieceSizes controls the granularity of allocations. When allocating k bytes, the allocator pads k up to the next element in pieceSizes, or to the next multiple of blockSize if k is larger than the largest element of pieceSizes. The array pieceSizes must be sorted, and the largest piece size must be smaller than blockSize by at least ~32 bytes (the minimum size of a PieceBlock header). If blockSize or pieceSizes are given when a file is first created, the same parameters must be used when MemoryMappedAllocator is constructed with the same file.

This class is thread-safe (multiple threads may call the methods concurrently). (TODO: double-check thread-safety)

Linear Supertypes
Allocator, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. MemoryMappedAllocator
  2. Allocator
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new MemoryMappedAllocator(dataFile: File, pieceSizes: Array[Int] = ..., blockSize: Int = ...)

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. def alloc(size: Long): Long

    Returns a pointer to a piece within data of size at least byteCount bytes.

    Returns a pointer to a piece within data of size at least byteCount bytes.

    Definition Classes
    MemoryMappedAllocatorAllocator
  5. def allocationCapacity(pointer: Long): Long

    Assuming the given pointer was allocated by this allocator, returns the number of bytes in its allocation.

  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. val blockSize: Int

  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. val data: MMapByteBuffer

    All pointers refer to locations within data.

    All pointers refer to locations within data.

    Definition Classes
    MemoryMappedAllocatorAllocator
  10. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. def free(pointer: Long): Unit

    Free the memory pointed

    Free the memory pointed

    Definition Classes
    MemoryMappedAllocatorAllocator
  14. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  15. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  16. val initializeNewAllocator: Boolean

  17. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  18. val log: Logger

  19. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  20. final def notify(): Unit

    Definition Classes
    AnyRef
  21. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  22. val pieceSizes: Array[Int]

  23. def realloc(originalPointer: Long, byteCount: Long): Long

    Returns a pointer to a piece within data of size at least byteCount bytes.

    Returns a pointer to a piece within data of size at least byteCount bytes. Copies all data from the allocation at the given originalPointer to the new pointer. If freeOriginal is true, the allocation at the original pointer is freed.

    Definition Classes
    MemoryMappedAllocatorAllocator
  24. var syncAllWrites: Boolean

    Indicates that all writes should be synced to the underlying disk immediately.

    Indicates that all writes should be synced to the underlying disk immediately. If set to false, write speed will increase, but the allocator may be in an inconsistent state if the process terminates unexpectedly.

  25. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  26. def toString(): String

    Definition Classes
    AnyRef → Any
  27. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Allocator

Inherited from AnyRef

Inherited from Any

Ungrouped