-- 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. -- -- What's neat about this format and library? Glad you asked! -- --
-- > 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 -- | 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 -- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- | Presentationtime numerator (int64) | 16-19 -- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- | ... | 20-23 -- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- | Presentationtime denominator (int64) | 24-27 -- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- | ... | 28-31 -- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- | Basetime numerator (int64) | 32-35 -- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- | ... | 36-39 -- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- | Basetime denominator (int64) | 40-43 -- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- | ... | 44-47 -- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- | UTC | 48-51 -- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- | ... | 52-55 -- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- | ... | 56-59 -- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- | ... | 60-63 -- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- | ... | 64-67 -- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ --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 -- | 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 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 -> Rational -> Rational -> Maybe Int -> Global version :: Global -> Version noTracks :: Global -> Int presentationTime :: Global -> Rational baseTime :: Global -> Rational baseUTC :: Global -> Maybe Int 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 Show Global 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 -- | 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 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 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 -> CacheFile cfGlobal :: CacheFile -> Global cfSpecs :: CacheFile -> IntMap TrackSpec -- | 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 Summary instance Typeable1 SummarySO instance Show TrackSpec instance Timestampable ZoomSummary instance Timestampable (Summary a) instance Timestampable Packet instance Timestampable a => Timestampable [a] instance Timestampable (TimeStamp, a) instance Show Codec -- | Iteratee reading of ZoomCache files. module Data.Iteratee.ZoomCache.Utils seekTimeStamp :: (ListLike s el, Nullable s, NullPoint s, Timestampable el, Monad m) => Maybe TimeStamp -> Iteratee s m () -- | 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 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 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 -> 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 -> 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 () 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 -- | 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] 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 Stream StreamPacket :: CacheFile -> TrackNo -> PacketSO -> Stream strmFile :: Stream -> CacheFile strmTrack :: Stream -> TrackNo strmPacket :: Stream -> PacketSO StreamSummary :: CacheFile -> TrackNo -> ZoomSummarySO -> Stream strmFile :: Stream -> CacheFile strmTrack :: Stream -> TrackNo strmSummary :: Stream -> ZoomSummarySO -- | 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 Stream elements. enumCacheFile :: (Functor m, MonadIO m) => [IdentifyCodec] -> Enumeratee ByteString [Stream] m a -- | Read the summary of an entire track. wholeTrackSummary :: (Functor m, MonadIO m) => [IdentifyCodec] -> TrackNo -> Iteratee ByteString m (TrackSpec, ZoomSummary) -- | Parse only the global and track headers of a zoom-cache file, -- returning a CacheFile iterHeaders :: (Functor m, Monad m) => [IdentifyCodec] -> Iteratee 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. enumStream :: (Functor m, MonadIO m) => CacheFile -> Enumeratee ByteString [Stream] m a -- | A version of enumStream which won't fail with an EofException if the -- last bit is incomplete (perhaps still being written to). enumStreamIncomplete :: (Functor m, MonadIO m) => CacheFile -> Enumeratee ByteString [Stream] 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 enumStream. Using this function -- multiple times in parallel will duplicate some parsing. enumStreamTrackNo :: (Functor m, MonadIO m) => CacheFile -> TrackNo -> Enumeratee ByteString [Stream] m a seekTimeStamp :: (ListLike s el, Nullable s, NullPoint s, Timestampable el, Monad m) => Maybe TimeStamp -> Iteratee s m () -- | Filter just the raw data enumPackets :: (Functor m, MonadIO m) => Enumeratee [Stream] [Packet] m a -- | Filter summaries at a particular summary level enumSummaryLevel :: (Functor m, MonadIO m) => Int -> Enumeratee [Stream] [ZoomSummary] m a -- | Filter summaries at all levels enumSummaries :: (Functor m, MonadIO m) => Enumeratee [Stream] [ZoomSummary] m a -- | Filter to a given list of track names filterTracksByName :: (Functor m, MonadIO m) => CacheFile -> [ByteString] -> Enumeratee [Stream] [Stream] m a -- | Filter to a given list of track numbers filterTracks :: (Functor m, MonadIO m) => [TrackNo] -> Enumeratee [Stream] [Stream] m a -- | Filter just the raw data enumPacketSOs :: (Functor m, MonadIO m) => Enumeratee [Stream] [PacketSO] m a -- | Filter summaries at a particular summary level enumSummarySOLevel :: (Functor m, MonadIO m) => Int -> Enumeratee [Stream] [ZoomSummarySO] m a -- | Filter summaries at all levels enumSummarySOs :: (Functor m, MonadIO m) => Enumeratee [Stream] [ZoomSummarySO] m a -- | Filter raw data enumCTPSO :: (Functor m, MonadIO m) => Enumeratee [Stream] [(CacheFile, TrackNo, PacketSO)] m a -- | Filter summaries enumCTSO :: (Functor m, MonadIO m) => Enumeratee [Stream] [(CacheFile, TrackNo, ZoomSummarySO)] m a instance Timestampable Stream 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 -- | 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 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 -- | Global and track headers for a zoom-cache file data CacheFile CacheFile :: Global -> IntMap TrackSpec -> CacheFile cfGlobal :: CacheFile -> Global cfSpecs :: CacheFile -> IntMap TrackSpec -- | A codec instance must specify a SummaryData type, and implement -- all methods of this class. class Typeable a => ZoomReadable a 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 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 -> 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 -> 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 () 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 SummarySO Double. toSummaryDouble :: Typeable a => Summary a -> Maybe (Summary Double) -- | Coercion of numeric SummarySO to type SummarySO Double. toSummarySODouble :: Typeable a => SummarySO a -> Maybe (SummarySO Double) -- | Read the summary of an entire track. wholeTrackSummaryDouble :: (Functor m, MonadIO m) => [IdentifyCodec] -> TrackNo -> Iteratee ByteString m (Summary Double) enumDouble :: (Functor m, MonadIO m) => Enumeratee [Stream] [(TimeStamp, Double)] m a enumSummaryDouble :: (Functor m, MonadIO m) => Int -> Enumeratee [Stream] [Summary 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) => [IdentifyCodec] -> TrackNo -> Iteratee ByteString m [Summary Double] enumListDouble :: (Functor m, MonadIO m) => Enumeratee [Stream] [(TimeStamp, [Double])] m a enumSummaryListDouble :: (Functor m, MonadIO m) => Int -> Enumeratee [Stream] [[Summary 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 ()