mmap

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package mmap provides memory-mapped file I/O for zero-copy high-performance reading

Index

Constants

View Source
const (
	// Memory protection flags
	PROT_READ = syscall.PROT_READ

	// Memory mapping flags
	MAP_SHARED = syscall.MAP_SHARED

	// Memory advice flags
	MADV_SEQUENTIAL = syscall.MADV_SEQUENTIAL
	MADV_WILLNEED   = syscall.MADV_WILLNEED
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LineReader

type LineReader struct {
	// contains filtered or unexported fields
}

LineReader provides line-oriented reading over memory-mapped data

func NewLineReader

func NewLineReader(filename string, batchSize int) (*LineReader, error)

NewLineReader creates a new line reader over memory-mapped file

func (*LineReader) Close

func (lr *LineReader) Close() error

Close closes the line reader

func (*LineReader) ReadBatch

func (lr *LineReader) ReadBatch() ([][]byte, error)

ReadBatch reads a batch of lines

type ParallelCSVReader

type ParallelCSVReader struct {
	// contains filtered or unexported fields
}

ParallelCSVReader reads CSV files using memory mapping and parallel processing

func NewParallelCSVReader

func NewParallelCSVReader(filename string, delimiter byte, numWorkers int) (*ParallelCSVReader, error)

NewParallelCSVReader creates a new parallel CSV reader

func (*ParallelCSVReader) Close

func (pcr *ParallelCSVReader) Close() error

Close closes the parallel CSV reader

func (*ParallelCSVReader) GetReader

func (pcr *ParallelCSVReader) GetReader() *LineReader

GetReader returns the underlying LineReader

func (*ParallelCSVReader) ReadAll

func (pcr *ParallelCSVReader) ReadAll() ([][]string, error)

ReadAll reads all CSV records in parallel

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader provides memory-mapped file reading with zero-copy performance

func NewReader

func NewReader(filename string) (*Reader, error)

NewReader creates a new memory-mapped file reader

func (*Reader) Close

func (r *Reader) Close() error

Close unmaps the file and closes it

func (*Reader) ProcessParallel

func (r *Reader) ProcessParallel(processor func(chunk []byte, offset int64) error) error

ProcessParallel processes the file in parallel chunks

func (*Reader) ReadAll

func (r *Reader) ReadAll() []byte

ReadAll returns the entire memory-mapped file data

func (*Reader) ReadRange

func (r *Reader) ReadRange(offset, length int64) ([]byte, error)

ReadRange reads a specific range from the memory-mapped file

func (*Reader) Stats

func (r *Reader) Stats() (bytesRead, pagesRead int64)

Stats returns reading statistics

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL