package granary

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Granary_unix.Unix_fileSource

Unix-file BLOCK backend (pread/pwrite over a Unix fd).

Unix file-backed BLOCK implementation. Opens or creates a file. Takes an OS-level flock(LOCK_EX) on open to prevent concurrent access from two processes.

Sourcetype t
Sourcetype error =
  1. | Io of string
  2. | Out_of_bounds of {
    1. page_id : int64;
    2. n_pages : int64;
    }
Sourceval pp : Format.formatter -> t -> unit

Pretty-print the file's page count.

Sourceval pp_error : Format.formatter -> error -> unit

Pretty-print an error.

Sourceval page_size : t -> int

This file's page size in bytes (#95).

Sourceval set_page_size : t -> int -> unit

set_page_size t ps adopts page size ps for addressing and recomputes the logical page count from the file's byte size (#95). Called by the open path after peeking the header's geometry on an existing file.

Sourceval open_ : ?page_size:int -> path:string -> unit -> (t, error) result Lwt.t

open_ ?page_size ~path () opens (or creates) the file and takes an exclusive flock. page_size (default 4096, #95) sets the addressing granularity; for an existing file of a different geometry, open at the default then set_page_size after peeking the header.

Sourceval close : t -> (unit, error) result Lwt.t

Release the lock and close the underlying file descriptor.

Sourceval n_pages : t -> int64

Current size of the file, in pages.

Sourceval read_page : t -> page_id:int64 -> Cstruct.t -> (unit, error) result Lwt.t

read_page t ~page_id buf reads page page_id into buf.

Sourceval write_page : t -> page_id:int64 -> Cstruct.t -> (unit, error) result Lwt.t

write_page t ~page_id buf writes buf to page page_id.

Sourceval sync : t -> (unit, error) result Lwt.t

fsync the underlying file, durably persisting prior writes.

Sourceval resize : t -> n_pages:int64 -> (unit, error) result Lwt.t

resize t ~n_pages grows or shrinks the file to n_pages pages.