The TeaTime namespace provides classes to read and write TeaFiles. TeaFiles are a simple and efficient way to store time series in flat files.


  Class Description
Public class EventTimeAttribute
Defines the field of a struct holding the event time.
Public class Field
Describes the field of an item.
Public class FileFormatException
The header of a TeaFile has an invalid format.
Public class InternalErrorException
An internal error occured.
Public class InvalidFieldTypeException
The field of an item is of a type that can not be stored in a TeaFile.
Public class InvalidStateException
The object has an invalid state.
Public class Item
Holds the values of an Item when reading a TeaFile untyped.
Public class ItemDescription
Describes the type of items stored in a TeaFile.
Public class ItemException
The item type violates constraints.
Public class ManagedMemoryMapping<(Of <(<'T>)>)>
Access items in TeaFiles via safe memory mapping using MemoryMappedFile.
Public class NameValue
A name / value pair.
Public class NameValueCollection
A collection of name / value pairs.
Public class RawMemoryMapping<(Of <(<'T>)>)>
Access items in TeaFiles via unsafe raw memory mapping.
Public class TeaFile
Read TeaFiles without knowing anything about their content (untyped reading).
Public class TeaFile<(Of <(<'T>)>)>
Create, write and read TeaFiles using their item type (typed reading).
Public class TeaFileDescription
TeaFiles optionally hold a description, describing item layout and content.
Public class TimescaleException
The current default Timescale differs from the Timescale used in a file.
Public class TypeMismatchException
A TeaFile is read with a type that does not match the type it was written with.


  Structure Description
Public structure Event<(Of <(<'T>)>)>
Represents an event.
Public structure Time
This class is designed after DateTime but allows configurable epoch and resolution via its Scale property.
Public structure Timescale
Describes how raw tick counts are converted to date and time values.


  Interface Description
Public interface IItemCollection
Provides access to items of untyped TeaFile.
Public interface IItemCollection<(Of <(<'T>)>)>
Provides access to items using typed TeaFile<(Of <(<'T>)>)>.


  Enumeration Description
Public enumeration FieldType
Describes the types available for structs inside TeaFiles.
Public enumeration ItemDescriptionElements
Describes the elements inside an ItemDescription.
Public enumeration ScaleCollisionBehavior
Describes the behavior upon Timescale collision.


TeaFile<(Of <(<'T>)>)> is used to create, write and read TeaFiles


              struct Tick // the time series item type
    public DateTime Time;
    public double Price;
    public int Volume;

// create file and write some values
using (var tf = TeaFile<Tick>.Create("gold.tea"))
    tf.Write(new Tick { Price = 5, Time = DateTime.Now, Volume = 700 });
    tf.Write(new Tick { Price = 15, Time = DateTime.Now.AddHours(1), Volume = 1700 });

// read typed
using (var tf = TeaFile<Tick>.OpenRead("gold.tea"))
    Tick value = tf.Read();

If the type of items stored in a TeaFile is unknown, the file can still be opened using the non generic class TeaFile.


read untyped - we know nothing about the type of item in the file
using (var tf = TeaFile.OpenRead("gold.tea"))
    foreach(Item item in tf.Items)

// output:
Price=5 Time=20.8.2011 23:50
Price=15 Time=21.8.2011 00:50
If possible, typed reading is preferred, as it is much more performant and convient. Untyped reading should be used otherwise. Tools like TeaShell that present arbitrary TeaFiles, not known at compile time, use untyped reading.