File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ module Database.LSMTree.Class (
88 , withTableFromSnapshot
99 , withTableDuplicate
1010 , withTableUnion
11+ , withTableUnions
1112 , withCursor
1213 , module Common
1314 , module Types
@@ -162,6 +163,13 @@ class (IsSession (Session h)) => IsTable h where
162163 -> h m k v b
163164 -> m (h m k v b )
164165
166+ unions ::
167+ ( IOLike m
168+ , C k v b
169+ )
170+ => V. Vector (h m k v b )
171+ -> m (h m k v b )
172+
165173withTableNew :: forall h m k v b a .
166174 (IOLike m , IsTable h , C k v b )
167175 => Session h m
@@ -194,6 +202,13 @@ withTableUnion :: forall h m k v b a.
194202 -> m a
195203withTableUnion table1 table2 = bracket (table1 `union` table2) close
196204
205+ withTableUnions :: forall h m k v b a .
206+ (IOLike m , IsTable h , C k v b )
207+ => V. Vector (h m k v b )
208+ -> (h m k v b -> m a )
209+ -> m a
210+ withTableUnions tables = bracket (unions tables) close
211+
197212withCursor :: forall h m k v b a .
198213 (IOLike m , IsTable h , C k v b )
199214 => Maybe k
@@ -232,3 +247,4 @@ instance IsTable R.Table where
232247
233248 duplicate = R. duplicate
234249 union = R. union
250+ unions = R. unions
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ module Database.LSMTree.Model.IO (
1717import Control.Concurrent.Class.MonadSTM.Strict
1818import Control.Exception (Exception )
1919import Control.Monad.Class.MonadThrow (MonadThrow (.. ))
20+ import qualified Data.Vector as V
2021import qualified Database.LSMTree.Class as Class
2122import Database.LSMTree.Model.Session (TableConfig (.. ))
2223import qualified Database.LSMTree.Model.Session as Model
@@ -90,3 +91,8 @@ instance Class.IsTable Table where
9091
9192 union (Table s1 t1) (Table _s2 t2) =
9293 Table s1 <$> runInOpenSession s1 (Model. union Model. getResolve t1 t2)
94+
95+ unions ts =
96+ Table s <$> runInOpenSession s (Model. unions Model. getResolve (V. map thTable ts))
97+ where
98+ Table s _ = V. head ts
You can’t perform that action at this time.
0 commit comments