TDAMemDataTable using TDABin2DataStreamer (Delphi)
TDABin2DataStreamer is tightly integrated with the new TDAMemDataTable and TDAMemDataset components.
TDABin2DataStreamer has 2 modes of work: compatible and native. Compatible mode is used for filling TDAADODataTable or TDACDSDataTable or using OnReadFieldValue event.
This component works with a TDAMemDataTable in 'native mode', where the best performance can be achieved, because streamer can populate data in TDAMemDataTable via internal methods which don't execute the dataset's Append/Post methods.
For example, a TDAMemDataTable can fill itself from a received Bin2 stream without having to parse and copy the entire data stream - making opening data tables on the client very efficient.
How Objects are Streamed
In conclusion, the following extracts show the format of the stream produced by TDABin2DataStreamer.
Note, that while the extracts shown below, use an XML structure view for best readability, data streaming in Bin2 format uses binary encoding.
DataTable:
<BinHeader>
<Flag is schema present or not>
<End of schema position (0 if schema doesn't exist)>
<Schema of the table>
<Count of rows in stream>
<Count of fields in stream>
<Description fields in stream (For each field)
<FieldName>
<FieldDataType>
<FieldSize>
>
<Data (for each row)
<Bitmask that holds info about fields with null values>
<For each field
<Value of the field>
>
>
DataTable Schema:
<Count of fields in table>
<Count of properties for each field>
<For each field
<For each property
<Name of the property>
<Value of the property>
>
>
<Count of parameters in table>
<Count of properties for each parameter>
<For each parameter
<For each property
<Name of the property>
<Value of the property>
>
>
Delta:
<BinHeader>
<Count of changes>
<Count of fields>
<For each field in delta :>
<FieldName>
<FieldDataType>
<Count of key fields>
<For each key field>
<FieldName>
<Flag is this delta "Reduced">
<Count of actual changes>
<For each change
<Type of the Change>
<RecordID>
<Status of the change>
<Message of the change>
<Bitmask: holds info about OLD values>
<For each field
<OLD value of the field>
>
<Bitmask: holds info about NEW values>
<For each field
<NEW value of the field>
>
>
A Delta packet contains local changes to be updated on the server.