Skip to content

MmapFastqParser

Mojo struct 🡭

@memory_only
struct MmapFastqParser

Zero-copy FASTQ parser over a memory-mapped file.

Same API surface as FastqParser; parses directly from the page cache with no buffering and no kernel-to-user copies. The parser owns the mapping, so record views stay valid until the next read. Best for plain local files; use FastqParser for gzip/network streams.

Example:

var parser = MmapFastqParser(Path("data.fastq"))
for view in parser.views():
_ = view.sequence()
  • src (MmapSource)
  • quality_schema (QualitySchema)
  • validator (Validator)

AnyType, Deinitable, FastqParserLike, Movable

fn def __init__(out self, path: Path, check_ascii: Bool = False, check_quality: Bool = False, quality_schema_name: String = "generic")

Args:

  • path (Path)
  • check_ascii (Bool)
  • check_quality (Bool)
  • quality_schema_name (String)
  • self (Self)

Returns:

Self

Raises:

fn def has_more(self) -> Bool

Args:

  • self (Self)

Returns:

Bool

fn def next_view(mut self) -> FastqView[MutUntrackedOrigin]

Args:

  • self (Self)

Returns:

FastqView[MutUntrackedOrigin]

Raises:

fn def next_view_memchr_seq(mut self) -> FastqView[MutUntrackedOrigin]

Benchmark-only variant that scans record boundaries via sequential memchr.

Args:

  • self (Self)

Returns:

FastqView[MutUntrackedOrigin]

Raises:

fn def next_view_masks(mut self) -> FastqView[MutUntrackedOrigin]

Benchmark-only variant using the hoisted-mask SIMD scanner.

Args:

  • self (Self)

Returns:

FastqView[MutUntrackedOrigin]

Raises:

fn def next_record(mut self) -> FastqRecord

Args:

  • self (Self)

Returns:

FastqRecord

Raises:

fn def next_record_memchr_seq(mut self) -> FastqRecord

Benchmark-only variant that scans record boundaries via sequential memchr.

Args:

  • self (Self)

Returns:

FastqRecord

Raises:

fn def next_record_masks(mut self) -> FastqRecord

Args:

  • self (Self)

Returns:

FastqRecord

Raises:

fn def next_batch(mut self, max_records: Int = Int(4096)) -> FastqBatch

Args:

  • self (Self)
  • max_records (Int)

Returns:

FastqBatch

Raises:

fn def views(ref self) -> _FastqViewIter[Self, origin_of(self)]

Args:

  • self (Self)

Returns:

_FastqViewIter[Self, origin_of(self)]

fn def records(ref self) -> _FastqRecordIter[Self, origin_of(self)]

Args:

  • self (Self)

Returns:

_FastqRecordIter[Self, origin_of(self)]

fn def batches(ref self, max_records: Optional[Int] = None) -> _FastqBatchIter[Self, origin_of(self)]

Args:

  • self (Self)
  • max_records (Optional[Int])

Returns:

_FastqBatchIter[Self, origin_of(self)]