package granary

  1. Overview
  2. Docs
Pure-OCaml SQL engine

Install

dune-project
 Dependency

Authors

Maintainers

Sources

0.0.3.tar.gz
sha256=8b18780ea373be48301d9f333925860a2f9110fc0ac28684295118d72b65a67e
sha512=25ca3c9c5e2b528704a542502e0f37dc33ba003f65622d969b8c2b800778585f8ef0cf89b36e6679832e3993e8303aecddfc662742baf7044d6afe4a796b8f11

doc/granary.unix/Granary_unix/Unix_file/index.html

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.