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

Safe HaskellNone
LanguageHaskell2010

Database.Haskey.Alloc.Concurrent.FreePages.Query

Synopsis

Documentation

getFreePageId :: (Functor m, AllocM m, MonadIO m, MonadState (WriterEnv hnd) m) => S stateType () -> m (Maybe SomeFreePage) Source #

Get a free page.

First try to get one from the in-memory dirty pages. Then try to get one from the in-memory free page cache stored in writerReusablePages. If that one is empty, actually query one from the free database.

getFreedDirtyPageId :: (Functor m, MonadState (WriterEnv hnd) m) => S stateType () -> m (Maybe DirtyFree) Source #

Get a free'd dirty page.

Get a free'd dirty page, that is immediately suitable for reuse in the current transaction.

getCachedFreePageId :: (Functor m, MonadState (WriterEnv hnd) m) => S stateType () -> m (Maybe OldFree) Source #

Get a cached free page.

Get a free page from the free database cache stored in writerReusablePages.

queryNewFreePageIds :: (AllocM m, MonadIO m, MonadState (WriterEnv hnd) m) => S stateType () -> m (Maybe OldFree) Source #

Try to get a list of free pages from the free page database, return the first free one for immediate use, and store the rest in the environment.

This function will delete the lastly used entry from the free database, query a new one, and then update the free page cache in the state.

This function only works when writerReusablePagesOn is True.

This function expects writerReusablePages to be empty.

lookupValidFreePageIds :: (MonadIO m, AllocReaderM m, MonadState (WriterEnv hnd) m) => FreeTree -> m (Maybe (TxId, NonEmpty PageId)) Source #

Lookup a list of free pages from the free page database, guaranteed to be old enough.

lookupFreePageIds :: (Functor m, AllocReaderM m, MonadState (WriterEnv hnd) m) => FreeTree -> m (Maybe (Unchecked (TxId, NonEmpty PageId))) Source #

Lookup a list of free pages from the free page database.

newtype Unchecked a Source #

Auxiliry type to ensure the transaction ID of free pages are checked.

Constructors

Unchecked a 

checkFreePages :: (Functor m, MonadIO m, MonadState (WriterEnv hnd) m) => Unchecked (TxId, NonEmpty PageId) -> m (Maybe (TxId, NonEmpty PageId)) Source #

Check the transaction ID of the free pages, if it's to old, return Nothing.