-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A streamable, seekable, zoomable cache file format -- -- zoom-cache is a fairly simple data file format for storing and -- summarizing streams of time-series data. The purpose of this format is -- to make it easy to quickly generate plots; zooming refers to -- being able to render a window of data, and being able to quickly -- change the bounds of the window: to move around and to zoom in and -- out. -- -- This library provides a monadic writing and an iteratee reading -- interface for zoom-cache files. To build GUI applications, see the -- scope package: -- -- http://hackage.haskell.org/package/scope -- -- What's neat about the zoom-cache format and library? Glad you asked! -- -- -- -- When developing applications that read or write zoom-cache files, it -- should be sufficient to import only the module Data.ZoomCache. @package zoom-cache @version 1.2.1.3 -- | Fixed-length lists. module Data.ZoomCache.NList data NList n a NList :: n -> [a] -> NList n a nListToList :: NList n a -> [a] instance (Show n, Show a) => Show (NList n a) instance (Nat n, Arbitrary a) => Arbitrary (NList n a) instance Typeable a => Typeable (NList n a) instance Eq a => Eq (NList n a) -- | ZoomCache multichannel API module Data.ZoomCache.Multichannel.Common trackTypeMultichannel :: ByteString -- | The minimum and maximum positive, finite floats. module Data.ZoomCache.Numeric.FloatMinMax -- | The minimum positive, denormalized float. floatMin :: RealFloat a => a -- | The maximum denormalized float. floatMaxDenorm :: RealFloat a => a -- | The minimum positive, normalized float. floatMinNorm :: RealFloat a => a -- | The maximum finite float. floatMax :: RealFloat a => a -- | Delta encoding and decoding of numeric values. module Data.ZoomCache.Numeric.Delta -- | Delta encode a list of numbers -- --
--   > deltaEncode [1,2,3,2,4]
--   [1,1,1,-1,2]
--   
deltaEncode :: Num a => [a] -> [a] -- | Delta-decode a list of numbers -- --
--   > deltaDecode [1,1,1,-1,2]
--   [1,2,3,2,4]
--   
deltaDecode :: Num a => [a] -> [a] -- | zoom-cache format specification -- -- Field encoding formats: -- -- int16: 16bit big endian -- -- int32: 32bit big endian -- -- double: big-endian IEEE 754-2008 binary64 (IEEE 754-1985 -- double) module Data.ZoomCache.Format headerMarker :: Word8 -- | Global header: -- --
--    0                   1                   2                   3
--    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Identifier                                                    | 0-3
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           | 4-7
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Version major (int16)         | Version minor (int16)         | 8-11
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | No. tracks (int32)                                            | 12-15
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Modified Julian Day (intVLC)                                  | 16-
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           | ...
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Seconds since midnight Numerator (intVLC)                     | ...
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           | ...
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Seconds since midnight Denominator (intVLC)                   | ...
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           | ...
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   
-- -- The Universal Time corresponding to data timestamp 0 is uniquely given -- by the fields Modified Julian Day, Seconds since midnight -- Numerator and Seconds since midnight Denominator. -- -- The Modified Julian Day is a standard count of days, with zero being -- the day 1858-11-17. Seconds since midnight: 0 <= t <= 86401s -- (because of leap seconds) -- -- If the correspondence to Universal Time is meaningless or unknown when -- writing data, these fields shall be given the special values 0, 0, 0. -- -- When reading, a value of 0 for Seconds since midnight -- Denominator should be interpreted as no corresponding Universal -- Time. -- -- Field encoding formats: -- -- int16: 16bit big endian signed integer -- -- int32: 32bit big endian signed integer -- -- intVLC: Variable-length-coded signed integer globalHeader :: ByteString -- | The major version encoded by this library versionMajor :: Int -- | The minor version encoded by this library versionMinor :: Int -- | Track header: -- --
--    0                   1                   2                   3
--    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Identifier                                                    | 0-3
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           | 4-7
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Track no. (int32)                                             | 8-11
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Reserved                                                |z|d|v| 12-15
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Datarate numerator (int64)                                    | 16-19
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           | 20-23
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Datarate denominator (int64)                                  | 24-27
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           | 28-31
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Length of codec identifier in bytes (int32)                   | 32-35
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Codec identifier                                              | 36-39
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           | 40-
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Length of name in bytes (int32)                               | ...
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Name (UTF-8) ...                                              | ...
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   
-- -- v : Variable data rate flag. 0=CBR, 1=VBR d : Delta -- encode flag. 0=Raw values 1=delta encoded values z : Zlib -- encode flag. 0=uncompressed 1=zlib compressed -- -- Datarate: numerator 0 indicates variable bitrate (all data values are -- timestamped) trackHeader :: ByteString -- | Raw Data Packet header: -- --
--    0                   1                   2                   3
--    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Identifier                                                    | 0-3
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           | 4-7
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Track no. (int32)                                             | 8-11
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Entry Timestamp (int64)                                       | 12-15
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           | 16-19
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Exit TImestamp (int64)                                        | 20-23
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           | 24-27
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Count of data points COUNT (int32)                            | 28-31
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Payload length in bytes (remainder of packet) (int32)         | 32-35
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Data ...                                                      | 36-39
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           | 40-
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Timestamps ...                                                | TS-
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           |
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   
-- -- Timestamps block is only present if VBR (datarate numerator is 0) -- -- TS = 28 + (COUNT * sizeof(Type)) packetHeader :: ByteString -- | Summary Data Packet header: -- --
--    0                   1                   2                   3
--    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Identifier                                                    | 0-3
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           | 4-7
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Track no. (int32)                                             | 8-11
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Level (int32)                                                 | 12-15
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Entry Timestamp (int64)                                       | 16-19
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           | 20-23
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Exit Timestamp (int64)                                        | 24-27
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           | 28-31
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Summary length in bytes (int32)                               | 32-35
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Summary Data ...                                              | 36-
--   
-- -- Some default encodings of Summary Data are provided in modules -- Data.ZoomCache.Numeric.Double and -- Data.ZoomCache.Numeric.Int. summaryHeader :: ByteString module Data.Offset data Offset a Offset :: {-# UNPACK #-} !FileOffset -> !a -> Offset a unwrapOffset :: Offset a -> a instance ListLike s Word8 => ListLike (Offset s) Word8 instance FoldableLL s el => FoldableLL (Offset s) el instance Monoid a => Monoid (Offset a) instance NullPoint a => NullPoint (Offset a) instance Nullable a => Nullable (Offset a) module Data.Iteratee.IO.OffsetFd -- | The enumerator of a POSIX File Descriptor: a variation of -- enumFd that supports RandomIO (seek requests). enumFdRandomOBS :: MonadCatchIO m => Int -> Fd -> Enumerator (Offset ByteString) m a enumFileRandomOBS :: MonadCatchIO m => Int -> FilePath -> Enumerator (Offset ByteString) m a -- | A version of fileDriverFd that supports seeking. fileDriverRandomFdOBS :: MonadCatchIO m => Int -> Iteratee (Offset ByteString) m a -> FilePath -> m a -- | Process a file using the given Iteratee. This function wraps -- enumFdRandom as a convenience. fileDriverRandomOBS :: MonadCatchIO m => Iteratee (Offset ByteString) m a -> FilePath -> m a module Data.Iteratee.Offset tell :: Monad m => Iteratee (Offset ByteString) m FileOffset -- | Run a ByteString iteratee on an (Offset ByteString) input stream convOffset :: Monad m => Iteratee ByteString m a -> Iteratee (Offset ByteString) m a takeBS :: Monad m => Int -> Iteratee (Offset ByteString) m ByteString -- | Types used throughout zoom-cache module Data.ZoomCache.Common newtype TimeStamp TS :: Double -> TimeStamp newtype TimeStampDiff TSDiff :: Double -> TimeStampDiff -- |
--   timeStampDiff (TS t1) (TS t2) = TSDiff (t1 - t2)
--   
timeStampDiff :: TimeStamp -> TimeStamp -> TimeStampDiff timeStampFromSO :: Rational -> SampleOffset -> TimeStamp timeStampFromUTCTime :: UTCTime -> UTCTime -> TimeStamp -- |
--   utcTimeFromTimeStamp base (TS ts) = baseUTC + ts
--   
utcTimeFromTimeStamp :: UTCTime -> TimeStamp -> UTCTime data SampleOffset SO :: {-# UNPACK #-} !Int64 -> SampleOffset unSO :: SampleOffset -> {-# UNPACK #-} !Int64 data SampleOffsetDiff SODiff :: {-# UNPACK #-} !Int64 -> SampleOffsetDiff unSODiff :: SampleOffsetDiff -> {-# UNPACK #-} !Int64 -- |
--   sampleOffsetDiff (SO t1) (SO t2) = SODiff (t1 - t2)
--   
sampleOffsetDiff :: SampleOffset -> SampleOffset -> SampleOffsetDiff -- | Constant or Variable samplerate. For constant samplerate, timestamps -- are implied as incrementing by 1/samplerate For variable samplerate, -- explicit timestamps are attached to each datum, encoded as a separate -- block of SampleOffset in the Raw Data packet. data SampleRateType ConstantSR :: SampleRateType VariableSR :: SampleRateType type TrackNo = Int data Global Global :: Version -> Int -> Maybe UTCTime -> Global version :: Global -> Version noTracks :: Global -> Int baseUTC :: Global -> Maybe UTCTime data Version Version :: !Int -> !Int -> Version instance Eq SampleOffset instance Ord SampleOffset instance Show SampleOffset instance Eq SampleOffsetDiff instance Ord SampleOffsetDiff instance Show SampleOffsetDiff instance Eq Version instance Show Version instance Eq SampleRateType instance Show SampleRateType instance Eq TimeStamp instance Ord TimeStamp instance Show TimeStamp -- | ZoomCache packet and summary types and interfaces module Data.ZoomCache.Types data Codec Codec :: a -> Codec -- | A map of all track numbers to their TrackSpec type TrackMap = IntMap TrackSpec -- | A specification of the type and name of each track data TrackSpec TrackSpec :: !Codec -> !Bool -> !Bool -> !SampleRateType -> {-# UNPACK #-} !Rational -> !ByteString -> TrackSpec specType :: TrackSpec -> !Codec specDeltaEncode :: TrackSpec -> !Bool specZlibCompress :: TrackSpec -> !Bool specSRType :: TrackSpec -> !SampleRateType specRate :: TrackSpec -> {-# UNPACK #-} !Rational specName :: TrackSpec -> !ByteString -- | Identify the tracktype corresponding to a given Codec Identifier. When -- parsing a zoom-cache file, the zoom-cache library will try each of a -- given list [IdentifyTrack]. -- -- The standard zoom-cache instances are provided in -- standardIdentifiers. -- -- When developing your own codecs it is not necessary to build a -- composite IdentifyTrack functions; it is sufficient to -- generate one for each new codec type. A library of related zoom-cache -- codecs should export its own [IdentifyTrack] functions, -- usually called something like mylibIdentifiers. -- -- These can be generated with identifyCodec. type IdentifyCodec = ByteString -> Maybe Codec class Timestampable a timestamp :: Timestampable a => a -> Maybe TimeStamp before :: Timestampable a => Maybe TimeStamp -> a -> Bool class UTCTimestampable a utcTimestamp :: UTCTimestampable a => a -> Maybe UTCTime beforeUTC :: UTCTimestampable a => Maybe UTCTime -> a -> Bool -- | A codec instance must specify a SummaryData type, and implement -- all methods of this class. class Typeable a => ZoomReadable a where data family SummaryData a :: * deltaDecodeRaw = id trackIdentifier :: ZoomReadable a => a -> ByteString readRaw :: (ZoomReadable a, Functor m, Monad m) => Iteratee ByteString m a readSummary :: (ZoomReadable a, Functor m, Monad m) => Iteratee ByteString m (SummaryData a) prettyRaw :: ZoomReadable a => a -> String prettySummaryData :: ZoomReadable a => SummaryData a -> String deltaDecodeRaw :: ZoomReadable a => [a] -> [a] -- | A codec instance must additionally specify a SummaryWork type class ZoomReadable a => ZoomWritable a where data family SummaryWork a :: * deltaEncodeRaw _ = id fromRaw :: ZoomWritable a => a -> Builder fromSummaryData :: ZoomWritable a => SummaryData a -> Builder initSummaryWork :: ZoomWritable a => SampleOffset -> SummaryWork a updateSummaryData :: ZoomWritable a => SampleOffset -> a -> SummaryWork a -> SummaryWork a toSummaryData :: ZoomWritable a => SampleOffsetDiff -> SummaryWork a -> SummaryData a appendSummaryData :: ZoomWritable a => SampleOffsetDiff -> SummaryData a -> SampleOffsetDiff -> SummaryData a -> SummaryData a deltaEncodeRaw :: ZoomWritable a => SummaryWork a -> a -> a data ZoomRaw ZoomRaw :: [a] -> ZoomRaw data ZoomSummary ZoomSummary :: (Summary a) -> ZoomSummary data ZoomSummaryUTC ZoomSummaryUTC :: (SummaryUTC a) -> ZoomSummaryUTC data ZoomSummarySO ZoomSummarySO :: (SummarySO a) -> ZoomSummarySO data ZoomWork ZoomWork :: IntMap (SummarySO a) -> Maybe (SummaryWork a) -> ZoomWork levels :: ZoomWork -> IntMap (SummarySO a) currWork :: ZoomWork -> Maybe (SummaryWork a) data Packet Packet :: {-# UNPACK #-} !TrackNo -> {-# UNPACK #-} !TimeStamp -> {-# UNPACK #-} !TimeStamp -> {-# UNPACK #-} !Int -> !ZoomRaw -> ![TimeStamp] -> Packet packetTrack :: Packet -> {-# UNPACK #-} !TrackNo packetEntry :: Packet -> {-# UNPACK #-} !TimeStamp packetExit :: Packet -> {-# UNPACK #-} !TimeStamp packetCount :: Packet -> {-# UNPACK #-} !Int packetData :: Packet -> !ZoomRaw packetTimeStamps :: Packet -> ![TimeStamp] packetFromPacketSO :: Rational -> PacketSO -> Packet -- | A summary block with samplecounts converted to TimeStamp data Summary a Summary :: {-# UNPACK #-} !TrackNo -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !TimeStamp -> {-# UNPACK #-} !TimeStamp -> !SummaryData a -> Summary a summaryTrack :: Summary a -> {-# UNPACK #-} !TrackNo summaryLevel :: Summary a -> {-# UNPACK #-} !Int summaryEntry :: Summary a -> {-# UNPACK #-} !TimeStamp summaryExit :: Summary a -> {-# UNPACK #-} !TimeStamp summaryData :: Summary a -> !SummaryData a -- | Convert a SummarySo to a Summary, given a samplerate summaryFromSummarySO :: Rational -> SummarySO a -> Summary a data PacketUTC PacketUTC :: {-# UNPACK #-} !TrackNo -> {-# UNPACK #-} !UTCTime -> {-# UNPACK #-} !UTCTime -> {-# UNPACK #-} !Int -> !ZoomRaw -> ![UTCTime] -> PacketUTC packetUTCTrack :: PacketUTC -> {-# UNPACK #-} !TrackNo packetUTCEntry :: PacketUTC -> {-# UNPACK #-} !UTCTime packetUTCExit :: PacketUTC -> {-# UNPACK #-} !UTCTime packetUTCCount :: PacketUTC -> {-# UNPACK #-} !Int packetUTCData :: PacketUTC -> !ZoomRaw packetUTCTimeStamps :: PacketUTC -> ![UTCTime] packetUTCFromPacket :: UTCTime -> Packet -> PacketUTC packetUTCFromPacketSO :: UTCTime -> Rational -> PacketSO -> PacketUTC -- | A summary block with timestamps converted to UTCTime data SummaryUTC a SummaryUTC :: {-# UNPACK #-} !TrackNo -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !UTCTime -> {-# UNPACK #-} !UTCTime -> !SummaryData a -> SummaryUTC a summaryUTCTrack :: SummaryUTC a -> {-# UNPACK #-} !TrackNo summaryUTCLevel :: SummaryUTC a -> {-# UNPACK #-} !Int summaryUTCEntry :: SummaryUTC a -> {-# UNPACK #-} !UTCTime summaryUTCExit :: SummaryUTC a -> {-# UNPACK #-} !UTCTime summaryUTCData :: SummaryUTC a -> !SummaryData a -- | Convert a Summary to a SummaryUTC, given a UTC base time summaryUTCFromSummary :: UTCTime -> Summary a -> SummaryUTC a summaryUTCFromSummarySO :: UTCTime -> Rational -> SummarySO a -> SummaryUTC a data PacketSO PacketSO :: {-# UNPACK #-} !TrackNo -> {-# UNPACK #-} !SampleOffset -> {-# UNPACK #-} !SampleOffset -> {-# UNPACK #-} !Int -> !ZoomRaw -> ![SampleOffset] -> PacketSO packetSOTrack :: PacketSO -> {-# UNPACK #-} !TrackNo packetSOEntry :: PacketSO -> {-# UNPACK #-} !SampleOffset packetSOExit :: PacketSO -> {-# UNPACK #-} !SampleOffset packetSOCount :: PacketSO -> {-# UNPACK #-} !Int packetSOData :: PacketSO -> !ZoomRaw packetSOSampleOffsets :: PacketSO -> ![SampleOffset] -- | A recorded block of summary data data SummarySO a SummarySO :: {-# UNPACK #-} !TrackNo -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !SampleOffset -> {-# UNPACK #-} !SampleOffset -> !SummaryData a -> SummarySO a summarySOTrack :: SummarySO a -> {-# UNPACK #-} !TrackNo summarySOLevel :: SummarySO a -> {-# UNPACK #-} !Int summarySOEntry :: SummarySO a -> {-# UNPACK #-} !SampleOffset summarySOExit :: SummarySO a -> {-# UNPACK #-} !SampleOffset summarySOData :: SummarySO a -> !SummaryData a -- | The duration covered by a summary, in units of 1 / the track's -- datarate summarySODuration :: SummarySO a -> SampleOffsetDiff -- | Global and track headers for a zoom-cache file data CacheFile CacheFile :: Global -> IntMap TrackSpec -> IntMap FileOffset -> CacheFile cfGlobal :: CacheFile -> Global cfSpecs :: CacheFile -> IntMap TrackSpec cfOffsets :: CacheFile -> IntMap FileOffset -- | Create an empty CacheFile using the given Global mkCacheFile :: Global -> CacheFile -- | Determine whether all tracks of a CacheFile are specified fiFull :: CacheFile -> Bool instance Typeable1 SummaryUTC instance Typeable1 Summary instance Typeable1 SummarySO instance Show TrackSpec instance UTCTimestampable ZoomSummaryUTC instance Timestampable ZoomSummary instance UTCTimestampable (SummaryUTC a) instance Timestampable (Summary a) instance UTCTimestampable PacketUTC instance Timestampable Packet instance UTCTimestampable a => UTCTimestampable (Offset a) instance UTCTimestampable a => UTCTimestampable [a] instance UTCTimestampable (UTCTime, a) instance Timestampable a => Timestampable (Offset a) instance Timestampable a => Timestampable [a] instance Timestampable (TimeStamp, a) instance Show Codec -- | Iteratee reading of ZoomCache files. module Data.Iteratee.ZoomCache.Seek seekTimeStamp :: (ListLike s el, Nullable s, NullPoint s, Timestampable el, Monad m) => CacheFile -> Maybe TimeStamp -> Iteratee s m () seekUTCTime :: (ListLike s el, Nullable s, NullPoint s, UTCTimestampable el, Monad m) => Maybe UTCTime -> Iteratee s m () -- | Iteratee reading of ZoomCache files. module Data.Iteratee.ZoomCache.Utils -- | Read 1 byte as a signed Integral readInt8 :: (Nullable s, ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a -- | Read 2 bytes as a big-endian signed Integral readInt16be :: (Nullable s, ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a -- | Read 4 bytes as a big-endian signed Integral readInt32be :: (Nullable s, ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a -- | Read 8 bytes as a big-endian signed Integral readInt64be :: (Nullable s, ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a -- | Read 1 byte as an unsigned Integral readWord8 :: (Nullable s, ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a -- | Read 2 bytes as a big-endian unsigned Integral readWord16be :: (Nullable s, ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a -- | Read 4 bytes as a big-endian unsigned Integral readWord32be :: (Nullable s, ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a -- | Read 8 bytes as a big-endian unsigned Integral readWord64be :: (Nullable s, ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a -- | Read a variable-length-coded Integer. For details of the -- variable-length coding format, see Data.ZoomCache.Numeric.Int. readIntegerVLC :: (Nullable s, ListLike s Word8, Functor m, Monad m) => Iteratee s m Integer -- | Read 4 bytes as a big-endian Float readFloat32be :: (Nullable s, ListLike s Word8, Functor m, Monad m) => Iteratee s m Float -- | Read 8 bytes as a big-endian Double readDouble64be :: (Nullable s, ListLike s Word8, Functor m, Monad m) => Iteratee s m Double -- | Read 16 bytes as a big-endian Rational, encoded as an 8 byte big -- endian numerator followed by an 8 byte big endian denominator. readRational64be :: (Nullable s, ListLike s Word8, Functor m, Monad m) => Iteratee s m Rational readCodec :: (Functor m, Monad m) => [IdentifyCodec] -> Int -> Iteratee (Offset ByteString) m (Maybe Codec) -- | Identifiers for track types of ZoomCache files. module Data.ZoomCache.Identify -- | Generate an IdentifyTrack function for a given type. identifyCodec :: ZoomReadable a => a -> IdentifyCodec -- | Pretty-printing of zoom-cache types module Data.ZoomCache.Pretty -- | Pretty-print a Global prettyGlobal :: Global -> String -- | Pretty-print a TrackSpec prettyTrackSpec :: TrackNo -> TrackSpec -> String -- | Pretty-print a SampleOffset, given a datarate prettyTimeStamp :: TimeStamp -> String -- | Pretty-print a SampleOffset, given a datarate prettySampleOffset :: Rational -> SampleOffset -> String -- | Pretty-print a SummarySO, given a datarate prettySummarySO :: ZoomReadable a => Rational -> SummarySO a -> String -- | Blaze-builder utility functions for writing ZoomCache files. module Blaze.ByteString.Builder.ZoomCache -- | Serialize a TimeStamp in 64bit big endian format. fromSampleOffset :: SampleOffset -> Builder -- | Serialize a Float in big-endian IEEE 754-2008 binary32 format -- (IEEE 754-1985 single format). fromFloat :: Float -> Builder -- | Serialize a Double in big-endian IEEE 754-2008 binary64 format -- (IEEE 754-1985 double format). fromDouble :: Double -> Builder -- | Serialize an Integral in 32bit big endian format. fromIntegral32be :: Integral a => a -> Builder -- | Serialize an Integer in variable-length-coding format For -- details of the variable-length coding format, see -- Data.ZoomCache.Numeric.Int. fromIntegerVLC :: Integer -> Builder -- | Serialize a Rational as a sequence of two 64bit big endian -- format integers. fromRational64 :: Rational -> Builder -- | Writing of ZoomCache files. module Data.ZoomCache.Write -- | The ZoomWrite class provides write, a method to write a Haskell -- value to an open ZoomCache file. class ZoomWrite t write :: ZoomWrite t => TrackNo -> t -> ZoomW () writeData :: (Typeable a, ZoomWrite a, ZoomWritable a) => TrackNo -> a -> ZoomW () writeDataVBR :: (Typeable a, ZoomWrite a, ZoomWritable a) => TrackNo -> (SampleOffset, a) -> ZoomW () writeDataTS :: (Typeable a, ZoomWrite a, ZoomWritable a) => TrackNo -> (TimeStamp, a) -> ZoomW () -- | A StateT IO monad for writing a ZoomCache file type ZoomW = StateT ZoomWHandle IO -- | Run a ZoomW () action on a given file handle, using the -- specified TrackMap specification withFileWrite :: TrackMap -> Maybe UTCTime -> Bool -> ZoomW () -> FilePath -> IO () -- | Force a flush of ZoomCache summary blocks to disk. It is not usually -- necessary to call this function as summary blocks are transparently -- written at regular intervals. flush :: ZoomW () data ZoomWHandle -- | Open a new ZoomCache file for writing, using a specified -- TrackMap. openWrite :: TrackMap -> Maybe UTCTime -> Bool -> FilePath -> IO ZoomWHandle closeWrite :: ZoomWHandle -> IO () -- | Query the maximum number of data points to buffer for a given track -- before forcing a flush of all buffered data and summaries. watermark :: TrackNo -> ZoomW (Maybe Int) -- | Set the maximum number of data points to buffer for a given track -- before forcing a flush of all buffered data and summaries. setWatermark :: TrackNo -> Int -> ZoomW () -- | This module re-exports the required interfaces and some useful -- functions for developing zoom-cache codecs. -- -- To implement a codec, specify SummaryData and -- SummaryWork types, and implement the methods of the -- ZoomReadable and ZoomWritable classes. -- -- For sample implementations, read the source of the provided instances -- Data.ZoomCache.Numeric.Int and -- Data.ZoomCache.Numeric.Double. module Data.ZoomCache.Codec -- | A codec instance must specify a SummaryData type, and implement -- all methods of this class. class Typeable a => ZoomReadable a where data family SummaryData a :: * deltaDecodeRaw = id trackIdentifier :: ZoomReadable a => a -> ByteString readRaw :: (ZoomReadable a, Functor m, Monad m) => Iteratee ByteString m a readSummary :: (ZoomReadable a, Functor m, Monad m) => Iteratee ByteString m (SummaryData a) prettyRaw :: ZoomReadable a => a -> String prettySummaryData :: ZoomReadable a => SummaryData a -> String deltaDecodeRaw :: ZoomReadable a => [a] -> [a] -- | A codec instance must additionally specify a SummaryWork type class ZoomReadable a => ZoomWritable a where data family SummaryWork a :: * deltaEncodeRaw _ = id fromRaw :: ZoomWritable a => a -> Builder fromSummaryData :: ZoomWritable a => SummaryData a -> Builder initSummaryWork :: ZoomWritable a => SampleOffset -> SummaryWork a updateSummaryData :: ZoomWritable a => SampleOffset -> a -> SummaryWork a -> SummaryWork a toSummaryData :: ZoomWritable a => SampleOffsetDiff -> SummaryWork a -> SummaryData a appendSummaryData :: ZoomWritable a => SampleOffsetDiff -> SummaryData a -> SampleOffsetDiff -> SummaryData a -> SummaryData a deltaEncodeRaw :: ZoomWritable a => SummaryWork a -> a -> a -- | The ZoomWrite class provides write, a method to write a Haskell -- value to an open ZoomCache file. class ZoomWrite t write :: ZoomWrite t => TrackNo -> t -> ZoomW () -- | Identify the tracktype corresponding to a given Codec Identifier. When -- parsing a zoom-cache file, the zoom-cache library will try each of a -- given list [IdentifyTrack]. -- -- The standard zoom-cache instances are provided in -- standardIdentifiers. -- -- When developing your own codecs it is not necessary to build a -- composite IdentifyTrack functions; it is sufficient to -- generate one for each new codec type. A library of related zoom-cache -- codecs should export its own [IdentifyTrack] functions, -- usually called something like mylibIdentifiers. -- -- These can be generated with identifyCodec. type IdentifyCodec = ByteString -> Maybe Codec -- | Generate an IdentifyTrack function for a given type. identifyCodec :: ZoomReadable a => a -> IdentifyCodec -- | Read 1 byte as a signed Integral readInt8 :: (Nullable s, ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a -- | Read 2 bytes as a big-endian signed Integral readInt16be :: (Nullable s, ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a -- | Read 4 bytes as a big-endian signed Integral readInt32be :: (Nullable s, ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a -- | Read 8 bytes as a big-endian signed Integral readInt64be :: (Nullable s, ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a -- | Read 1 byte as an unsigned Integral readWord8 :: (Nullable s, ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a -- | Read 2 bytes as a big-endian unsigned Integral readWord16be :: (Nullable s, ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a -- | Read 4 bytes as a big-endian unsigned Integral readWord32be :: (Nullable s, ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a -- | Read 8 bytes as a big-endian unsigned Integral readWord64be :: (Nullable s, ListLike s Word8, Functor m, Monad m, Integral a) => Iteratee s m a -- | Read a variable-length-coded Integer. For details of the -- variable-length coding format, see Data.ZoomCache.Numeric.Int. readIntegerVLC :: (Nullable s, ListLike s Word8, Functor m, Monad m) => Iteratee s m Integer -- | Read 4 bytes as a big-endian Float readFloat32be :: (Nullable s, ListLike s Word8, Functor m, Monad m) => Iteratee s m Float -- | Read 8 bytes as a big-endian Double readDouble64be :: (Nullable s, ListLike s Word8, Functor m, Monad m) => Iteratee s m Double -- | Read 16 bytes as a big-endian Rational, encoded as an 8 byte big -- endian numerator followed by an 8 byte big endian denominator. readRational64be :: (Nullable s, ListLike s Word8, Functor m, Monad m) => Iteratee s m Rational writeData :: (Typeable a, ZoomWrite a, ZoomWritable a) => TrackNo -> a -> ZoomW () writeDataVBR :: (Typeable a, ZoomWrite a, ZoomWritable a) => TrackNo -> (SampleOffset, a) -> ZoomW () writeDataTS :: (Typeable a, ZoomWrite a, ZoomWritable a) => TrackNo -> (TimeStamp, a) -> ZoomW () -- | A StateT IO monad for writing a ZoomCache file type ZoomW = StateT ZoomWHandle IO -- | Serialize a Rational as a sequence of two 64bit big endian -- format integers. fromRational64 :: Rational -> Builder -- | Serialize an Integral in 32bit big endian format. fromIntegral32be :: Integral a => a -> Builder -- | Serialize an Integer in variable-length-coding format For -- details of the variable-length coding format, see -- Data.ZoomCache.Numeric.Int. fromIntegerVLC :: Integer -> Builder -- | Serialize a Float in big-endian IEEE 754-2008 binary32 format -- (IEEE 754-1985 single format). fromFloat :: Float -> Builder -- | Serialize a Double in big-endian IEEE 754-2008 binary64 format -- (IEEE 754-1985 double format). fromDouble :: Double -> Builder data Codec newtype TimeStamp TS :: Double -> TimeStamp newtype TimeStampDiff TSDiff :: Double -> TimeStampDiff -- |
--   timeStampDiff (TS t1) (TS t2) = TSDiff (t1 - t2)
--   
timeStampDiff :: TimeStamp -> TimeStamp -> TimeStampDiff timeStampFromSO :: Rational -> SampleOffset -> TimeStamp data SampleOffset SO :: {-# UNPACK #-} !Int64 -> SampleOffset unSO :: SampleOffset -> {-# UNPACK #-} !Int64 data SampleOffsetDiff SODiff :: {-# UNPACK #-} !Int64 -> SampleOffsetDiff unSODiff :: SampleOffsetDiff -> {-# UNPACK #-} !Int64 -- |
--   sampleOffsetDiff (SO t1) (SO t2) = SODiff (t1 - t2)
--   
sampleOffsetDiff :: SampleOffset -> SampleOffset -> SampleOffsetDiff type TrackNo = Int -- | Default codec implementation for values of type Bool. Elements of type -- Bool are useful for recording observations of binary events. -- -- This module implements the interfaces documented in -- Data.ZoomCache.Codec. -- -- The table below describes the encoding of SummaryData for Bool. -- --
--   | ...                                                           |   -35
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Expected value (double)                                       | 36-39
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | ...                                                           | 40-43
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   
-- -- Field encoding formats: -- -- double: big-endian IEEE 754-2008 binary64 (IEEE 754-1985 -- double) module Data.ZoomCache.Bool instance ZoomWritable Bool instance ZoomWrite (TimeStamp, Bool) instance ZoomWrite (SampleOffset, Bool) instance ZoomWrite Bool instance ZoomReadable Bool -- | Default codec implementation for values of type (). Elements of type -- () are useful for marking events, and variable rate tracks written -- with type (SampleOffset, ()) are useful for recording times of events. -- -- This module implements the interfaces documented in -- Data.ZoomCache.Codec. -- -- As elements of type () contain no unique information it is sufficient -- to record only a count of elements which occur within each packet. -- -- No raw data is encoded for tracks of type () as the raw data packet -- header already includes a count of elements. This is implemented by -- specifying const mempty) as the Builder and (return ()) -- as the reader. -- -- The table below describes the encoding of SummaryData for (). -- --
--   | ...                                                           |   -35
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Count (int32)                                                 | 36-39
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   
-- -- Field encoding formats: -- -- int32: 32bit big endian module Data.ZoomCache.Unit instance ZoomWritable () instance ZoomWrite (TimeStamp, ()) instance ZoomWrite (SampleOffset, ()) instance ZoomWrite () instance ZoomReadable () -- | Default codec implementation for multichannel values of type (NList n -- a). -- -- This module implements the interfaces documented in -- Data.ZoomCache.Codec. -- -- Multichannel SummaryData is simply a concatenation of n blocks of -- SummaryData for type a. module Data.ZoomCache.Multichannel.NList summaryNListToList :: Summary (NList n a) -> [Summary a] summaryUTCNListToList :: SummaryUTC (NList n a) -> [SummaryUTC a] instance (Nat n, ZoomWritable a) => ZoomWritable (NList n a) instance (Nat n, ZoomWrite a, ZoomWritable a) => ZoomWrite (SampleOffset, NList n a) instance (Nat n, ZoomWrite a, ZoomWritable a) => ZoomWrite (NList n a) instance (Nat n, ZoomReadable a) => ZoomReadable (NList n a) -- | ZoomCache multichannel API module Data.ZoomCache.Multichannel.Internal supportMultichannel :: [IdentifyCodec] -> [IdentifyCodec] identifyCodecMultichannel :: [IdentifyCodec] -> IdentifyCodec -- | Create a track map for a stream of a given type, as track no. 1 oneTrackMultichannel :: ZoomReadable a => Int -> a -> Bool -> Bool -> SampleRateType -> Rational -> ByteString -> TrackMap mkTrackSpecMultichannel :: ZoomReadable a => Int -> a -> Bool -> Bool -> SampleRateType -> Rational -> ByteString -> TrackSpec -- | Iteratee reading of ZoomCache files. -- -- A typical usage, using the iteratee iter to process the level -- 3 summaries from the track called "rainfall": -- --
--   I.fileDriverRandom (enumCacheFile standardIdentifiers .
--       I.joinI . filterTracksByName ["rainfall"] .
--       I.joinI . enumSummaryLevel 3 $ iter) filename
--   
-- -- Similarly, using the iteratee rawIter to process the raw data -- from the track called "rainfall": -- --
--   I.fileDriverRandom (enumCacheFile standardIdentifiers .
--       I.joinI . filterTracksByName ["rainfall"] .
--       I.joinI . enumPackets $ rawIter) filename
--   
module Data.Iteratee.ZoomCache data Block Block :: CacheFile -> TrackNo -> !BlockData -> Block blkFile :: Block -> CacheFile blkTrack :: Block -> TrackNo blkData :: Block -> !BlockData data BlockData BlockPacket :: !PacketSO -> BlockData BlockSummary :: !ZoomSummarySO -> BlockData -- | An enumeratee of a zoom-cache file, from the global header onwards. -- The global and track headers will be transparently read, and the -- CacheFile visible in the Block elements. enumCacheFile :: (Functor m, MonadIO m) => [IdentifyCodec] -> Enumeratee (Offset ByteString) [Offset Block] m a -- | Read the summary of an entire track. wholeTrackSummary :: (Functor m, MonadIO m) => TrackNo -> Iteratee [Offset Block] m (TrackSpec, ZoomSummary) -- | Read the summary of an entire track. wholeTrackSummaryUTC :: (Functor m, MonadIO m) => TrackNo -> Iteratee [Offset Block] m (TrackSpec, Maybe ZoomSummaryUTC) -- | Parse only the global and track headers of a zoom-cache file, -- returning a CacheFile iterHeaders :: (Functor m, Monad m) => [IdentifyCodec] -> Iteratee (Offset ByteString) m CacheFile -- | An iteratee of zoom-cache data, after global and track headers have -- been read, or if the CacheFile has been acquired elsewhere. enumBlock :: (Functor m, MonadIO m) => CacheFile -> Enumeratee (Offset ByteString) [Offset Block] m a -- | A version of enumBlock which won't fail with an EofException if the -- last bit is incomplete (perhaps still being written to). enumBlockIncomplete :: (Functor m, MonadIO m) => CacheFile -> Enumeratee (Offset ByteString) [Offset Block] m a -- | An enumeratee of zoom-cache data, after global and track headers have -- been read, or if the CacheFile has been acquired elsewhere. -- This version skips parsing of all tracks other than the specified -- TrackNo. -- -- This function should only be used in applications where only one track -- is used from a file; if you need to process multiple tracks -- independently then give each an iteratee filtered by filterTracks or -- filterTracksByName, and run these in parallel on the output of -- enumCacheFile or enumBlock. Using this function multiple -- times in parallel will duplicate some parsing. enumBlockTrackNo :: (Functor m, MonadIO m) => CacheFile -> TrackNo -> Enumeratee (Offset ByteString) [Offset Block] m a seekTimeStamp :: (ListLike s el, Nullable s, NullPoint s, Timestampable el, Monad m) => CacheFile -> Maybe TimeStamp -> Iteratee s m () seekUTCTime :: (ListLike s el, Nullable s, NullPoint s, UTCTimestampable el, Monad m) => Maybe UTCTime -> Iteratee s m () -- | Filter just the raw data enumPackets :: (Functor m, Monad m) => Enumeratee [Offset Block] [Packet] m a -- | Filter just the raw data, timestamped by UTC enumPacketsUTC :: (Functor m, Monad m) => Enumeratee [Offset Block] [PacketUTC] m a -- | Filter summaries at a particular summary level enumSummaryLevel :: (Functor m, Monad m) => Int -> Enumeratee [Offset Block] [ZoomSummary] m a -- | Filter summaries at all levels enumSummaries :: (Functor m, Monad m) => Enumeratee [Offset Block] [ZoomSummary] m a -- | Filter summaries at a particular summary level enumSummaryUTCLevel :: (Functor m, Monad m) => Int -> Enumeratee [Offset Block] [ZoomSummaryUTC] m a -- | Filter summaries at all levels enumSummariesUTC :: (Functor m, Monad m) => Enumeratee [Offset Block] [ZoomSummaryUTC] m a -- | Filter to a given list of track names filterTracksByName :: (Functor m, Monad m) => CacheFile -> [ByteString] -> Enumeratee [Offset Block] [Offset Block] m a -- | Filter to a given list of track numbers filterTracks :: (Functor m, Monad m) => [TrackNo] -> Enumeratee [Offset Block] [Offset Block] m a -- | Filter just the raw data enumPacketSOs :: (Functor m, Monad m) => Enumeratee [Offset Block] [PacketSO] m a -- | Filter summaries at a particular summary level enumSummarySOLevel :: (Functor m, Monad m) => Int -> Enumeratee [Offset Block] [ZoomSummarySO] m a -- | Filter summaries at all levels enumSummarySOs :: (Functor m, Monad m) => Enumeratee [Offset Block] [ZoomSummarySO] m a -- | Filter raw data enumCTPSO :: (Functor m, Monad m) => Enumeratee [Offset Block] [(CacheFile, TrackNo, PacketSO)] m a -- | Filter summaries enumCTSO :: (Functor m, Monad m) => Enumeratee [Offset Block] [(CacheFile, TrackNo, ZoomSummarySO)] m a instance Timestampable Block module Data.ZoomCache.Numeric.Types class (Ord a, Real a, ZoomReadable a, ZoomWritable a) => ZoomNum a numEntry :: ZoomNum a => SummaryData a -> a numExit :: ZoomNum a => SummaryData a -> a numMin :: ZoomNum a => SummaryData a -> a numMax :: ZoomNum a => SummaryData a -> a numAvg :: ZoomNum a => SummaryData a -> Double numRMS :: ZoomNum a => SummaryData a -> Double numWorkSO :: ZoomNum a => SummaryWork a -> SampleOffset numWorkEntry :: ZoomNum a => SummaryWork a -> Maybe a numWorkExit :: ZoomNum a => SummaryWork a -> a numWorkMin :: ZoomNum a => SummaryWork a -> a numWorkMax :: ZoomNum a => SummaryWork a -> a numWorkSum :: ZoomNum a => SummaryWork a -> Double numWorkSumSq :: ZoomNum a => SummaryWork a -> Double numMkSummary :: ZoomNum a => a -> a -> a -> a -> Double -> Double -> SummaryData a numMkSummaryWork :: ZoomNum a => SampleOffset -> Maybe a -> a -> a -> a -> Double -> Double -> SummaryWork a module Data.ZoomCache.Numeric.Internal readSummaryNum :: (Functor m, Monad m, ZoomNum a) => Iteratee ByteString m (SummaryData a) fromSummaryNum :: ZoomNum a => SummaryData a -> Builder initSummaryNumBounded :: (Bounded a, ZoomNum a) => SampleOffset -> SummaryWork a mkSummaryNum :: ZoomNum a => SampleOffsetDiff -> SummaryWork a -> SummaryData a appendSummaryNum :: ZoomNum a => SampleOffsetDiff -> SummaryData a -> SampleOffsetDiff -> SummaryData a -> SummaryData a updateSummaryNum :: ZoomNum a => SampleOffset -> a -> SummaryWork a -> SummaryWork a deltaDecodeNum :: ZoomNum a => [a] -> [a] deltaEncodeNum :: ZoomNum a => SummaryWork a -> a -> a -- | Default codec implementation for values of type Float and Double. This -- module implements the interfaces documented in -- Data.ZoomCache.Codec. View the module source for enlightenment. -- -- The table below describes the encoding of SummaryData for Float. -- --
--   | ...                                                           |   -35
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Entry (float)                                                 | 36-39
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Exit (float)                                                  | 40-43
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Min (float)                                                   | 44-47
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Max (float)                                                   | 48-51
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Avg (float)                                                   | 52-55
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | RMS (float)                                                   | 56-59
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   
-- -- The table below describes the encoding of SummaryData for Double. -- --
--   | ...                                                           |   -35
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Entry (double)                                                | 36-39
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 40-43
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Exit (double)                                                 | 44-47
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 48-51
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Min (double)                                                  | 52-55
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 56-59
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Max (double)                                                  | 60-63
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 64-67
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Avg (double)                                                  | 68-71
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 72-75
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | RMS (double)                                                  | 76-79
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 80-83
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   
-- -- Field encoding formats: -- -- float: big-endian IEEE 754-2008 binary32 (IEEE 754-1985 -- single) double: big-endian IEEE 754-2008 binary64 (IEEE -- 754-1985 double) module Data.ZoomCache.Numeric.IEEE754 instance ZoomNum Double instance ZoomWritable Double instance ZoomWrite (TimeStamp, Double) instance ZoomWrite (SampleOffset, Double) instance ZoomWrite Double instance ZoomReadable Double instance ZoomNum Float instance ZoomWritable Float instance ZoomWrite (TimeStamp, Float) instance ZoomWrite (SampleOffset, Float) instance ZoomWrite Float instance ZoomReadable Float -- | ZoomCache track specification module Data.ZoomCache.TrackSpec setCodec :: ZoomReadable a => a -> TrackSpec -> TrackSpec setCodecMultichannel :: ZoomReadable a => Int -> a -> TrackSpec -> TrackSpec mkTrackSpec :: ZoomReadable a => a -> Bool -> Bool -> SampleRateType -> Rational -> ByteString -> TrackSpec -- | Create a track map for a stream of a given type, as track no. 1 oneTrack :: ZoomReadable a => a -> Bool -> Bool -> SampleRateType -> Rational -> ByteString -> TrackMap instance Default TrackSpec -- | Default codec implementation for values of type Int. This module -- implements the interfaces documented in Data.ZoomCache.Codec. -- View the module source for enlightenment. -- -- The table below describes the encoding of SummaryData for Int8: -- --
--   | ...                                                           |   -35
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Entry (int8)  | Exit (int8)   | Min (int8)    | Max (int8)    | 36-39
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Avg (double)                                                  | 40-43
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 44-47
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | RMS (double)                                                  | 48-51
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   
-- -- The table below describes the encoding of SummaryData for Int16: -- --
--   | ...                                                           |   -35
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Entry (int16)                 | Exit (int16)                  | 36-39
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Min (int16)                   | Max (int16)                   | 40-43
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Avg (double)                                                  | 44-47
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 48-51
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | RMS (double)                                                  | 52-55
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 56-59
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   
-- -- The table below describes the encoding of SummaryData for Int32: -- --
--   | ...                                                           |   -35
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Entry (int32)                                                 | 36-39
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Exit (int32)                                                  | 40-43
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Min (int32)                                                   | 44-47
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Max (int32)                                                   | 48-51
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Avg (double)                                                  | 52-55
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 56-59
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | RMS (double)                                                  | 60-63
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 64-67
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   
-- -- The table below describes the encoding of SummaryData for Int64: -- --
--   | ...                                                           |   -35
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Entry (int64)                                                 | 36-39
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 40-43
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Exit (int64)                                                  | 44-47
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 48-51
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Min (int64)                                                   | 52-55
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 56-59
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Max (int64)                                                   | 60-63
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 64-67
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Avg (double)                                                  | 68-71
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 72-75
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | RMS (double)                                                  | 76-79
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 80-83
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   
-- -- SummaryData for Int and Integer is encoded as the following sequence: -- --
--   Entry (intVLC)
--   Exit (intVLC)
--   Min (intVLC)
--   Max (intVLC)
--   Avg (double)
--   RMS (double)
--   
-- -- Field encoding formats: -- -- int8: 8bit signed integer -- -- int16: 16bit big endian signed integer -- -- int32: 32bit big endian signed integer -- -- int64: 32bit big endian signed integer -- -- intVLC: Variable-length-coded signed integer -- -- double: big-endian IEEE 754-2008 binary64 (IEEE 754-1985 -- double) -- -- Variable-length coding format: -- -- zoom-cache includes a simple variable-length coding scheme for signed -- integers. When decoding, single bytes are read at a time. If the high -- bit is set, the next byte is also read. The lower 7 bits of each byte -- contain data. Decoding continues by reading single bytes until a byte -- is read with the high bit zero. -- -- The first byte of a variable-length coded integer contain a sign bit -- and the lowest 6 bits of the value. This byte is encoded as: -- --
--    0 1 2 3 4 5 6 7
--   +-+-+-+-+-+-+-+-+
--   |s| d[0]-d[5] |c|
--   +-+-+-+-+-+-+-+-+
--   
-- -- Subsequent bytes encode bits 6-12, 13-19, ... of the value: -- --
--    0 1 2 3 4 5 6 7
--   +-+-+-+-+-+-+-+-+
--   | d[n]-d[n+6] |c|
--   +-+-+-+-+-+-+-+-+
--   
-- -- where n = 6, 13, 20, ... -- -- s: sign, 1 = negative, 0 = non-negative -- -- c: continue flag, 1 = continue reading next byte, 0 = stop module Data.ZoomCache.Numeric.Int instance ZoomNum Integer instance ZoomWritable Integer instance ZoomWrite (TimeStamp, Integer) instance ZoomWrite (SampleOffset, Integer) instance ZoomWrite Integer instance ZoomReadable Integer instance ZoomNum Int64 instance ZoomWritable Int64 instance ZoomWrite (TimeStamp, Int64) instance ZoomWrite (SampleOffset, Int64) instance ZoomWrite Int64 instance ZoomReadable Int64 instance ZoomNum Int32 instance ZoomWritable Int32 instance ZoomWrite (TimeStamp, Int32) instance ZoomWrite (SampleOffset, Int32) instance ZoomWrite Int32 instance ZoomReadable Int32 instance ZoomNum Int16 instance ZoomWritable Int16 instance ZoomWrite (TimeStamp, Int16) instance ZoomWrite (SampleOffset, Int16) instance ZoomWrite Int16 instance ZoomReadable Int16 instance ZoomNum Int8 instance ZoomWritable Int8 instance ZoomWrite (TimeStamp, Int8) instance ZoomWrite (SampleOffset, Int8) instance ZoomWrite Int8 instance ZoomReadable Int8 instance ZoomNum Int instance ZoomWritable Int instance ZoomWrite (TimeStamp, Int) instance ZoomWrite (SampleOffset, Int) instance ZoomWrite Int instance ZoomReadable Int -- | Default codec implementation for values of type Word. This module -- implements the interfaces documented in Data.ZoomCache.Codec. -- View the module source for enlightenment. -- -- The table below describes the encoding of SummaryData for Word8: -- --
--   | ...                                                           |   -35
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Entry (word8) | Exit (word8)  | Min (word8)   | Max (word8)   | 36-39
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Avg (double)                                                  | 40-43
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 44-47
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | RMS (double)                                                  | 48-51
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   
-- -- The table below describes the encoding of SummaryData for Word16: -- --
--   | ...                                                           |   -35
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Entry (word16)                | Exit (word16)                 | 36-39
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Min (word16)                  | Max (word16)                  | 40-43
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Avg (double)                                                  | 44-47
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 48-51
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | RMS (double)                                                  | 52-55
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 56-59
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   
-- -- The table below describes the encoding of SummaryData for Word32: -- --
--   | ...                                                           |   -35
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Entry (word32)                                                | 36-39
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Exit (word32)                                                 | 40-43
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Min (word32)                                                  | 44-47
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Max (word32)                                                  | 48-51
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Avg (double)                                                  | 52-55
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 56-59
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | RMS (double)                                                  | 60-63
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 64-67
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   
-- -- The table below describes the encoding of SummaryData for Word64: -- --
--   | ...                                                           |   -35
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Entry (word64)                                                | 36-39
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 40-43
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Exit (word64)                                                 | 44-47
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 48-51
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Min (word64)                                                  | 52-55
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 56-59
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Max (word64)                                                  | 60-63
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 64-67
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | Avg (double)                                                  | 68-71
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 72-75
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   | RMS (double)                                                  | 76-79
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   |                                                               | 80-83
--   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
--   
-- -- SummaryData for Word is encoded as the following sequence, in which -- the variable-length coded sign bit is always zero: -- --
--   Entry (intVLC)
--   Exit (intVLC)
--   Min (intVLC)
--   Max (intVLC)
--   Avg (double)
--   RMS (double)
--   
-- -- Field encoding formats: -- -- word8: 8bit unsigned integer -- -- word16: 16bit big endian unsigned integer -- -- word32: 32bit big endian unsigned integer -- -- word64: 32bit big endian unsigned integer -- -- intVLC: Variable-length-coded signed integer -- -- double: big-endian IEEE 754-2008 binary64 (IEEE 754-1985 -- double) -- -- For details of the variable-length coding format, see -- Data.ZoomCache.Numeric.Int. module Data.ZoomCache.Numeric.Word instance ZoomNum Word64 instance ZoomWritable Word64 instance ZoomWrite (TimeStamp, Word64) instance ZoomWrite (SampleOffset, Word64) instance ZoomWrite Word64 instance ZoomReadable Word64 instance ZoomNum Word32 instance ZoomWritable Word32 instance ZoomWrite (TimeStamp, Word32) instance ZoomWrite (SampleOffset, Word32) instance ZoomWrite Word32 instance ZoomReadable Word32 instance ZoomNum Word16 instance ZoomWritable Word16 instance ZoomWrite (TimeStamp, Word16) instance ZoomWrite (SampleOffset, Word16) instance ZoomWrite Word16 instance ZoomReadable Word16 instance ZoomNum Word8 instance ZoomWritable Word8 instance ZoomWrite (TimeStamp, Word8) instance ZoomWrite (SampleOffset, Word8) instance ZoomWrite Word8 instance ZoomReadable Word8 instance ZoomNum Word instance ZoomWritable Word instance ZoomWrite (TimeStamp, Word) instance ZoomWrite (SampleOffset, Word) instance ZoomWrite Word instance ZoomReadable Word -- | API for implementing ZoomCache applications module Data.ZoomCache newtype TimeStamp TS :: Double -> TimeStamp newtype TimeStampDiff TSDiff :: Double -> TimeStampDiff -- |
--   timeStampDiff (TS t1) (TS t2) = TSDiff (t1 - t2)
--   
timeStampDiff :: TimeStamp -> TimeStamp -> TimeStampDiff timeStampFromSO :: Rational -> SampleOffset -> TimeStamp class Timestampable a timestamp :: Timestampable a => a -> Maybe TimeStamp before :: Timestampable a => Maybe TimeStamp -> a -> Bool class UTCTimestampable a utcTimestamp :: UTCTimestampable a => a -> Maybe UTCTime beforeUTC :: UTCTimestampable a => Maybe UTCTime -> a -> Bool timeStampFromUTCTime :: UTCTime -> UTCTime -> TimeStamp -- |
--   utcTimeFromTimeStamp base (TS ts) = baseUTC + ts
--   
utcTimeFromTimeStamp :: UTCTime -> TimeStamp -> UTCTime data SampleOffset SO :: {-# UNPACK #-} !Int64 -> SampleOffset unSO :: SampleOffset -> {-# UNPACK #-} !Int64 type TrackNo = Int data Codec Codec :: a -> Codec -- | Identify the tracktype corresponding to a given Codec Identifier. When -- parsing a zoom-cache file, the zoom-cache library will try each of a -- given list [IdentifyTrack]. -- -- The standard zoom-cache instances are provided in -- standardIdentifiers. -- -- When developing your own codecs it is not necessary to build a -- composite IdentifyTrack functions; it is sufficient to -- generate one for each new codec type. A library of related zoom-cache -- codecs should export its own [IdentifyTrack] functions, -- usually called something like mylibIdentifiers. -- -- These can be generated with identifyCodec. type IdentifyCodec = ByteString -> Maybe Codec -- | Constant or Variable samplerate. For constant samplerate, timestamps -- are implied as incrementing by 1/samplerate For variable samplerate, -- explicit timestamps are attached to each datum, encoded as a separate -- block of SampleOffset in the Raw Data packet. data SampleRateType ConstantSR :: SampleRateType VariableSR :: SampleRateType data Global Global :: Version -> Int -> Maybe UTCTime -> Global version :: Global -> Version noTracks :: Global -> Int baseUTC :: Global -> Maybe UTCTime -- | Global and track headers for a zoom-cache file data CacheFile CacheFile :: Global -> IntMap TrackSpec -> IntMap FileOffset -> CacheFile cfGlobal :: CacheFile -> Global cfSpecs :: CacheFile -> IntMap TrackSpec cfOffsets :: CacheFile -> IntMap FileOffset -- | A codec instance must specify a SummaryData type, and implement -- all methods of this class. class Typeable a => ZoomReadable a where data family SummaryData a :: * deltaDecodeRaw = id trackIdentifier :: ZoomReadable a => a -> ByteString readRaw :: (ZoomReadable a, Functor m, Monad m) => Iteratee ByteString m a readSummary :: (ZoomReadable a, Functor m, Monad m) => Iteratee ByteString m (SummaryData a) prettyRaw :: ZoomReadable a => a -> String prettySummaryData :: ZoomReadable a => SummaryData a -> String deltaDecodeRaw :: ZoomReadable a => [a] -> [a] data ZoomRaw ZoomRaw :: [a] -> ZoomRaw data ZoomSummary ZoomSummary :: (Summary a) -> ZoomSummary data Packet Packet :: {-# UNPACK #-} !TrackNo -> {-# UNPACK #-} !TimeStamp -> {-# UNPACK #-} !TimeStamp -> {-# UNPACK #-} !Int -> !ZoomRaw -> ![TimeStamp] -> Packet packetTrack :: Packet -> {-# UNPACK #-} !TrackNo packetEntry :: Packet -> {-# UNPACK #-} !TimeStamp packetExit :: Packet -> {-# UNPACK #-} !TimeStamp packetCount :: Packet -> {-# UNPACK #-} !Int packetData :: Packet -> !ZoomRaw packetTimeStamps :: Packet -> ![TimeStamp] -- | A summary block with samplecounts converted to TimeStamp data Summary a Summary :: {-# UNPACK #-} !TrackNo -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !TimeStamp -> {-# UNPACK #-} !TimeStamp -> !SummaryData a -> Summary a summaryTrack :: Summary a -> {-# UNPACK #-} !TrackNo summaryLevel :: Summary a -> {-# UNPACK #-} !Int summaryEntry :: Summary a -> {-# UNPACK #-} !TimeStamp summaryExit :: Summary a -> {-# UNPACK #-} !TimeStamp summaryData :: Summary a -> !SummaryData a data ZoomSummaryUTC ZoomSummaryUTC :: (SummaryUTC a) -> ZoomSummaryUTC data PacketUTC PacketUTC :: {-# UNPACK #-} !TrackNo -> {-# UNPACK #-} !UTCTime -> {-# UNPACK #-} !UTCTime -> {-# UNPACK #-} !Int -> !ZoomRaw -> ![UTCTime] -> PacketUTC packetUTCTrack :: PacketUTC -> {-# UNPACK #-} !TrackNo packetUTCEntry :: PacketUTC -> {-# UNPACK #-} !UTCTime packetUTCExit :: PacketUTC -> {-# UNPACK #-} !UTCTime packetUTCCount :: PacketUTC -> {-# UNPACK #-} !Int packetUTCData :: PacketUTC -> !ZoomRaw packetUTCTimeStamps :: PacketUTC -> ![UTCTime] -- | A summary block with timestamps converted to UTCTime data SummaryUTC a SummaryUTC :: {-# UNPACK #-} !TrackNo -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !UTCTime -> {-# UNPACK #-} !UTCTime -> !SummaryData a -> SummaryUTC a summaryUTCTrack :: SummaryUTC a -> {-# UNPACK #-} !TrackNo summaryUTCLevel :: SummaryUTC a -> {-# UNPACK #-} !Int summaryUTCEntry :: SummaryUTC a -> {-# UNPACK #-} !UTCTime summaryUTCExit :: SummaryUTC a -> {-# UNPACK #-} !UTCTime summaryUTCData :: SummaryUTC a -> !SummaryData a data ZoomSummarySO ZoomSummarySO :: (SummarySO a) -> ZoomSummarySO data PacketSO PacketSO :: {-# UNPACK #-} !TrackNo -> {-# UNPACK #-} !SampleOffset -> {-# UNPACK #-} !SampleOffset -> {-# UNPACK #-} !Int -> !ZoomRaw -> ![SampleOffset] -> PacketSO packetSOTrack :: PacketSO -> {-# UNPACK #-} !TrackNo packetSOEntry :: PacketSO -> {-# UNPACK #-} !SampleOffset packetSOExit :: PacketSO -> {-# UNPACK #-} !SampleOffset packetSOCount :: PacketSO -> {-# UNPACK #-} !Int packetSOData :: PacketSO -> !ZoomRaw packetSOSampleOffsets :: PacketSO -> ![SampleOffset] -- | A recorded block of summary data data SummarySO a SummarySO :: {-# UNPACK #-} !TrackNo -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !SampleOffset -> {-# UNPACK #-} !SampleOffset -> !SummaryData a -> SummarySO a summarySOTrack :: SummarySO a -> {-# UNPACK #-} !TrackNo summarySOLevel :: SummarySO a -> {-# UNPACK #-} !Int summarySOEntry :: SummarySO a -> {-# UNPACK #-} !SampleOffset summarySOExit :: SummarySO a -> {-# UNPACK #-} !SampleOffset summarySOData :: SummarySO a -> !SummaryData a -- | A map of all track numbers to their TrackSpec type TrackMap = IntMap TrackSpec -- | A specification of the type and name of each track data TrackSpec TrackSpec :: !Codec -> !Bool -> !Bool -> !SampleRateType -> {-# UNPACK #-} !Rational -> !ByteString -> TrackSpec specType :: TrackSpec -> !Codec specDeltaEncode :: TrackSpec -> !Bool specZlibCompress :: TrackSpec -> !Bool specSRType :: TrackSpec -> !SampleRateType specRate :: TrackSpec -> {-# UNPACK #-} !Rational specName :: TrackSpec -> !ByteString -- | The ZoomWrite class provides write, a method to write a Haskell -- value to an open ZoomCache file. class ZoomWrite t write :: ZoomWrite t => TrackNo -> t -> ZoomW () -- | A codec instance must additionally specify a SummaryWork type class ZoomReadable a => ZoomWritable a where data family SummaryWork a :: * deltaEncodeRaw _ = id fromRaw :: ZoomWritable a => a -> Builder fromSummaryData :: ZoomWritable a => SummaryData a -> Builder initSummaryWork :: ZoomWritable a => SampleOffset -> SummaryWork a updateSummaryData :: ZoomWritable a => SampleOffset -> a -> SummaryWork a -> SummaryWork a toSummaryData :: ZoomWritable a => SampleOffsetDiff -> SummaryWork a -> SummaryData a appendSummaryData :: ZoomWritable a => SampleOffsetDiff -> SummaryData a -> SampleOffsetDiff -> SummaryData a -> SummaryData a deltaEncodeRaw :: ZoomWritable a => SummaryWork a -> a -> a -- | A StateT IO monad for writing a ZoomCache file type ZoomW = StateT ZoomWHandle IO -- | Run a ZoomW () action on a given file handle, using the -- specified TrackMap specification withFileWrite :: TrackMap -> Maybe UTCTime -> Bool -> ZoomW () -> FilePath -> IO () -- | Force a flush of ZoomCache summary blocks to disk. It is not usually -- necessary to call this function as summary blocks are transparently -- written at regular intervals. flush :: ZoomW () data ZoomWHandle -- | Open a new ZoomCache file for writing, using a specified -- TrackMap. openWrite :: TrackMap -> Maybe UTCTime -> Bool -> FilePath -> IO ZoomWHandle closeWrite :: ZoomWHandle -> IO () -- | Query the maximum number of data points to buffer for a given track -- before forcing a flush of all buffered data and summaries. watermark :: TrackNo -> ZoomW (Maybe Int) -- | Set the maximum number of data points to buffer for a given track -- before forcing a flush of all buffered data and summaries. setWatermark :: TrackNo -> Int -> ZoomW () setCodec :: ZoomReadable a => a -> TrackSpec -> TrackSpec setCodecMultichannel :: ZoomReadable a => Int -> a -> TrackSpec -> TrackSpec mkTrackSpec :: ZoomReadable a => a -> Bool -> Bool -> SampleRateType -> Rational -> ByteString -> TrackSpec -- | Create a track map for a stream of a given type, as track no. 1 oneTrack :: ZoomReadable a => a -> Bool -> Bool -> SampleRateType -> Rational -> ByteString -> TrackMap -- | IdentifyTrack functions provided for standard codecs provided -- by the zoom-cache library. standardIdentifiers :: [IdentifyCodec] -- | ZoomCache numeric API module Data.ZoomCache.Numeric class (Ord a, Real a, ZoomReadable a, ZoomWritable a) => ZoomNum a numEntry :: ZoomNum a => SummaryData a -> a numExit :: ZoomNum a => SummaryData a -> a numMin :: ZoomNum a => SummaryData a -> a numMax :: ZoomNum a => SummaryData a -> a numAvg :: ZoomNum a => SummaryData a -> Double numRMS :: ZoomNum a => SummaryData a -> Double rawToDouble :: ZoomRaw -> [Double] -- | Coercion of numeric Summary to type Summary Double. toSummaryDouble :: Typeable a => Summary a -> Maybe (Summary Double) -- | Coercion of numeric SummaryUTC to type SummaryUTC Double. toSummaryUTCDouble :: Typeable a => SummaryUTC a -> Maybe (SummaryUTC Double) -- | Read the summary of an entire track. wholeTrackSummaryDouble :: (Functor m, MonadIO m) => TrackNo -> Iteratee [Offset Block] m (Summary Double) -- | Read the summary of an entire track. wholeTrackSummaryUTCDouble :: (Functor m, MonadIO m) => TrackNo -> Iteratee [Offset Block] m (SummaryUTC Double) enumDouble :: (Functor m, Monad m) => Enumeratee [Offset Block] [(TimeStamp, Double)] m a enumUTCDouble :: (Functor m, Monad m) => Enumeratee [Offset Block] [(UTCTime, Double)] m a enumSummaryDouble :: (Functor m, Monad m) => Int -> Enumeratee [Offset Block] [Summary Double] m a enumSummaryUTCDouble :: (Functor m, Monad m) => Int -> Enumeratee [Offset Block] [SummaryUTC Double] m a -- | Default codec implementation for multichannel values of type [a]. -- -- This module implements the interfaces documented in -- Data.ZoomCache.Codec. -- -- Multichannel SummaryData is simply a concatenation of n blocks of -- SummaryData for type a. module Data.ZoomCache.Multichannel.List -- | Read the summary of an entire track. wholeTrackSummaryListDouble :: (Functor m, MonadIO m) => TrackNo -> Iteratee [Offset Block] m [Summary Double] enumListDouble :: (Functor m, Monad m) => Enumeratee [Offset Block] [(TimeStamp, [Double])] m a enumSummaryListDouble :: (Functor m, Monad m) => Int -> Enumeratee [Offset Block] [[Summary Double]] m a -- | Read the summary of an entire track. wholeTrackSummaryUTCListDouble :: (Functor m, MonadIO m) => TrackNo -> Iteratee [Offset Block] m [SummaryUTC Double] enumUTCListDouble :: (Functor m, Monad m) => Enumeratee [Offset Block] [(UTCTime, [Double])] m a enumSummaryUTCListDouble :: (Functor m, Monad m) => Int -> Enumeratee [Offset Block] [[SummaryUTC Double]] m a instance (ZoomWrite a, ZoomWritable a) => ZoomWrite (SampleOffset, [a]) instance (ZoomWrite a, ZoomWritable a) => ZoomWrite [a] -- | ZoomCache multichannel API module Data.ZoomCache.Multichannel trackTypeMultichannel :: ByteString -- | Reading of ZoomCache files. module Data.ZoomCache.Dump zoomDumpFile :: [IdentifyCodec] -> TrackNo -> FilePath -> IO () zoomDumpSummary :: [IdentifyCodec] -> TrackNo -> FilePath -> IO () zoomDumpSummaryLevel :: Int -> [IdentifyCodec] -> TrackNo -> FilePath -> IO () zoomInfoFile :: [IdentifyCodec] -> FilePath -> IO ()