Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Database.LSMTree.Internal.RawPage
Contents
Synopsis
- data RawPage = RawPage !Int !ByteArray
- emptyRawPage :: RawPage
- makeRawPage :: ByteArray -> Int -> RawPage
- unsafeMakeRawPage :: ByteArray -> Int -> RawPage
- rawPageRawBytes :: RawPage -> RawBytes
- rawPageNumKeys :: RawPage -> Word16
- rawPageNumBlobs :: RawPage -> Word16
- rawPageLookup :: RawPage -> SerialisedKey -> RawPageLookup (Entry SerialisedValue BlobSpan)
- data RawPageLookup entry
- = LookupEntryNotPresent
- | LookupEntry !entry
- | LookupEntryOverflow !entry !Word32
- rawPageOverflowPages :: RawPage -> Int
- rawPageFindKey :: RawPage -> SerialisedKey -> Maybe Word16
- rawPageIndex :: RawPage -> Word16 -> RawPageIndex (Entry SerialisedValue BlobSpan)
- data RawPageIndex entry
- = IndexNotPresent
- | IndexEntry !SerialisedKey !entry
- | IndexEntryOverflow !SerialisedKey !entry !Word32
- getRawPageIndexKey :: RawPageIndex e -> Maybe SerialisedKey
- rawPageKeyOffsets :: RawPage -> Vector KeyOffset
- rawPageValueOffsets :: RawPage -> Vector ValueOffset
- rawPageValueOffsets1 :: RawPage -> (Word16, Word32)
- rawPageHasBlobSpanAt :: RawPage -> Int -> Word64
- rawPageBlobSpanIndex :: RawPage -> Int -> BlobSpan
- rawPageOpAt :: RawPage -> Int -> Word64
- rawPageKeys :: RawPage -> Vector SerialisedKey
- rawPageValues :: RawPage -> Vector SerialisedValue
Documentation
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.
rawPageRawBytes :: RawPage -> RawBytes Source #
rawPageNumKeys :: RawPage -> Word16 Source #
rawPageNumBlobs :: RawPage -> Word16 Source #
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
Functor RawPageLookup Source # | |
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 # | |
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 # | |
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.
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)
rawPageIndex :: RawPage -> Word16 -> RawPageIndex (Entry SerialisedValue BlobSpan) Source #
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
Functor RawPageIndex Source # | |
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 # | |
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 # | |
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
rawPageKeyOffsets :: RawPage -> Vector KeyOffset Source #
rawPageValueOffsets :: RawPage -> Vector ValueOffset Source #
for non-single key page case
rawPageKeys :: RawPage -> Vector SerialisedKey Source #
rawPageValues :: RawPage -> Vector SerialisedValue Source #
Non-single page case