Skip to content

RapidgzipReader

Mojo struct 🡭

@memory_only
struct RapidgzipReader

Reader for gzip-compressed files (.gz) using parallel rapidgzip decompression.

Implements the Reader trait like FileReader and GZFile. Use for .fastq.gz files with FastqParser when higher throughput from parallel decompression is desired.

Example:

from blazeseq import RapidgzipReader, FastqParser
var r = RapidgzipReader("data.fastq.gz", parallelism=0)
var parser = FastqParser[RapidgzipReader](r^, "illumina_1.8")
for record in parser.records():
_ = record.id()

AnyType, ImplicitlyDestructible, Movable, Reader

def __init__(out self, path: String, parallelism: UInt32 = 0)

Open a gzip file for parallel decompression.

Args:

  • path (String): Path to the .gz file.
  • parallelism (UInt32): Number of worker threads; 0 = auto-detect.
  • self (Self)

Returns:

Self

Raises:

Error: If the file cannot be opened.

def __init__(out self, path: Path, parallelism: UInt32 = 0)

Open a gzip file for parallel decompression.

Args:

  • path (Path): Path to the .gz file.
  • parallelism (UInt32): Number of worker threads; 0 = auto-detect.
  • self (Self)

Returns:

Self

Raises:

Error: If the file cannot be opened.

def read_to_buffer(mut self, mut buf: Span[Byte, MutExternalOrigin], amt: Int, pos: Int) -> UInt64

Read decompressed bytes into buf at offset pos. Returns bytes read (0 at EOF).

Args:

  • self (Self)
  • buf (Span)
  • amt (Int)
  • pos (Int)

Returns:

UInt64

Raises: