@@ -11,6 +11,7 @@ import Prelude hiding (all, head, last, length, notElem, splitAt,
1111
1212import Control.Arrow (first , (>>>) )
1313import Control.Monad.ST.Strict (runST )
14+ import qualified Data.ByteString.Lazy as LazyByteString (unpack )
1415import Data.ByteString.Short (ShortByteString (SBS ))
1516import qualified Data.ByteString.Short as ShortByteString (length , pack )
1617import Data.Either (isLeft )
@@ -21,7 +22,7 @@ import Data.Primitive.ByteArray (ByteArray (ByteArray), ByteArray#)
2122import Data.Vector (Vector , all , fromList , head , last , length ,
2223 notElem , splitAt , tail , takeWhile , toList , (!) )
2324import qualified Data.Vector.Primitive as Primitive (Vector (Vector ), concat ,
24- force , length , singleton )
25+ force , length , singleton , toList )
2526import Data.Word (Word16 , Word32 , Word64 , Word8 )
2627import Database.LSMTree.Extras.Generators (LogicalPageSummaries ,
2728 toAppends )
@@ -31,8 +32,8 @@ import Database.LSMTree.Extras.Index
3132import qualified Database.LSMTree.Internal.Chunk as Chunk (toByteVector )
3233import Database.LSMTree.Internal.Entry (NumEntries (NumEntries ))
3334import Database.LSMTree.Internal.Index.Ordinary
34- (IndexOrdinary (IndexOrdinary ), fromSBS , search ,
35- toLastKeys )
35+ (IndexOrdinary (IndexOrdinary ), finalLBS , fromSBS ,
36+ headerLBS , search , toLastKeys )
3637import Database.LSMTree.Internal.Index.OrdinaryAcc (new , unsafeEnd )
3738import Database.LSMTree.Internal.Page (PageNo (PageNo ),
3839 PageSpan (PageSpan ))
@@ -67,6 +68,15 @@ tests = testGroup "Test.Database.LSMTree.Internal.Index.Ordinary" $
6768 " Search for unmentioned key beyond range works"
6869 prop_searchForUnmentionedKeyBeyondRangeWorks
6970 ],
71+ testGroup " Header and footer construction" $
72+ [
73+ testProperty
74+ " Header construction works"
75+ prop_headerConstructionWorks,
76+ testProperty
77+ " Footer construction works"
78+ prop_footerConstructionWorks
79+ ],
7080 testGroup " Deserialisation" $
7181 [
7282 testProperty
@@ -353,6 +363,20 @@ prop_searchForUnmentionedKeyBeyondRangeWorks key (SearchableIndex index)
353363 selectionHead :: SerialisedKey
354364 selectionHead = head selection
355365
366+ -- ** Header and footer construction
367+
368+ prop_headerConstructionWorks :: Property
369+ prop_headerConstructionWorks
370+ = LazyByteString. unpack headerLBS
371+ ===
372+ Primitive. toList testedTypeAndVersionBlock
373+
374+ prop_footerConstructionWorks :: NumEntries -> IndexOrdinary -> Property
375+ prop_footerConstructionWorks entryCount index
376+ = LazyByteString. unpack (finalLBS entryCount index)
377+ ===
378+ Primitive. toList (entryCountBlock entryCount)
379+
356380-- ** Deserialisation
357381
358382prop_numberOfEntriesFromSerialisedIndexWorks :: NumEntries
0 commit comments