lsm-tree-0.1.0.0: Log-structured merge-trees
Safe HaskellSafe-Inferred
LanguageGHC2021

Database.LSMTree.Internal.RawPage

Synopsis

Documentation

data RawPage Source #

Constructors

RawPage 

Fields

Instances

Instances details
Show RawPage Source # 
Instance details

Defined in Database.LSMTree.Internal.RawPage

NFData RawPage Source # 
Instance details

Defined in Database.LSMTree.Internal.RawPage

Methods

rnf :: RawPage -> () #

Eq RawPage Source #

This instance assumes pages are 4096 bytes in size

Instance details

Defined in Database.LSMTree.Internal.RawPage

Methods

(==) :: RawPage -> RawPage -> Bool #

(/=) :: RawPage -> RawPage -> Bool #

makeRawPage Source #

Arguments

:: ByteArray

bytearray, must contain 4096 bytes (after offset)

-> Int

offset in bytes, must be 8 byte aligned.

-> RawPage 

Create RawPage.

This function may copy data to satisfy internal RawPage invariants. Use unsafeMakeRawPage if you don't want copy.

unsafeMakeRawPage Source #

Arguments

:: ByteArray

bytearray, must be pinned and contain 4096 bytes (after offset)

-> Int

offset in bytes, must be 8 byte aligned.

-> RawPage 

rawPageLookup :: RawPage -> SerialisedKey -> RawPageLookup (Entry SerialisedValue BlobSpan) Source #

Time: \( \mathcal{O}\left( \log_2 n \right) \) where \( n \) is the number of entries in the RawPage.

Return the Entry corresponding to the supplied SerialisedKey if it exists within the RawPage.

data RawPageLookup entry Source #

Constructors

LookupEntryNotPresent

The key is not present on the page.

LookupEntry !entry

The key is present and corresponds to a normal entry that fits fully within the page.

LookupEntryOverflow !entry !Word32

The key is present and corresponds to an entry where the value may have overflowed onto subsequent pages. In this case the entry contains the prefix of the value (that did fit on the page). The length of the suffix is returned separately.

Instances

Instances details
Functor RawPageLookup Source # 
Instance details

Defined in Database.LSMTree.Internal.RawPage

Methods

fmap :: (a -> b) -> RawPageLookup a -> RawPageLookup b #

(<$) :: a -> RawPageLookup b -> RawPageLookup a #

Show entry => Show (RawPageLookup entry) Source # 
Instance details

Defined in Database.LSMTree.Internal.RawPage

Methods

showsPrec :: Int -> RawPageLookup entry -> ShowS #

show :: RawPageLookup entry -> String #

showList :: [RawPageLookup entry] -> ShowS #

Eq entry => Eq (RawPageLookup entry) Source # 
Instance details

Defined in Database.LSMTree.Internal.RawPage

Methods

(==) :: RawPageLookup entry -> RawPageLookup entry -> Bool #

(/=) :: RawPageLookup entry -> RawPageLookup entry -> Bool #

rawPageOverflowPages :: RawPage -> Int Source #

Calculate the number of overflow pages that are expected to follow this page.

This will be non-zero when the page contains a single key/op entry that is itself too large to fit within the page.

rawPageFindKey Source #

Arguments

:: RawPage 
-> SerialisedKey 
-> Maybe Word16

entry number of first entry greater or equal to the key

Time: \( \mathcal{O}\left( \log_2 n \right) \) where \( n \) is the number of entries in the RawPage.

Return the least entry number in the RawPage (if it exists) which is greater than or equal to the supplied SerialisedKey.

The following law always holds \( \forall \mathtt{key} \mathtt{page} \):

  • maybe True (key <=) (getRawPageIndexKey . rawPageIndex page . id =<< rawPageFindKey page key)
  • maybe True (key > ) (getRawPageIndexKey . rawPageIndex page . pred =<< rawPageFindKey page key)
  • maybe (maximum (rawPageKeys page) < key) (rawPageFindKey page key)

data RawPageIndex entry Source #

Constructors

IndexNotPresent 
IndexEntry !SerialisedKey !entry

The index is present and corresponds to a normal entry that fits fully within the page (but might be the only entry on the page).

IndexEntryOverflow !SerialisedKey !entry !Word32

The index is present and corresponds to an entry where the value has overflowed onto subsequent pages. In this case only prefix entry and the length of the suffix are returned. The caller can copy the full serialised pages themselves.

Instances

Instances details
Functor RawPageIndex Source # 
Instance details

Defined in Database.LSMTree.Internal.RawPage

Methods

fmap :: (a -> b) -> RawPageIndex a -> RawPageIndex b #

(<$) :: a -> RawPageIndex b -> RawPageIndex a #

Show entry => Show (RawPageIndex entry) Source # 
Instance details

Defined in Database.LSMTree.Internal.RawPage

Methods

showsPrec :: Int -> RawPageIndex entry -> ShowS #

show :: RawPageIndex entry -> String #

showList :: [RawPageIndex entry] -> ShowS #

Eq entry => Eq (RawPageIndex entry) Source # 
Instance details

Defined in Database.LSMTree.Internal.RawPage

Methods

(==) :: RawPageIndex entry -> RawPageIndex entry -> Bool #

(/=) :: RawPageIndex entry -> RawPageIndex entry -> Bool #

getRawPageIndexKey :: RawPageIndex e -> Maybe SerialisedKey Source #

Time: \( \mathcal{O}\left( 1 \right) \)

Conveniently access the SerialisedKey of a RawPageIndex.

Test and debug

rawPageValueOffsets :: RawPage -> Vector ValueOffset Source #

for non-single key page case

rawPageValueOffsets1 :: RawPage -> (Word16, Word32) Source #

single key page case

rawPageBlobSpanIndex Source #

Arguments

:: RawPage 
-> Int

blobspan index. Calculate with rawPageCalculateBlobIndex

-> BlobSpan