Safe Haskell | None |
---|---|
Language | Haskell2010 |
A storage back-end manages physical storage of pages.
- class (Applicative m, Monad m) => StoreM hnd m | m -> hnd where
- arbitrarySearch :: (Ord v, Integral n) => n -> (n -> v) -> v -> n
- calculateMaxKeySize :: PageSize -> (Node Z ZeroEncoded ZeroEncoded -> PageSize) -> Word64
- calculateMaxValueSize :: PageSize -> Word64 -> (Node Z ZeroEncoded ZeroEncoded -> PageSize) -> Word64
- data ZeroEncoded = ZeroEncoded {}
Class
class (Applicative m, Monad m) => StoreM hnd m | m -> hnd where Source #
A storage back-end that can store and fetch physical pages.
openHandle, flushHandle, closeHandle, removeHandle, nodePageSize, maxPageSize, getNodePage, putNodePage, getOverflow, putOverflow, listOverflows
openHandle :: hnd -> m () Source #
Open a database handle for reading and writing.
flushHandle :: hnd -> m () Source #
Flush the contents of a handle to disk (or other storage).
closeHandle :: hnd -> m () Source #
Close a database handle.
removeHandle :: hnd -> m () Source #
Remove a handle from the storage back-end.
nodePageSize :: (Key key, Value val) => m (Height height -> Node height key val -> PageSize) Source #
A function that calculates the hypothetical size of a node, if it were to be written to a page (regardless of the maximum page size).
maxPageSize :: m PageSize Source #
The maximum page size the allocator can handle.
maxKeySize :: m Word64 Source #
Get the maximum key size
The default implementation will repeatedly call calculateMaxKeySize
.
You might want to cache this value in your own implementation.
maxValueSize :: m Word64 Source #
Get the maximum value size
The default implementation will repeatedly call calculateMaxValueSize
.
You might want to cache this value in your own implementation.
getNodePage :: (Key key, Value val) => hnd -> Height height -> Proxy key -> Proxy val -> NodeId height key val -> m (Node height key val) Source #
Read a page and return the actual node and the transaction id when the node was written.
putNodePage :: (Key key, Value val) => hnd -> Height height -> NodeId height key val -> Node height key val -> m () Source #
Write a node to a physical page.
getOverflow :: Value val => hnd -> Proxy val -> m val Source #
Read a value from an overflow page
putOverflow :: Value val => hnd -> val -> m () Source #
Write a value to an overflow page
listOverflows :: hnd -> m [hnd] Source #
List overflow pages in the specific overflow directory.
The result should include **AT LEAST** the handles in the specified directory, but it may contain more handles, even handles that do not belong to an overflow page.
StoreM hnd m => StoreM hnd (StateT s m) Source # | |
(Applicative m, Monad m, MonadIO m, MonadThrow m, Ord fp, Show fp, Typeable * fp) => StoreM fp (MemoryStoreT fp m) Source # | |
(Applicative m, Monad m, MonadIO m, MonadThrow m) => StoreM FilePath (FileStoreT FilePath m) Source # | |
StoreM hnd m => StoreM hnd (ReaderT * s m) Source # | |
Helpers
arbitrarySearch :: (Ord v, Integral n) => n -> (n -> v) -> v -> n Source #
Search an arbitrary number, less than a limit, greater than a starting value.
:: PageSize | Maximum pages size |
-> (Node Z ZeroEncoded ZeroEncoded -> PageSize) | Function that calculates the page size of a node |
-> Word64 | Maximum key size |
Calculate the maximum key size.
Return the size for which at least 4 key-value pairs with keys and values of that size can fit in a leaf node.
calculateMaxValueSize Source #
:: PageSize | Maximum page size |
-> Word64 | Maximum key size |
-> (Node Z ZeroEncoded ZeroEncoded -> PageSize) | Function that calculates the page size of a node |
-> Word64 | Maximum value size |
Calculate the maximum value size.
Return the size for which at least 4 key-value pairs of the specified maximum key size and values of the returned size can fit in a leaf node. that size can fit in a leaf node.
data ZeroEncoded Source #
Data type which encodes the integer using a variable amount of NULL or ONE bytes.