Safe Haskell | None |
---|---|
Language | Haskell2010 |
Storage.Hashed.Packed
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.
- data Format
- 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
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.
data Block
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
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 OS
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.
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.
Creating and loading.
create :: FilePath -> Format -> IO OS
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)
live :: OS -> [Block] -> IO (Map Hash FileSegment)
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]