module Database.Haskey.Alloc.Concurrent.Meta where
import Data.Binary (Binary)
import Data.Proxy (Proxy)
import Data.Set as Set
import GHC.Generics (Generic)
import Data.BTree.Impure.Structures
import Data.BTree.Primitives
import Database.Haskey.Alloc.Concurrent.Environment
import Database.Haskey.Alloc.Concurrent.FreePages.Tree
import Database.Haskey.Alloc.Concurrent.Overflow
import Database.Haskey.Store
data CurrentMetaPage = Meta1 | Meta2
data ConcurrentMeta k v = ConcurrentMeta {
concurrentMetaRevision :: TxId
, concurrentMetaDataNumPages :: S 'TypeData PageId
, concurrentMetaIndexNumPages :: S 'TypeIndex PageId
, concurrentMetaTree :: Tree k v
, concurrentMetaDataFreeTree :: S 'TypeData FreeTree
, concurrentMetaIndexFreeTree :: S 'TypeIndex FreeTree
, concurrentMetaOverflowTree :: OverflowTree
, concurrentMetaDataFreshUnusedPages :: S 'TypeData (Set DirtyFree)
, concurrentMetaIndexFreshUnusedPages :: S 'TypeIndex (Set DirtyFree)
} deriving (Generic)
deriving instance (Show k, Show v) => Show (ConcurrentMeta k v)
instance (Binary k, Binary v) => Binary (ConcurrentMeta k v) where
class StoreM FilePath m => ConcurrentMetaStoreM m where
putConcurrentMeta :: (Key k, Value v)
=> FilePath
-> ConcurrentMeta k v
-> m ()
readConcurrentMeta :: (Key k, Value v)
=> FilePath
-> Proxy k
-> Proxy v
-> m (Maybe (ConcurrentMeta k v))