hashed-storage-0.4.3: Hashed file storage support code.

Storage.Hashed.Packed

Contents

Description

This module implements an object storage. This is a directory on disk containing a content-addressed storage. This is useful for storing all kinds of things, particularly filesystem trees, or darcs pristine caches and patch objects. However, this is an abstract, flat storage: no tree semantics are provided. You just need to provide a reference-collecting functionality, computing a list of references for any given object. The system provides transparent garbage collection and packing.

Synopsis

Documentation

data Format Source

On-disk format for object storage: we implement a completely loose format (one file per object), a compact format stored in a single append-only file and an immutable "pack" format.

Constructors

Loose 
Compact 
Pack 

Instances

data Block Source

Object storage block. When used as a hatchery, the loose or compact format are preferable, while for mature space, the pack format is more useful.

data OS Source

Object storage. Contains a single "hatchery" and possibly a number of mature space blocks, usually in form of packs. It also keeps a list of root pointers and has a way to extract pointers from objects (externally supplied). These last two things are used to implement a simple GC.

Basic operations.

hatch :: OS -> [ByteString] -> IO OSSource

Add new objects to the object storage (i.e. put them into hatchery). It is safe to call this even on objects that are already present in the storage: such objects will be skipped.

compact :: OS -> IO OSSource

Move things from hatchery into a (new) pack.

repack :: OS -> IO OSSource

Reduce number of packs in the object storage. This may both recombine packs to eliminate dead objects and join some packs to form bigger packs.

lookup :: OS -> Hash -> IO (Maybe FileSegment)Source

Creating and loading.

create :: FilePath -> Format -> IO OSSource

Create an empty object storage in given directory, with a hatchery of given format. The directory is created if needed, but is assumed to be empty.

Low-level.

blockLookup :: Block -> Hash -> IO (Maybe FileSegment)Source

live :: OS -> [Block] -> IO (Map Hash FileSegment)Source

Build a map of live objects (i.e. those reachable from the given roots) in a given list of Blocks.

references :: OS -> FileSegment -> IO [Hash]Source