MappedRandomAccessSource

A RandomAccessSource backed by a memory-mapped file via JvmMappedMemoryChunk.

Unlike JvmRandomAccessSource (which reads through a FileChannel into heap buffers), this variant lets the OS manage paging. Ideal for immutable model weights that are read repeatedly.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val size: Long

The total size of the source in bytes.

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
open override fun readAt(position: Long, length: Int): ByteArray

Read bytes from the specified position.

open override fun readAt(position: Long, buffer: ByteArray, offset: Int = 0, length: Int = buffer.size): Int

Read bytes into an existing buffer.

Link copied to clipboard
fun sliceChunk(offset: Long, length: Long): MemoryChunk

Return a MemoryChunk slice without copying — useful for loader integration.