zoom-cache 1.2.1.0 → 1.2.1.1
raw patch · 5 files changed
+35/−52 lines, 5 files
Files
- Data/Iteratee/Offset.hs +1/−0
- Data/Iteratee/ZoomCache.hs +18/−9
- Data/Iteratee/ZoomCache/Utils.hs +10/−37
- Data/ZoomCache/Numeric/Internal.hs +5/−5
- zoom-cache.cabal +1/−1
Data/Iteratee/Offset.hs view
@@ -34,6 +34,7 @@ | LL.null vec = I.liftI step | otherwise = I.idone o s step stream = I.icont step (Just (I.setEOF stream))+{-# INLINE tell #-} ----------------------------------------------------------------------
Data/Iteratee/ZoomCache.hs view
@@ -108,10 +108,10 @@ data Block = Block { blkFile :: CacheFile , blkTrack :: TrackNo- , blkData :: BlockData+ , blkData :: !BlockData } -data BlockData = BlockPacket PacketSO | BlockSummary ZoomSummarySO+data BlockData = BlockPacket !PacketSO | BlockSummary !ZoomSummarySO instance Timestampable Block where timestamp (Block c t (BlockPacket p)) = timestamp (packetFromCTPSO (c,t,p))@@ -177,11 +177,13 @@ enumSummaryLevel level = I.joinI . enumSummaries . I.filter (\(ZoomSummary s) -> summaryLevel s == level)+{-# INLINE enumSummaryLevel #-} -- | Filter summaries at all levels enumSummaries :: (Functor m, Monad m) => I.Enumeratee [Offset Block] [ZoomSummary] m a enumSummaries = I.joinI . enumCTSO . I.mapChunks (map summaryFromCTSO)+{-# INLINE enumSummaries #-} -- | Convert a CTSO triple into a ZoomSummary summaryFromCTSO :: (CacheFile, TrackNo, ZoomSummarySO) -> ZoomSummary@@ -271,6 +273,7 @@ where fil :: Block -> Bool fil b = (blkTrack b) `elem` tracks+{-# INLINE filterTracks #-} -- | An enumeratee of a zoom-cache file, from the global header onwards. -- The global and track headers will be transparently read, and the @@ -281,6 +284,7 @@ enumCacheFile identifiers iter = do fi <- iterHeaders identifiers enumBlock fi iter+{-# INLINE enumCacheFile #-} -- | An enumeratee of zoom-cache data, after global and track headers -- have been read, or if the 'CacheFile' has been acquired elsewhere.@@ -319,30 +323,32 @@ iterBlock :: (Functor m, MonadIO m) => CacheFile -> Iteratee (Offset ByteString) m (CacheFile, [Offset Block])-iterBlock cf = do+iterBlock cf = {-# SCC "iterBlock" #-} do I.dropWhile (/= headerMarker) o <- OffI.tell header <- OffI.takeBS 8 case parseHeader header of Just PacketHeader -> do- (trackNo, packet) <- OffI.convOffset $ readPacket (cfSpecs cf)- return $ maybe (cf, []) (retPacket trackNo o) packet+ (!trackNo, packet) <- OffI.convOffset $ readPacket (cfSpecs cf)+ return $! maybe (cf, []) (retPacket trackNo o) packet Just SummaryHeader -> do- (trackNo, summary) <- OffI.convOffset $ readSummaryBlock (cfSpecs cf)- return $ maybe (cf, []) (retSummary trackNo o) summary+ (!trackNo, summary) <- OffI.convOffset $ readSummaryBlock (cfSpecs cf)+ return $! maybe (cf, []) (retSummary trackNo o) summary _ -> return (cf, []) where retPacket trackNo o p = (cf', [Offset o (Block cf' trackNo (BlockPacket p))]) where ms = toMS <$> (flip timeStampFromSO) (packetSOExit p) <$> r r = specRate <$> IM.lookup trackNo (cfSpecs cf)- cf' = cf { cfOffsets = offs' ms o (cfOffsets cf) }+ !cfO' = offs' ms o (cfOffsets cf)+ cf' = cf { cfOffsets = cfO' } retSummary trackNo o (ZoomSummarySO s) = (cf', [Offset o (Block cf' trackNo (BlockSummary (ZoomSummarySO s)))]) where ms = toMS <$> (flip timeStampFromSO) (summarySOExit s) <$> r r = specRate <$> IM.lookup trackNo (cfSpecs cf)- cf' = cf { cfOffsets = offs' ms o (cfOffsets cf) }+ !cfO' = offs' ms o (cfOffsets cf)+ cf' = cf { cfOffsets = cfO' } toMS :: TimeStamp -> Int toMS (TS ts) = floor . (* 1000.0) $ ts@@ -353,6 +359,7 @@ where f Nothing = Just o f (Just o0) = Just (min o0 o)+{-# INLINE iterBlock #-} -- | An iteratee of zoom-cache data, after global and track headers -- have been read, or if the 'CacheFile' has been acquired elsewhere.@@ -360,6 +367,7 @@ => CacheFile -> I.Enumeratee (Offset ByteString) [Offset Block] m a enumBlock = I.unfoldConvStreamCheck I.eneeCheckIfDonePass iterBlock+{-# INLINE enumBlock #-} -- | A version of enumBlock which won't fail with an EofException if the last -- bit is incomplete (perhaps still being written to).@@ -602,6 +610,7 @@ readSummaryAs :: (ZoomReadable a, Functor m, Monad m) => a -> Iteratee ByteString m (SummaryData a) readSummaryAs = const readSummary+{-# INLINE readSummaryBlockData #-} ----------------------------------------------------------------------
Data/Iteratee/ZoomCache/Utils.hs view
@@ -36,7 +36,6 @@ import Control.Applicative ((<$>)) import Control.Monad (msum) import Data.Bits-import qualified Data.ByteString as B import Data.ByteString (ByteString) import Data.Int import Data.Iteratee (Iteratee)@@ -59,10 +58,7 @@ where u8_to_s8 :: Word8 -> Int8 u8_to_s8 = fromIntegral-{-# SPECIALIZE INLINE readInt8 :: (Functor m, Monad m) => Iteratee [Word8] m Int8 #-}-{-# SPECIALIZE INLINE readInt8 :: (Functor m, Monad m) => Iteratee B.ByteString m Int8 #-}-{-# SPECIALIZE INLINE readInt8 :: (Functor m, Monad m) => Iteratee [Word8] m Int #-}-{-# SPECIALIZE INLINE readInt8 :: (Functor m, Monad m) => Iteratee B.ByteString m Int #-}+{-# INLINE readInt8 #-} -- | Read 2 bytes as a big-endian signed Integral readInt16be :: (I.Nullable s, LL.ListLike s Word8, Functor m, Monad m, Integral a)@@ -71,10 +67,7 @@ where u16_to_s16 :: Word16 -> Int16 u16_to_s16 = fromIntegral-{-# SPECIALIZE INLINE readInt16be :: (Functor m, Monad m) => Iteratee [Word8] m Int16 #-}-{-# SPECIALIZE INLINE readInt16be :: (Functor m, Monad m) => Iteratee B.ByteString m Int16 #-}-{-# SPECIALIZE INLINE readInt16be :: (Functor m, Monad m) => Iteratee [Word8] m Int #-}-{-# SPECIALIZE INLINE readInt16be :: (Functor m, Monad m) => Iteratee B.ByteString m Int #-}+{-# INLINE readInt16be #-} -- | Read 4 bytes as a big-endian signed Integral readInt32be :: (I.Nullable s, LL.ListLike s Word8, Functor m, Monad m, Integral a)@@ -83,10 +76,7 @@ where u32_to_s32 :: Word32 -> Int32 u32_to_s32 = fromIntegral-{-# SPECIALIZE INLINE readInt32be :: (Functor m, Monad m) => Iteratee [Word8] m Int32 #-}-{-# SPECIALIZE INLINE readInt32be :: (Functor m, Monad m) => Iteratee B.ByteString m Int32 #-}-{-# SPECIALIZE INLINE readInt32be :: (Functor m, Monad m) => Iteratee [Word8] m Int #-}-{-# SPECIALIZE INLINE readInt32be :: (Functor m, Monad m) => Iteratee B.ByteString m Int #-}+{-# INLINE readInt32be #-} -- | Read 8 bytes as a big-endian signed Integral readInt64be :: (I.Nullable s, LL.ListLike s Word8, Functor m, Monad m, Integral a)@@ -95,46 +85,31 @@ where u64_to_s64 :: Word64 -> Int64 u64_to_s64 = fromIntegral-{-# SPECIALIZE INLINE readInt64be :: (Functor m, Monad m) => Iteratee [Word8] m Int64 #-}-{-# SPECIALIZE INLINE readInt64be :: (Functor m, Monad m) => Iteratee B.ByteString m Int64 #-}-{-# SPECIALIZE INLINE readInt64be :: (Functor m, Monad m) => Iteratee [Word8] m Int #-}-{-# SPECIALIZE INLINE readInt64be :: (Functor m, Monad m) => Iteratee B.ByteString m Int #-}+{-# INLINE readInt64be #-} -- | Read 1 byte as an unsigned Integral readWord8 :: (I.Nullable s, LL.ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a readWord8 = fromIntegral <$> I.head-{-# SPECIALIZE INLINE readWord8 :: (Functor m, Monad m) => Iteratee [Word8] m Word8 #-}-{-# SPECIALIZE INLINE readWord8 :: (Functor m, Monad m) => Iteratee B.ByteString m Word8 #-}-{-# SPECIALIZE INLINE readWord8 :: (Functor m, Monad m) => Iteratee [Word8] m Word #-}-{-# SPECIALIZE INLINE readWord8 :: (Functor m, Monad m) => Iteratee B.ByteString m Word #-}+{-# INLINE readWord8 #-} -- | Read 2 bytes as a big-endian unsigned Integral readWord16be :: (I.Nullable s, LL.ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a readWord16be = fromIntegral <$> I.endianRead2 I.MSB-{-# SPECIALIZE INLINE readWord16be :: (Functor m, Monad m) => Iteratee [Word8] m Word16 #-}-{-# SPECIALIZE INLINE readWord16be :: (Functor m, Monad m) => Iteratee B.ByteString m Word16 #-}-{-# SPECIALIZE INLINE readWord16be :: (Functor m, Monad m) => Iteratee [Word8] m Word #-}-{-# SPECIALIZE INLINE readWord16be :: (Functor m, Monad m) => Iteratee B.ByteString m Word #-}+{-# INLINE readWord16be #-} -- | Read 4 bytes as a big-endian unsigned Integral readWord32be :: (I.Nullable s, LL.ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a readWord32be = fromIntegral <$> I.endianRead4 I.MSB-{-# SPECIALIZE INLINE readWord32be :: (Functor m, Monad m) => Iteratee [Word8] m Word32 #-}-{-# SPECIALIZE INLINE readWord32be :: (Functor m, Monad m) => Iteratee B.ByteString m Word32 #-}-{-# SPECIALIZE INLINE readWord32be :: (Functor m, Monad m) => Iteratee [Word8] m Word #-}-{-# SPECIALIZE INLINE readWord32be :: (Functor m, Monad m) => Iteratee B.ByteString m Word #-}+{-# INLINE readWord32be #-} -- | Read 8 bytes as a big-endian unsigned Integral readWord64be :: (I.Nullable s, LL.ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a readWord64be = fromIntegral <$> I.endianRead8 I.MSB-{-# SPECIALIZE INLINE readWord64be :: (Functor m, Monad m) => Iteratee [Word8] m Word64 #-}-{-# SPECIALIZE INLINE readWord64be :: (Functor m, Monad m) => Iteratee B.ByteString m Word64 #-}-{-# SPECIALIZE INLINE readWord64be :: (Functor m, Monad m) => Iteratee [Word8] m Word #-}-{-# SPECIALIZE INLINE readWord64be :: (Functor m, Monad m) => Iteratee B.ByteString m Word #-}+{-# INLINE readWord64be #-} -- | Read a variable-length-coded Integer. -- For details of the variable-length coding format, see@@ -166,8 +141,7 @@ readFloat32be = do n <- I.endianRead4 I.MSB return (unsafeCoerce n :: Float)-{-# SPECIALIZE INLINE readFloat32be :: (Functor m, Monad m) => Iteratee [Word8] m Float #-}-{-# SPECIALIZE INLINE readFloat32be :: (Functor m, Monad m) => Iteratee B.ByteString m Float #-}+{-# INLINE readFloat32be #-} -- | Read 8 bytes as a big-endian Double readDouble64be :: (I.Nullable s, LL.ListLike s Word8, Functor m, Monad m)@@ -175,8 +149,7 @@ readDouble64be = do n <- I.endianRead8 I.MSB return (unsafeCoerce n :: Double)-{-# SPECIALIZE INLINE readDouble64be :: (Functor m, Monad m) => Iteratee [Word8] m Double #-}-{-# SPECIALIZE INLINE readDouble64be :: (Functor m, Monad m) => Iteratee B.ByteString m Double #-}+{-# INLINE readDouble64be #-} -- | Read 16 bytes as a big-endian Rational, encoded as an 8 byte -- big endian numerator followed by an 8 byte big endian denominator.
Data/ZoomCache/Numeric/Internal.hs view
@@ -29,17 +29,17 @@ readSummaryNum :: (Functor m, Monad m, ZoomNum a) => Iteratee ByteString m (SummaryData a) readSummaryNum = do- [en,ex,mn,mx] <- replicateM 4 readRaw- [avg,rms] <- replicateM 2 readDouble64be- return (numMkSummary en ex mn mx avg rms)-{-# INLINABLE readSummaryNum #-}+ [!en,!ex,!mn,!mx] <- replicateM 4 readRaw+ [!avg,!rms] <- replicateM 2 readDouble64be+ return $! numMkSummary en ex mn mx avg rms+{-# INLINE readSummaryNum #-} fromSummaryNum :: ZoomNum a => SummaryData a -> Builder fromSummaryNum s = mconcat $ map fromRaw [numEntry s, numExit s, numMin s, numMax s] ++ map fromDouble [numAvg s, numRMS s]-{-# INLINABLE fromSummaryNum #-}+{-# INLINE fromSummaryNum #-} initSummaryNumBounded :: (Bounded a, ZoomNum a) => SampleOffset -> SummaryWork a
zoom-cache.cabal view
@@ -3,7 +3,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version: 1.2.1.0+Version: 1.2.1.1 Synopsis: A streamable, seekable, zoomable cache file format