@@ -8,7 +8,6 @@ module Database.LSMTree.Internal.Serialise.Class (
88 , SerialiseValue (.. )
99 , serialiseValueIdentity
1010 , serialiseValueIdentityUpToSlicing
11- , serialiseValueConcatDistributes
1211 , RawBytes (.. )
1312 , packSlice
1413 -- * Errors
@@ -21,7 +20,6 @@ import qualified Data.ByteString.Lazy as LBS
2120import qualified Data.ByteString.Short.Internal as SBS
2221import Data.Monoid (Sum (.. ))
2322import qualified Data.Primitive as P
24- import Data.Proxy (Proxy )
2523import qualified Data.Vector.Primitive as VP
2624import Data.Void (Void , absurd )
2725import Data.Word
@@ -80,14 +78,9 @@ serialiseKeyMinimalSize x = RB.size (serialiseKey x) >= 8
8078--
8179-- [Identity] @'deserialiseValue' ('serialiseValue' x) == x@
8280-- [Identity up to slicing] @'deserialiseValue' ('packSlice' prefix ('serialiseValue' x) suffix) == x@
83- -- [Concat distributes] @'deserialiseValueN' xs == 'deserialiseValue' ('mconcat' xs)@
8481class SerialiseValue v where
8582 serialiseValue :: v -> RawBytes
8683 deserialiseValue :: RawBytes -> v
87- -- | Deserialisation when bytes are split into multiple chunks.
88- --
89- -- TODO: Unused so far, we might not need it.
90- deserialiseValueN :: [RawBytes ] -> v
9184
9285
9386-- | An instance for 'Sum' which is transparent to the serialisation of @a@.
@@ -99,8 +92,6 @@ instance SerialiseValue a => SerialiseValue (Sum a) where
9992
10093 deserialiseValue = Sum . deserialiseValue
10194
102- deserialiseValueN = Sum . deserialiseValueN
103-
10495-- | Test the __Identity__ law for the 'SerialiseValue' class
10596serialiseValueIdentity :: (Eq v , SerialiseValue v ) => v -> Bool
10697serialiseValueIdentity x = deserialiseValue (serialiseValue x) == x
@@ -112,10 +103,6 @@ serialiseValueIdentityUpToSlicing ::
112103serialiseValueIdentityUpToSlicing prefix x suffix =
113104 deserialiseValue (packSlice prefix (serialiseValue x) suffix) == x
114105
115- -- | Test the __Concat distributes__ law for the 'SerialiseValue' class
116- serialiseValueConcatDistributes :: forall v . (Eq v , SerialiseValue v ) => Proxy v -> [RawBytes ] -> Bool
117- serialiseValueConcatDistributes _ xs = deserialiseValueN @ v xs == deserialiseValue (mconcat xs)
118-
119106{- ------------------------------------------------------------------------------
120107 RawBytes
121108-------------------------------------------------------------------------------}
@@ -159,7 +146,6 @@ instance SerialiseValue Word64 where
159146
160147 deserialiseValue (RawBytes (VP. Vector off len ba)) =
161148 requireBytesExactly " Word64" 8 len $ indexWord8ArrayAsWord64 ba off
162- deserialiseValueN = deserialiseValue . mconcat
163149
164150{- ------------------------------------------------------------------------------
165151 ByteString
@@ -178,14 +164,12 @@ instance SerialiseKey BS.ByteString where
178164-- | Placeholder instance, not optimised
179165instance SerialiseValue LBS. ByteString where
180166 serialiseValue = serialiseValue . LBS. toStrict
181- deserialiseValue = deserialiseValueN . pure
182- deserialiseValueN = B. toLazyByteString . foldMap RB. builder
167+ deserialiseValue = B. toLazyByteString . RB. builder
183168
184169-- | Placeholder instance, not optimised
185170instance SerialiseValue BS. ByteString where
186171 serialiseValue = RB. fromShortByteString . SBS. toShort
187- deserialiseValue = deserialiseValueN . pure
188- deserialiseValueN = LBS. toStrict . deserialiseValueN
172+ deserialiseValue = LBS. toStrict . deserialiseValue
189173
190174{- ------------------------------------------------------------------------------
191175 ShortByteString
@@ -198,7 +182,6 @@ instance SerialiseKey SBS.ShortByteString where
198182instance SerialiseValue SBS. ShortByteString where
199183 serialiseValue = RB. fromShortByteString
200184 deserialiseValue = byteArrayToSBS . RB. force
201- deserialiseValueN = byteArrayToSBS . foldMap RB. force
202185
203186{- ------------------------------------------------------------------------------
204187 ByteArray
@@ -210,7 +193,6 @@ instance SerialiseValue SBS.ShortByteString where
210193instance SerialiseValue P. ByteArray where
211194 serialiseValue ba = RB. fromByteArray 0 (P. sizeofByteArray ba) ba
212195 deserialiseValue = RB. force
213- deserialiseValueN = foldMap RB. force
214196
215197{- ------------------------------------------------------------------------------
216198Void
222204instance SerialiseValue Void where
223205 serialiseValue = absurd
224206 deserialiseValue = error " panic"
225- deserialiseValueN = error " panic"
0 commit comments