File tree Expand file tree Collapse file tree 5 files changed +346
-109
lines changed
src/Database/LSMTree/Internal
test/Test/Database/LSMTree/Internal Expand file tree Collapse file tree 5 files changed +346
-109
lines changed Original file line number Diff line number Diff line change @@ -470,7 +470,9 @@ combine new_ old = case new_ of
470470--
471471-- See 'MergeUnion'.
472472combineUnion :: Op -> Op -> Op
473+ combineUnion Delete (Mupsert v) = Insert v Nothing
473474combineUnion Delete old = old
475+ combineUnion (Mupsert u) Delete = Insert u Nothing
474476combineUnion new_ Delete = new_
475477combineUnion (Mupsert v') (Mupsert v ) = Insert (resolveValue v' v) Nothing
476478combineUnion (Mupsert v') (Insert v _) = Insert (resolveValue v' v) Nothing
Original file line number Diff line number Diff line change @@ -549,7 +549,7 @@ instance Arbitrary (Unsliced SerialisedKey) where
549549
550550instance Arbitrary BlobSpan where
551551 arbitrary = BlobSpan <$> arbitrary <*> arbitrary
552- shrink (BlobSpan x y) = BlobSpan <$> shrink x <*> shrink y
552+ shrink (BlobSpan x y) = [ BlobSpan x' y' | (x', y') <- shrink (x, y) ]
553553
554554{- ------------------------------------------------------------------------------
555555 Merge
Original file line number Diff line number Diff line change @@ -92,12 +92,11 @@ unNumEntries (NumEntries x) = x
9292 Value resolution/merging
9393-------------------------------------------------------------------------------}
9494
95- -- | As long as values are a semigroup, an Entry is too
96- instance Semigroup v => Semigroup (Entry v b ) where
97- e1 <> e2 = combine (<>) e1 e2
98-
9995-- | Given a value-merge function, combine entries. Only take a blob from the
10096-- left entry.
97+ --
98+ -- Note: 'Entry' is a semigroup with 'combine' if the @(v -> v -> v)@ argument
99+ -- is associative.
101100combine :: (v -> v -> v ) -> Entry v b -> Entry v b -> Entry v b
102101combine _ e@ Delete _ = e
103102combine _ e@ Insert {} _ = e
@@ -111,10 +110,15 @@ combine f (Mupdate u) (Mupdate v) = Mupdate (f u v)
111110-- has a value, the result should have a value (represented by 'Insert'). If
112111-- both have a value, these values get combined monoidally. Only take a blob
113112-- from the left entry.
113+ --
114+ -- Note: 'Entry' is a semigroup with 'combineUnion' if the @(v -> v -> v)@
115+ -- argument is associative.
114116combineUnion :: (v -> v -> v ) -> Entry v b -> Entry v b -> Entry v b
115117combineUnion f = go
116118 where
119+ go Delete (Mupdate v) = Insert v
117120 go Delete e = e
121+ go (Mupdate u) Delete = Insert u
118122 go e Delete = e
119123 go (Insert u) (Insert v) = Insert (f u v)
120124 go (Insert u) (InsertWithBlob v _) = Insert (f u v)
You can’t perform that action at this time.
0 commit comments