
IndexInput
- Namespace
- Rowles.LeanLucene.Store
- Assembly
- Rowles.LeanLucene.dll
Readable input over a memory-mapped file. Maintains a position cursor and uses System.Runtime.CompilerServices.Unsafe.ReadUnaligned``1(System.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
IndexInput(string)
Opens a file at filePath as a memory-mapped read-only input.
Acquires a native pointer for the lifetime of this instance.

BasePointer
Base pointer for the memory-mapped region. Used for zero-copy reads.
Length
Total file 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.
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 _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 System.IO.BinaryWriter.Write(System.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.
ReadSpan(int)
Returns a read-only span over the memory-mapped buffer at the current position
without allocating. Advances the position by count bytes.
The span is only valid while the IndexInput is not disposed.
ReadSpan(int, 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.

ReadVarIntFast()
Unrolled VarInt decoder with a single per-value bounds check. If at least 5 bytes remain, uses the branchless unrolled path. Otherwise falls back to the safe per-byte checked path. This eliminates up to 4 bounds checks per VarInt value compared to ReadVarInt().

ReadVarIntFast(ref long)
Stateless variant of ReadVarIntFast() using a caller-supplied cursor.
Seek(long)
Moves the read cursor to the specified absolute byte offset.