Skip to content

Commit 98d51ef

Browse files
committed
Class: add union debt/credits types and related functions
1 parent aa41f6b commit 98d51ef

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

test/Database/LSMTree/Class.hs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,21 @@ class (IsSession (Session h)) => IsTable h where
185185
=> NonEmpty (h m k v b)
186186
-> m (h m k v b)
187187

188+
remainingUnionDebt ::
189+
( IOLike m
190+
, C k v b
191+
)
192+
=> h m k v b
193+
-> m UnionDebt
194+
195+
supplyUnionCredits ::
196+
( IOLike m
197+
, C k v b
198+
)
199+
=> h m k v b
200+
-> UnionCredits
201+
-> m UnionCredits
202+
188203
withTableNew :: forall h m k v b a.
189204
(IOLike m, IsTable h, C k v b)
190205
=> Session h m
@@ -277,5 +292,8 @@ instance IsTable R.Table where
277292
openSnapshot sesh snap = R.openSnapshot sesh R.configNoOverride snap
278293

279294
duplicate = R.duplicate
295+
280296
union = R.union
281297
unions = R.unions
298+
remainingUnionDebt = R.remainingUnionDebt
299+
supplyUnionCredits = R.supplyUnionCredits

test/Database/LSMTree/Class/Common.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Data.Typeable (Typeable)
1515
import Database.LSMTree (ResolveValue)
1616
import Database.LSMTree.Common as Types (IOLike, Range (..),
1717
SerialiseKey, SerialiseValue, SnapshotLabel (..),
18-
SnapshotName)
18+
SnapshotName, UnionCredits (..), UnionDebt (..))
1919
import qualified Database.LSMTree.Common as R
2020
import System.FS.API (FsPath, HasFS)
2121
import System.FS.BlockIO.API (HasBlockIO)

test/Database/LSMTree/Model/IO.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ instance Class.IsTable Table where
9292

9393
union (Table s1 t1) (Table _s2 t2) =
9494
Table s1 <$> runInOpenSession s1 (Model.union Model.getResolve t1 t2)
95-
9695
unions ts =
9796
Table s <$> runInOpenSession s (Model.unions Model.getResolve (fmap thTable ts))
9897
where
9998
Table s _ = NE.head ts
99+
remainingUnionDebt (Table s t) = runInOpenSession s (Model.remainingUnionDebt t)
100+
supplyUnionCredits (Table s t) credits = runInOpenSession s (Model.supplyUnionCredits t credits)

0 commit comments

Comments
 (0)