File tree Expand file tree Collapse file tree 4 files changed +44
-2
lines changed
Expand file tree Collapse file tree 4 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -669,8 +669,8 @@ duplicate (Internal.MonoidalTable t) = Internal.MonoidalTable <$> Internal.dupli
669669 -> IO (Table IO k v) #-}
670670-- | Union two full tables, creating a new table.
671671--
672- -- A good mental model of this operation is @'Data.Map.unionWith' (<>)@ on
673- -- @'Data.Map.Map' k v@.
672+ -- A good mental model of this operation is @'Data.Map.Lazy. unionWith' (<>)@ on
673+ -- @'Data.Map.Lazy. Map' k v@.
674674--
675675-- Multiple tables of the same type but with different configuration parameters
676676-- can live in the same session. However, 'union' only works for tables that
Original file line number Diff line number Diff line change @@ -101,6 +101,9 @@ module Database.LSMTree.Normal (
101101 -- * Persistence
102102 , duplicate
103103
104+ -- * Table union
105+ , union
106+
104107 -- * Concurrency #concurrency#
105108 -- $concurrency
106109
@@ -778,3 +781,29 @@ duplicate ::
778781 => Table m k v blob
779782 -> m (Table m k v blob )
780783duplicate (Internal. NormalTable t) = Internal. NormalTable <$!> Internal. duplicate t
784+
785+ {- ------------------------------------------------------------------------------
786+ Table union
787+ -------------------------------------------------------------------------------}
788+
789+ {-# SPECIALISE union ::
790+ Table IO k v blob
791+ -> Table IO k v blob
792+ -> IO (Table IO k v blob) #-}
793+ -- | Union two full tables, creating a new table.
794+ --
795+ -- A good mental model of this operation is @'Data.Map.Lazy.union'@ on
796+ -- @'Data.Map.Lazy.Map' k v@.
797+ --
798+ -- Multiple tables of the same type but with different configuration parameters
799+ -- can live in the same session. However, 'union' only works for tables that
800+ -- have the same key\/value types and configuration parameters.
801+ --
802+ -- NOTE: unioning tables creates a new table, but does not close the tables that
803+ -- were used as inputs.
804+ union :: forall m k v blob .
805+ IOLike m
806+ => Table m k v blob
807+ -> Table m k v blob
808+ -> m (Table m k v blob )
809+ union = undefined
Original file line number Diff line number Diff line change @@ -211,6 +211,15 @@ class (IsSession (Session h)) => IsTable h where
211211 => h m k v blob
212212 -> m (h m k v blob )
213213
214+ union ::
215+ ( IOLike m
216+ , SerialiseValue v
217+ , C k v blob
218+ )
219+ => h m k v blob
220+ -> h m k v blob
221+ -> m (h m k v blob )
222+
214223withTableNew :: forall h m k v blob a .
215224 ( IOLike m
216225 , IsTable h
@@ -296,3 +305,4 @@ instance IsTable R.Table where
296305 open sesh snap = R. open sesh R. configNoOverride snap
297306
298307 duplicate = R. duplicate
308+ union = R. union
Original file line number Diff line number Diff line change @@ -91,6 +91,9 @@ instance Class.IsTable Table where
9191
9292 duplicate (Table s t) = Table s <$> runInOpenSession s (Model. duplicate t)
9393
94+ union (Table s1 t1) (Table _s2 t2) =
95+ Table s1 <$> runInOpenSession s1 (Model. union Model. noResolve t1 t2)
96+
9497convLookupResult :: Model. LookupResult v b -> Class. LookupResult v b
9598convLookupResult = \ case
9699 Model. NotFound -> Class. NotFound
You can’t perform that action at this time.
0 commit comments