haskey-0.1.0.1: A transcatoinal, ACID compliant, embeddable key-value store.

Safe HaskellNone
LanguageHaskell2010

Database.Haskey.Store.File

Contents

Description

On-disk storage back-end. Can be used as a storage back-end for the append-only page allocator (see Data.BTree.Alloc).

Synopsis

Storage

data Page t where Source #

A decoded page, of a certain type t of kind PageType.

type Files fp = IORef (Map fp FHandle) Source #

A collection of files, each associated with a certain fp handle.

Each file is a Handle opened in ReadWriteMode and contains a collection of physical pages.

These files can be safely shared between threads.

data FileStoreConfig Source #

File store configuration.

The default configuration can be obtained by using defFileStoreConfig

A configuration with a specific page size can be obtained by using fileStoreConfigWithPageSize.

defFileStoreConfig :: FileStoreConfig Source #

The default configuration

This is an unwrapped fileStoreConfigWithPageSize with a page size of 4096 bytes.

fileStoreConfigWithPageSize :: PageSize -> Maybe FileStoreConfig Source #

Create a configuration with a specific page size.

The maximum key and value sizes are calculated using calculateMaxKeySize and calculateMaxValueSize.

If the page size is too small, Nothing is returned.

data FileStoreT fp m a Source #

Monad in which on-disk storage operations can take place.

Two important instances are StoreM making it a storage back-end, and ConcurrentMetaStoreM making it a storage back-end compatible with the concurrent page allocator.

Instances

Monad m => MonadReader FileStoreConfig (FileStoreT fp m) Source # 
(Applicative m, Monad m, MonadIO m, MonadThrow m) => StoreM FilePath (FileStoreT FilePath m) Source # 
Monad m => Monad (FileStoreT fp m) Source # 

Methods

(>>=) :: FileStoreT fp m a -> (a -> FileStoreT fp m b) -> FileStoreT fp m b #

(>>) :: FileStoreT fp m a -> FileStoreT fp m b -> FileStoreT fp m b #

return :: a -> FileStoreT fp m a #

fail :: String -> FileStoreT fp m a #

Functor m => Functor (FileStoreT fp m) Source # 

Methods

fmap :: (a -> b) -> FileStoreT fp m a -> FileStoreT fp m b #

(<$) :: a -> FileStoreT fp m b -> FileStoreT fp m a #

Applicative m => Applicative (FileStoreT fp m) Source # 

Methods

pure :: a -> FileStoreT fp m a #

(<*>) :: FileStoreT fp m (a -> b) -> FileStoreT fp m a -> FileStoreT fp m b #

(*>) :: FileStoreT fp m a -> FileStoreT fp m b -> FileStoreT fp m b #

(<*) :: FileStoreT fp m a -> FileStoreT fp m b -> FileStoreT fp m a #

MonadIO m => MonadIO (FileStoreT fp m) Source # 

Methods

liftIO :: IO a -> FileStoreT fp m a #

MonadThrow m => MonadThrow (FileStoreT fp m) Source # 

Methods

throwM :: Exception e => e -> FileStoreT fp m a #

MonadCatch m => MonadCatch (FileStoreT fp m) Source # 

Methods

catch :: Exception e => FileStoreT fp m a -> (e -> FileStoreT fp m a) -> FileStoreT fp m a #

MonadMask m => MonadMask (FileStoreT fp m) Source # 

Methods

mask :: ((forall a. FileStoreT fp m a -> FileStoreT fp m a) -> FileStoreT fp m b) -> FileStoreT fp m b #

uninterruptibleMask :: ((forall a. FileStoreT fp m a -> FileStoreT fp m a) -> FileStoreT fp m b) -> FileStoreT fp m b #

(Applicative m, Monad m, MonadIO m, MonadCatch m) => ConcurrentMetaStoreM (FileStoreT FilePath m) Source # 

runFileStoreT Source #

Arguments

:: FileStoreT fp m a

Action

-> FileStoreConfig

Configuration

-> Files fp

Open files

-> m a 

Run the storage operations in the FileStoreT monad, given a collection of open files.

newFileStore :: IO (Files fp) Source #

An empty file store, with no open files.

Binary encoding

encodeAndPad :: PageSize -> Page t -> Maybe ByteString Source #

Encode a page padding it to the maxim page size.

Return Nothing of the page is too large to fit into one page size.

Exceptions

newtype FileNotFoundError hnd Source #

Exception thrown when a file is accessed that doesn't exist.

Constructors

FileNotFoundError hnd