
IndexInput
- Namespace
- Rowles.LeanCorpus.Store
- Assembly
- Rowles.LeanCorpus.dll
Readable input over a memory-mapped file. Maintains a position cursor and uses ReadUnaligned<T>(scoped ref readonly byte) for primitive reads. Acquired pointer is held for the lifetime of the accessor to avoid repeated acquire/release overhead.
public sealed class IndexInput : IDisposable
- Inheritance
-
IndexInput
- Implements
IndexInput(string)
Opens a file at filePath as a memory-mapped read-only input.
Acquires a native pointer for the lifetime of this instance.
Length
Total input length in bytes.
Position
Current read position within the file.
CompareCharsAndAdvance(int, ReadOnlySpan<char>)
Compares charCount UTF-8-encoded chars at the current position
against term using ordinal comparison. Advances position past the bytes.
Zero-allocation (stackalloc for decode buffer).
CompareUtf8BytesAndAdvance(int, ReadOnlySpan<byte>)
Compares charCount UTF-8-encoded chars at the current position
against termUtf8 raw UTF-8 bytes. Advances position past the bytes.
Zero-allocation, no char decoding needed.
Dispose()
Releases the memory-mapped file view and underlying file resources.
~IndexInput()
Finaliser that releases the native memory-mapped view pointer if Dispose() was not called. This is a safety net; callers should always dispose explicitly.
Prefetch()
Hints the OS to prefetch the mapped region for sequential access. Uses PrefetchVirtualMemory on Windows and madvise(MADV_SEQUENTIAL) on Linux. Failures are silently ignored (advisory only).
ReadBoolean()
Reads the next byte and returns true if it is non-zero.
ReadBoolean(ref long)
Reads the next byte using a caller-supplied cursor and returns true if it is non-zero.
ReadByte()
Reads and returns the next byte, advancing the position by one.
ReadByte(ref long)
Reads and returns the next byte using a caller-supplied cursor, leaving Rowles.LeanCorpus.Store.IndexInput._position untouched.
ReadBytes(int)
Reads exactly count bytes and returns them as a new array.
ReadDouble()
Reads a 64-bit double-precision floating-point value.
ReadInt32()
Reads a 32-bit signed integer written in little-endian byte order.
ReadInt32(ref long)
Stateless variant of ReadInt32() using a caller-supplied cursor.
ReadInt32Array(Span<int>, int)
Bulk-reads count int32 values into the destination span.
Single bounds check for the entire block. Much faster than N × ReadInt32().
ReadInt32Array(Span<int>, int, ref long)
Stateless variant of ReadInt32Array(Span<int>, int) using a caller-supplied cursor.
ReadInt64()
Reads a 64-bit signed integer written in little-endian byte order.
ReadInt64(ref long)
Stateless variant of ReadInt64() using a caller-supplied cursor.
ReadLengthPrefixedString()
Reads a length-prefixed UTF-8 string as written by Write(string). The length prefix uses 7-bit encoded integer format.
ReadLengthPrefixedString(ref long)
Stateless variant of ReadLengthPrefixedString() using a caller-supplied cursor.
ReadSingle()
Reads a 32-bit single-precision floating-point value.
ReadSingle(ref long)
Stateless variant of ReadSingle() using a caller-supplied cursor.
ReadSingleArray(Span<float>, int, ref long)
Bulk-reads single-precision values using a caller-supplied cursor.
ReadSpan(int)
Returns a stable read-only span containing bytes from the current position.
Advances the position by count bytes. The returned data
remains valid after this input is disposed.
ReadSpan(int, scoped ref long)
Stateless variant of ReadSpan(int) using a caller-supplied cursor.
ReadUtf8String(int)
Reads charCount chars encoded as UTF-8 (as written by BinaryWriter.Write(char[])).
Returns a newly allocated string. Used for one-time skip index loading.
ReadVarInt()
Reads a variable-length encoded non-negative integer (LEB128). Small values (0–127) consume a single byte.
ReadVarInt(ref long)
Stateless variant of ReadVarInt() using a caller-supplied cursor.
Seek(long)
Moves the read cursor to the specified absolute byte offset.