RandomAccessSource
A source that supports random access reads at arbitrary positions.
Unlike kotlinx-io Source which is sequential, this allows reading at any position without loading the entire file into memory.
This is critical for parsing large model files (100+ GB) where only metadata needs to be read initially, with tensor data loaded lazily.
Implementations should be thread-safe for concurrent reads from different positions.
Usage:
RandomAccessSource.open(filePath).use { source ->
val header = source.readAt(0, 24) // Read first 24 bytes
val tensorData = source.readAt(dataOffset, tensorSize) // Read specific tensor
}Content copied to clipboard