hashed-storage-0.4.13: Hashed file storage support code.Source codeContentsIndex
Storage.Hashed.Packed
Contents
Basic operations.
Creating and loading.
Low-level.
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
data Format
= Loose
| Compact
| Pack
data Block
data OS
hatch :: OS -> [ByteString] -> IO OS
compact :: OS -> IO OS
repack :: OS -> IO OS
lookup :: OS -> Hash -> IO (Maybe FileSegment)
create :: FilePath -> Format -> IO OS
load :: FilePath -> IO OS
format :: Block -> Format
blockLookup :: Block -> Hash -> IO (Maybe FileSegment)
live :: OS -> [Block] -> IO (Map Hash FileSegment)
hatchery :: OS -> Block
mature :: OS -> [Block]
roots :: OS -> [Hash]
references :: OS -> FileSegment -> IO [Hash]
rootdir :: OS -> FilePath
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
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.
load :: FilePath -> IO OSSource
Low-level.
format :: Block -> FormatSource
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.
hatchery :: OS -> BlockSource
mature :: OS -> [Block]Source
roots :: OS -> [Hash]Source
references :: OS -> FileSegment -> IO [Hash]Source
rootdir :: OS -> FilePathSource
Produced by Haddock version 2.6.0