Portability | unknown |
---|---|
Stability | unstable |
Maintainer | Conrad Parker <conrad@metadecks.org> |
Safe Haskell | None |
Data.ZoomCache
Contents
Description
API for implementing ZoomCache applications
- newtype TimeStamp = TS Double
- newtype TimeStampDiff = TSDiff Double
- timeStampDiff :: TimeStamp -> TimeStamp -> TimeStampDiff
- timeStampFromSO :: Rational -> SampleOffset -> TimeStamp
- class Timestampable a where
- before :: Timestampable a => Maybe TimeStamp -> a -> Bool
- class UTCTimestampable a where
- utcTimestamp :: a -> Maybe UTCTime
- beforeUTC :: UTCTimestampable a => Maybe UTCTime -> a -> Bool
- timeStampFromUTCTime :: UTCTime -> UTCTime -> TimeStamp
- utcTimeFromTimeStamp :: UTCTime -> TimeStamp -> UTCTime
- data SampleOffset = SO {}
- type TrackNo = Int
- data Codec = forall a . ZoomReadable a => Codec a
- type IdentifyCodec = ByteString -> Maybe Codec
- data SampleRateType
- = ConstantSR
- | VariableSR
- data Global = Global {}
- data CacheFile = CacheFile {}
- class Typeable a => ZoomReadable a where
- data SummaryData a :: *
- trackIdentifier :: a -> ByteString
- readRaw :: (Functor m, Monad m) => Iteratee ByteString m a
- readSummary :: (Functor m, Monad m) => Iteratee ByteString m (SummaryData a)
- prettyRaw :: a -> String
- prettySummaryData :: SummaryData a -> String
- deltaDecodeRaw :: [a] -> [a]
- data ZoomRaw = forall a . ZoomReadable a => ZoomRaw [a]
- data ZoomSummary = forall a . ZoomReadable a => ZoomSummary (Summary a)
- data Packet = Packet {
- packetTrack :: !TrackNo
- packetEntry :: !TimeStamp
- packetExit :: !TimeStamp
- packetCount :: !Int
- packetData :: !ZoomRaw
- packetTimeStamps :: ![TimeStamp]
- data Summary a = Summary {
- summaryTrack :: !TrackNo
- summaryLevel :: !Int
- summaryEntry :: !TimeStamp
- summaryExit :: !TimeStamp
- summaryData :: !(SummaryData a)
- data ZoomSummaryUTC = forall a . ZoomReadable a => ZoomSummaryUTC (SummaryUTC a)
- data PacketUTC = PacketUTC {
- packetUTCTrack :: !TrackNo
- packetUTCEntry :: !UTCTime
- packetUTCExit :: !UTCTime
- packetUTCCount :: !Int
- packetUTCData :: !ZoomRaw
- packetUTCTimeStamps :: ![UTCTime]
- data SummaryUTC a = SummaryUTC {
- summaryUTCTrack :: !TrackNo
- summaryUTCLevel :: !Int
- summaryUTCEntry :: !UTCTime
- summaryUTCExit :: !UTCTime
- summaryUTCData :: !(SummaryData a)
- data ZoomSummarySO = forall a . ZoomReadable a => ZoomSummarySO (SummarySO a)
- data PacketSO = PacketSO {}
- data SummarySO a = SummarySO {
- summarySOTrack :: !TrackNo
- summarySOLevel :: !Int
- summarySOEntry :: !SampleOffset
- summarySOExit :: !SampleOffset
- summarySOData :: !(SummaryData a)
- type TrackMap = IntMap TrackSpec
- data TrackSpec = TrackSpec {
- specType :: !Codec
- specDeltaEncode :: !Bool
- specZlibCompress :: !Bool
- specSRType :: !SampleRateType
- specRate :: !Rational
- specName :: !ByteString
- class ZoomWrite t where
- class ZoomReadable a => ZoomWritable a where
- data SummaryWork a :: *
- fromRaw :: a -> Builder
- fromSummaryData :: SummaryData a -> Builder
- initSummaryWork :: SampleOffset -> SummaryWork a
- updateSummaryData :: SampleOffset -> a -> SummaryWork a -> SummaryWork a
- toSummaryData :: SampleOffsetDiff -> SummaryWork a -> SummaryData a
- appendSummaryData :: SampleOffsetDiff -> SummaryData a -> SampleOffsetDiff -> SummaryData a -> SummaryData a
- deltaEncodeRaw :: SummaryWork a -> a -> a
- type ZoomW = StateT ZoomWHandle IO
- withFileWrite :: TrackMap -> Maybe UTCTime -> Bool -> ZoomW () -> FilePath -> IO ()
- flush :: ZoomW ()
- data ZoomWHandle
- openWrite :: TrackMap -> Maybe UTCTime -> Bool -> FilePath -> IO ZoomWHandle
- closeWrite :: ZoomWHandle -> IO ()
- watermark :: TrackNo -> ZoomW (Maybe Int)
- 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
- oneTrack :: ZoomReadable a => a -> Bool -> Bool -> SampleRateType -> Rational -> ByteString -> TrackMap
- standardIdentifiers :: [IdentifyCodec]
- module Data.Iteratee.ZoomCache
- module Data.ZoomCache.Pretty
TimeStamps
Instances
Eq TimeStamp | |
Ord TimeStamp | |
Show TimeStamp | |
Timestampable (TimeStamp, a) | |
ZoomWrite (TimeStamp, Bool) | |
ZoomWrite (TimeStamp, Double) | |
ZoomWrite (TimeStamp, Float) | |
ZoomWrite (TimeStamp, Int) | |
ZoomWrite (TimeStamp, Int8) | |
ZoomWrite (TimeStamp, Int16) | |
ZoomWrite (TimeStamp, Int32) | |
ZoomWrite (TimeStamp, Int64) | |
ZoomWrite (TimeStamp, Integer) | |
ZoomWrite (TimeStamp, Word) | |
ZoomWrite (TimeStamp, Word8) | |
ZoomWrite (TimeStamp, Word16) | |
ZoomWrite (TimeStamp, Word32) | |
ZoomWrite (TimeStamp, Word64) | |
ZoomWrite (TimeStamp, ()) |
newtype TimeStampDiff Source
timeStampDiff :: TimeStamp -> TimeStamp -> TimeStampDiffSource
timeStampDiff (TS t1) (TS t2) = TSDiff (t1 - t2)
class Timestampable a whereSource
Instances
Timestampable ZoomSummary | |
Timestampable Packet | |
Timestampable Block | |
Timestampable a => Timestampable [a] | |
Timestampable a => Timestampable (Offset a) | |
Timestampable (Summary a) | |
Timestampable (TimeStamp, a) |
utcTimeFromTimeStamp :: UTCTime -> TimeStamp -> UTCTimeSource
utcTimeFromTimeStamp base (TS ts) = baseUTC + ts
Types
data SampleOffset Source
Instances
Eq SampleOffset | |
Ord SampleOffset | |
Show SampleOffset | |
ZoomWrite (SampleOffset, Bool) | |
ZoomWrite (SampleOffset, Double) | |
ZoomWrite (SampleOffset, Float) | |
ZoomWrite (SampleOffset, Int) | |
ZoomWrite (SampleOffset, Int8) | |
ZoomWrite (SampleOffset, Int16) | |
ZoomWrite (SampleOffset, Int32) | |
ZoomWrite (SampleOffset, Int64) | |
ZoomWrite (SampleOffset, Integer) | |
(ZoomWrite a, ZoomWritable a) => ZoomWrite (SampleOffset, [a]) | |
ZoomWrite (SampleOffset, Word) | |
ZoomWrite (SampleOffset, Word8) | |
ZoomWrite (SampleOffset, Word16) | |
ZoomWrite (SampleOffset, Word32) | |
ZoomWrite (SampleOffset, Word64) | |
ZoomWrite (SampleOffset, ()) | |
(Nat n, ZoomWrite a, ZoomWritable a) => ZoomWrite (SampleOffset, NList n a) |
type IdentifyCodec = ByteString -> Maybe CodecSource
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
.
data SampleRateType Source
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.
Constructors
ConstantSR | |
VariableSR |
Instances
Global and track headers for a zoom-cache file
class Typeable a => ZoomReadable a whereSource
A codec instance must specify a SummaryData
type,
and implement all methods of this class.
Associated Types
data SummaryData a :: *Source
Methods
trackIdentifier :: a -> ByteStringSource
The track identifier used for streams of type a
.
The value of the argument should be ignored by any instance of
ZoomReadable
, so that is safe to pass undefined
as the
argument.
readRaw :: (Functor m, Monad m) => Iteratee ByteString m aSource
An iteratee to read one value of type a
from a stream of ByteString
.
readSummary :: (Functor m, Monad m) => Iteratee ByteString m (SummaryData a)Source
An iteratee to read one value of type 'SummaryData a' from a stream
of ByteString
.
prettyRaw :: a -> StringSource
Pretty printing, used for dumping values of type a
.
prettySummaryData :: SummaryData a -> StringSource
Pretty printing for values of type 'SummaryData a'.
deltaDecodeRaw :: [a] -> [a]Source
Delta-decode a list of values
Instances
Constructors
forall a . ZoomReadable a => ZoomRaw [a] |
Constructors
Packet | |
Fields
|
Instances
A summary block with samplecounts converted to TimeStamp
Constructors
Summary | |
Fields
|
Instances
data ZoomSummaryUTC Source
Constructors
forall a . ZoomReadable a => ZoomSummaryUTC (SummaryUTC a) |
Instances
Constructors
PacketUTC | |
Fields
|
Instances
data SummaryUTC a Source
A summary block with timestamps converted to UTCTime
Constructors
SummaryUTC | |
Fields
|
Instances
data ZoomSummarySO Source
Constructors
forall a . ZoomReadable a => ZoomSummarySO (SummarySO a) |
Constructors
PacketSO | |
Fields
|
A recorded block of summary data
Constructors
SummarySO | |
Fields
|
Track specification
A specification of the type and name of each track
Constructors
TrackSpec | |
Fields
|
The ZoomWrite class
The ZoomWrite class provides write
, a method to write a
Haskell value to an open ZoomCache file.
Instances
class ZoomReadable a => ZoomWritable a whereSource
A codec instance must additionally specify a SummaryWork
type
Methods
Serialize a value of type a
fromSummaryData :: SummaryData a -> BuilderSource
Serialize a 'SummaryData a'
initSummaryWork :: SampleOffset -> SummaryWork aSource
Generate a new 'SummaryWork a', given an initial timestamp.
updateSummaryData :: SampleOffset -> a -> SummaryWork a -> SummaryWork aSource
Update a SummaryData
with the value of a
occuring at the
given SampleOffset
.
toSummaryData :: SampleOffsetDiff -> SummaryWork a -> SummaryData aSource
Finalize a 'SummaryWork a', generating a 'SummaryData a'.
appendSummaryData :: SampleOffsetDiff -> SummaryData a -> SampleOffsetDiff -> SummaryData a -> SummaryData aSource
Append two SummaryData
deltaEncodeRaw :: SummaryWork a -> a -> aSource
Delta-encode a value.
Instances
The ZoomW monad
type ZoomW = StateT ZoomWHandle IOSource
A StateT IO monad for writing a ZoomCache file
Arguments
:: TrackMap | |
-> Maybe UTCTime | |
-> Bool | Whether or not to write raw data packets. If False, only summary blocks are written. |
-> ZoomW () | |
-> FilePath | |
-> IO () |
Run a ZoomW ()
action on a given file handle, using the specified
TrackMap
specification
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.
ZoomWHandle IO functions
data ZoomWHandle Source
Arguments
:: TrackMap | |
-> Maybe UTCTime | |
-> Bool | Whether or not to write raw data packets. If False, only summary blocks are written. |
-> FilePath | |
-> IO ZoomWHandle |
Open a new ZoomCache file for writing, using a specified TrackMap
.
closeWrite :: ZoomWHandle -> IO ()Source
Watermarks
watermark :: TrackNo -> ZoomW (Maybe Int)Source
Query 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 ()Source
Set the maximum number of data points to buffer for a given track before forcing a flush of all buffered data and summaries.
TrackSpec helpers
setCodec :: ZoomReadable a => a -> TrackSpec -> TrackSpecSource
setCodecMultichannel :: ZoomReadable a => Int -> a -> TrackSpec -> TrackSpecSource
mkTrackSpec :: ZoomReadable a => a -> Bool -> Bool -> SampleRateType -> Rational -> ByteString -> TrackSpecSource
oneTrack :: ZoomReadable a => a -> Bool -> Bool -> SampleRateType -> Rational -> ByteString -> TrackMapSource
Create a track map for a stream of a given type, as track no. 1
Standard identifiers
standardIdentifiers :: [IdentifyCodec]Source
IdentifyTrack
functions provided for standard codecs provided
by the zoom-cache library.
Iteratee parsers
module Data.Iteratee.ZoomCache
Pretty printing
module Data.ZoomCache.Pretty