Skip to content

Commit 2e7635c

Browse files
authored
Merge pull request #762 from IntersectMBO/jdral/bpe-codec
Remove backwards compatible codec for bloomfilter bits per entry
2 parents 4d1876e + 24524f0 commit 2e7635c

8 files changed

+4
-22
lines changed

src/Database/LSMTree/Internal/Snapshot/Codec.hs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ instance Encode RunBloomFilterAlloc where
386386
encode (RunAllocFixed bits) =
387387
encodeListLen 2
388388
<> encodeWord 0
389-
<> encodeIntOrDouble bits
389+
<> encodeDouble bits
390390
encode (RunAllocRequestFPR fpr) =
391391
encodeListLen 2
392392
<> encodeWord 1
@@ -397,7 +397,7 @@ instance DecodeVersioned RunBloomFilterAlloc where
397397
n <- decodeListLen
398398
tag <- decodeWord
399399
case (n, tag) of
400-
(2, 0) -> RunAllocFixed <$> decodeIntOrDouble
400+
(2, 0) -> RunAllocFixed <$> decodeDouble
401401
(2, 1) -> RunAllocRequestFPR <$> decodeDouble
402402
_ -> fail ("[RunBloomFilterAlloc] Unexpected combination of list length and tag: " <> show (n, tag))
403403

@@ -407,7 +407,7 @@ instance Encode BloomFilterAlloc where
407407
encode (AllocFixed x) =
408408
encodeListLen 2
409409
<> encodeWord 0
410-
<> encodeIntOrDouble x
410+
<> encodeDouble x
411411
encode (AllocRequestFPR x) =
412412
encodeListLen 2
413413
<> encodeWord 1
@@ -418,28 +418,10 @@ instance DecodeVersioned BloomFilterAlloc where
418418
n <- decodeListLen
419419
tag <- decodeWord
420420
case (n, tag) of
421-
(2, 0) -> AllocFixed <$> decodeIntOrDouble
421+
(2, 0) -> AllocFixed <$> decodeDouble
422422
(2, 1) -> AllocRequestFPR <$> decodeDouble
423423
_ -> fail ("[BloomFilterAlloc] Unexpected combination of list length and tag: " <> show (n, tag))
424424

425-
-- Avoid a format change when the value is an integer: int or double encoding.
426-
encodeIntOrDouble :: Double -> Encoding
427-
encodeIntOrDouble x
428-
| let x' = floor x
429-
, x == fromIntegral x' = encodeInt x'
430-
| otherwise = encodeDouble x
431-
432-
decodeIntOrDouble :: Decoder s Double
433-
decodeIntOrDouble = do
434-
tok <- peekTokenType
435-
if isTokInt tok
436-
then fromIntegral <$> decodeInt
437-
else decodeDouble
438-
where
439-
isTokInt TypeUInt = True
440-
isTokInt TypeNInt = True
441-
isTokInt _ = False
442-
443425
-- FencePointerIndexType
444426

445427
instance Encode FencePointerIndexType where
Binary file not shown.
Binary file not shown.
6 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)