Copyright | (c) Philip Kamenarsky 2018 |
---|---|
License | MIT |
Maintainer | p.kamenarsky@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
This package contains a thin wrapper over a continous memory region combined with an efficient reverse index implementation for fast and type-safe indexed lookups.
It is aimed at storing, loading and querying big immutable datasets. Once written, a database can not be modified further.
The underlying storage is pinned and thus ensures efficient garbage collection without ever reading the structure contents, since no pointers live inside the dataset that point outside it.
Synopsis
- data DB (indexes :: [(Symbol, *)]) a
- data ByteStringIndex a
- data Word32Index a
- newtype Id a = Id Word32
- newtype Limit a = Limit Word32
- incId :: Id a -> Id a
- addLimit :: Id a -> Limit a -> Id a
- subIds :: Id a -> Id a -> Limit a
- (!) :: Serialize a => DB indexes a -> Id a -> Maybe a
- slice :: Serialize a => Id a -> Limit a -> DB indexes a -> [a]
- lookup :: forall indexes s v a. Serialize a => LookupIndex indexes s v a => Name s -> v -> DB indexes a -> [a]
Database
data DB (indexes :: [(Symbol, *)]) a Source #
An immutable database containing elements of type a
, each one
indexed according to an Indexes
description.
Import Database.Immutable.Read for reading boxed values and Database.Immutable.Read.Unboxed for the unboxed variant.
Index types
data ByteStringIndex a Source #
data Word32Index a Source #
Offset into the database.
Limit the number of elements read after an Id
.
Querying
(!) :: Serialize a => DB indexes a -> Id a -> Maybe a Source #
O(1) Yield the database element at the specified position.