• Kirill Smelkov's avatar
    xbufio += SeqReaderAt - buffering wrapper for a io.ReaderAt optimized for sequential access · 3956445e
    Kirill Smelkov authored
    For example in ZODB FileStorage format reader routines are written
    working with io.ReaderAt for the following reasons:
    
    - for loads random-access is required,
    - there can be several concurrent loads in flight simultaneously.
    
    At the same time various database iterations (APIs additional to load)
    use sequential access pattern and can be served by the same record
    reading routines. However with them we cannot use e.g. bufio.Reader
    because it works with plain io.Reader, not io.ReaderAt.
    
    Here comes SeqReaderAt: it adds a buffer, by default 2·4K, on top of
    original io.Reader, automatically detects direction of sequential
    access which can be forward, backward, or interleaved forward-backward
    patterns, and buffers data accordingly to avoid many syscalls e.g. in
    os.File case.
    3956445e
seqbuf_ioat.go 8.18 KB