DataStreamer

Overview

Data Streamers perform the task of reading and writing data and delta packets from and to a format that can be transmitted over the network between client and server. As such they form a critical part of the Data Abstract architecture.

DataStreamer is the base abstract class for serialization and deserialization of deltas and data in Data Abstract.

You will use one of the concrete implementations of this class (such as the Bin2DataStreamer in your application. You can also derive your own descendants of DataStreamer to implement a custom streaming format.

The source to read from(destination to write to) can be provided to the streamer instance with its initializeStreamer method. After that, all read/write methods of the streamer object will use the above mentioned object to read/write data.

While the DataStreamer exposes several public properties and methods, you will not usually work with Data Streamers directly, but it's widely used inside RemoteDataAdapter.

Location

 

doFinalizeStreamer  protected

Abstract method that is used internaly by finalizeStreamer method.

 

method doFinalizeStreamer

 

void doFinalizeStreamer()

doInitializeStreamer  protected

Abstract method that is used internaly by initializeStreamer method.

 

method doInitializeStreamer(aSource: Object; aMode: StreamerInitialization)

 

void doInitializeStreamer(Object aSource, StreamerInitialization aMode)

Parameters:

  • aSource: a data for the streamer to worm with(usually a string or a stream).
  • aMode: an initialization mode of the streamer.

doReadDataTable (StreamElementInfo, DataTable)  protected

Abstract method that is used internally by readDataTable method.

 

method doReadDataTable(anElement: StreamElementInfo; aDestination: DataTable)

 

void doReadDataTable(StreamElementInfo anElement, DataTable aDestination)

Parameters:

  • anElement: A stream element the represents table in the destination object.
  • aDestination: A target data table object to store read data.

doReadDataTable (StreamElementInfo, DataTable, Boolean)  protected

Abstract method that is used internally by readDataTable method.

 

method doReadDataTable(anElement: StreamElementInfo; aDestination: DataTable; ApplySchema: Boolean)

 

void doReadDataTable(StreamElementInfo anElement, DataTable aDestination, Boolean ApplySchema)

Parameters:

  • anElement: A stream element the represents table in the destination object.
  • aDestination: A target data table object to store read data.
  • ApplySchema: The flag defines, if a Schema should be applied to the given table.

doReadDataTable (StreamElementInfo, DataTable, Boolean, Boolean)  protected

Abstract method that is used internally by readDataTable method.

 

method doReadDataTable(anElement: StreamElementInfo; aDestination: DataTable; ApplySchema: Boolean; LoadRecords: Boolean)

 

void doReadDataTable(StreamElementInfo anElement, DataTable aDestination, Boolean ApplySchema, Boolean LoadRecords)

Parameters:

  • anElement: A stream element the represents table in the destination object.
  • aDestination: A target data table object to store read data.
  • ApplySchema: The flag defines, if a Schema should be applied to the given table.
  • LoadRecords: The flag defines, if method should load data for the table.

doReadDataTableSchema  protected

Abstract method that is used internally by readDataTableSchema method.

 

method doReadDataTableSchema(aDataTableName: String): SchemaDataTable

 

SchemaDataTable doReadDataTableSchema(String aDataTableName)

Parameters:

  • aDataTableName: A name of the data table.

doReadDelta  protected

Abstract method that is used internally by readDelta method.

 

method doReadDelta(anElement: StreamElementInfo; aDestination: Delta)

 

void doReadDelta(StreamElementInfo anElement, Delta aDestination)

Parameters:

  • anElement: A stream element the represents table in destination object.
  • aDestination: A delta object to be filled.

doWriteDataTable  protected

Abstract method that is used internally by writeDataTable method.

 

method doWriteDataTable(aTable: DataTable; aTableSchema: SchemaDataTable; aMaxRecords: Integer; aIncludeSchema: Boolean)

 

void doWriteDataTable(DataTable aTable, SchemaDataTable aTableSchema, Integer aMaxRecords, Boolean aIncludeSchema)

Parameters:

  • aTable: A data table to stream.
  • aTableSchema: A data table's schema to use while streaming.
  • aMaxRecords: A number of maximum table records the server supposed to send back to the client.
  • aIncludeSchema: The flag defines wheter or not server should include table schema in response.

doWriteDelta  protected

Abstract method that is used internally by writeDelta method.

 

method doWriteDelta(aDelta: Delta; aDynamicSelect: Boolean)

 

void doWriteDelta(Delta aDelta, Boolean aDynamicSelect)

Parameters:

  • aDelta: A delta to be streamed.
  • aDynamicSelect: A flag defines whether or not the streamer should use Dynamic Select feature while writing the delta.

Elements

 

property Elements: Map<String, StreamElementInfo> read;

 

Map<String, StreamElementInfo> Elements { __get; }

finalizeStreamer

The method finalizes the reading/writing of data. It should be called after all elements are written or when reading is complete.

 

method finalizeStreamer

 

void finalizeStreamer()

getLoggedDeltaFields  protected

The method uses given delta to return the list of SchemaField that should be logged to server and an index that maps schema fields to correspondent positions used by the delta.

 

class method getLoggedDeltaFields(aDelta: Delta; aFields: ReferenceType<array of SchemaField>; aMapping: ReferenceType<array of Integer>)

 

static void getLoggedDeltaFields(Delta aDelta, ReferenceType<array of SchemaField> aFields, ReferenceType<array of Integer> aMapping)

Parameters:

  • aDelta: A delta to work with.
  • aFields: * out param* list of schema fields that should be logged.
  • aMapping: * out param* mapping to find the index for column data.

InitializationMode  protected

 

property InitializationMode: StreamerInitialization read;

 

StreamerInitialization InitializationMode { __get; }

initializeStreamer

This method initializes current streamer object. First parameter should contain the stream or String containing the data to process. All other read/wirte streamer methods will use this given object as a source to read from or as a destination to write to. Second parameter should contain the mode in which this Streamer should be initialized.

 

method initializeStreamer(aSource: Object; aStreamerMode: StreamerInitialization)

 

void initializeStreamer(Object aSource, StreamerInitialization aStreamerMode)

Parameters:

  • aSource: a data for the streamer to worm with(usually a string or a stream).
  • aStreamerMode: an initialization mode of the streamer.

isDbValueAssigned  protected

This method checks if a value was initialized by the DB or the server.

 

class method isDbValueAssigned(aValue: Object): Boolean

 

static Boolean isDbValueAssigned(Object aValue)

Parameters:

  • aValue: avalue to check.

makeTableKey

The method returns a prepered key for the given table name, that will be used internally in the streamer to identify the table.

 

class method makeTableKey(aTableName: String): String

 

static String makeTableKey(String aTableName)

Parameters:

  • aTableName: A name of the data table.

needIncludeValuesToStream  protected

The method checks if specific row value must be included wile streaming data. It can be ommited, if if hasn't been changed. This approach is ussed in Reduced Delta feature of Bin2DataStreamer.

 

method needIncludeValuesToStream(aOldValue: Object; aNewValue: Object; aIsReducedDelta: Boolean; aIsPK: Boolean; aIncludeOld: ReferenceType<Boolean>; aIncludeNew: ReferenceType<Boolean>): Boolean

 

Boolean needIncludeValuesToStream(Object aOldValue, Object aNewValue, Boolean aIsReducedDelta, Boolean aIsPK, ReferenceType<Boolean> aIncludeOld, ReferenceType<Boolean> aIncludeNew)

Parameters:

  • aOldValue: An original field value.
  • aNewValue: A new field value.
  • aIsReducedDelta: A flag defines whether or not the delta should be reduced.
  • aIsPK: The flag used to define whether of not the field belongs to the primary key.
  • aIncludeOld: out param returns whether or not the original value is supposed to be included.
  • aIncludeNew: out param returns whether or not the new value is supposed to be included.

readDataTable

Reads the contents of a DataTable from the stream. This method will throw an exception if no DataTable can be found in the stream by the name passed in the first parameter.

Some cases of usage:

  // to load data without schema (in case table has been previously initialized with the schema):
  streamer.readDataTable("Clients", table, <tt>false</tt>, <tt>true</tt>);
  // to initialize the table column structure without loading the ctual data:
  streamer.readDataTable("Clients", table, <tt>true</tt>, <tt>false</tt>);

 

method readDataTable(aDataTableName: String; aDestination: DataTable; aApplySchema: Boolean; aLoadRecords: Boolean)

 

void readDataTable(String aDataTableName, DataTable aDestination, Boolean aApplySchema, Boolean aLoadRecords)

Parameters:

  • aDataTableName: A name of the data table to be read.
  • aDestination: A data table object to fill with tha data.
  • aApplySchema: The flag defines, if a Schema should be applied to the given table.
  • aLoadRecords: The flag defines, if method should load data for the table.

readDataTableSchema

The method reads the schema for the given table name and returns it.

 

method readDataTableSchema(aDataTableName: String): SchemaDataTable

 

SchemaDataTable readDataTableSchema(String aDataTableName)

Parameters:

  • aDataTableName: A name of the data table.

readDelta (Delta)

The method returns a delta from the provided source. If there is no delta by the name passed it will throw an exception.

 

method readDelta(aDestination: Delta)

 

void readDelta(Delta aDestination)

Parameters:

  • aDestination: A delta object to be filled.

readDelta (Schema, String): Delta

The method creates a new Delta object using the given Schema and fills it from the source associated with the streamer.

 

method readDelta(aSchema: Schema; aTableName: String): Delta

 

Delta readDelta(Schema aSchema, String aTableName)

Parameters:

  • aSchema: A schema for a new delta.
  • aTableName: A table name, that is used to find delta's data in the streamer's source.

writeDataTable

The method writes a DataTable to the streamer destination. This method will throw an exception if a DataTable by the same name already exists in the stream.

 

method writeDataTable(aTable: DataTable; aTableSchema: SchemaDataTable; aMaxRecords: Integer; aIncludeSchema: Boolean)

 

void writeDataTable(DataTable aTable, SchemaDataTable aTableSchema, Integer aMaxRecords, Boolean aIncludeSchema)

Parameters:

  • aTable: A data table to stream.
  • aTableSchema: A data table's schema to use while streaming.
  • aMaxRecords: A number of maximum table records the server supposed to send back to the client.
  • aIncludeSchema: The flag defines wheter or not server should include table schema in response.

writeDelta (DataTable, Boolean): Delta

 

method writeDelta(aDataTable: DataTable; aDynamicSelect: Boolean): Delta

 

Delta writeDelta(DataTable aDataTable, Boolean aDynamicSelect)

Parameters:

  • aDataTable:
  • aDynamicSelect:

writeDelta (Delta, Boolean)

The method streams the gived delta considering usage of Dynamic Select feature.

 

method writeDelta(aDelta: Delta; aDynamicSelect: Boolean)

 

void writeDelta(Delta aDelta, Boolean aDynamicSelect)

Parameters:

  • aDelta: A delta to be streamed.
  • aDynamicSelect: A flag defines whether or not the streamer should use Dynamic Select feature while writing the delta.

 

Elements

 

property Elements: Map<String, StreamElementInfo> read;

 

Map<String, StreamElementInfo> Elements { __get; }

InitializationMode  protected

 

property InitializationMode: StreamerInitialization read;

 

StreamerInitialization InitializationMode { __get; }

 

getLoggedDeltaFields  protected

The method uses given delta to return the list of SchemaField that should be logged to server and an index that maps schema fields to correspondent positions used by the delta.

 

class method getLoggedDeltaFields(aDelta: Delta; aFields: ReferenceType<array of SchemaField>; aMapping: ReferenceType<array of Integer>)

 

static void getLoggedDeltaFields(Delta aDelta, ReferenceType<array of SchemaField> aFields, ReferenceType<array of Integer> aMapping)

Parameters:

  • aDelta: A delta to work with.
  • aFields: * out param* list of schema fields that should be logged.
  • aMapping: * out param* mapping to find the index for column data.

isDbValueAssigned  protected

This method checks if a value was initialized by the DB or the server.

 

class method isDbValueAssigned(aValue: Object): Boolean

 

static Boolean isDbValueAssigned(Object aValue)

Parameters:

  • aValue: avalue to check.

makeTableKey

The method returns a prepered key for the given table name, that will be used internally in the streamer to identify the table.

 

class method makeTableKey(aTableName: String): String

 

static String makeTableKey(String aTableName)

Parameters:

  • aTableName: A name of the data table.

 

doFinalizeStreamer  protected

Abstract method that is used internaly by finalizeStreamer method.

 

method doFinalizeStreamer

 

void doFinalizeStreamer()

doInitializeStreamer  protected

Abstract method that is used internaly by initializeStreamer method.

 

method doInitializeStreamer(aSource: Object; aMode: StreamerInitialization)

 

void doInitializeStreamer(Object aSource, StreamerInitialization aMode)

Parameters:

  • aSource: a data for the streamer to worm with(usually a string or a stream).
  • aMode: an initialization mode of the streamer.

doReadDataTable (StreamElementInfo, DataTable)  protected

Abstract method that is used internally by readDataTable method.

 

method doReadDataTable(anElement: StreamElementInfo; aDestination: DataTable)

 

void doReadDataTable(StreamElementInfo anElement, DataTable aDestination)

Parameters:

  • anElement: A stream element the represents table in the destination object.
  • aDestination: A target data table object to store read data.

doReadDataTable (StreamElementInfo, DataTable, Boolean)  protected

Abstract method that is used internally by readDataTable method.

 

method doReadDataTable(anElement: StreamElementInfo; aDestination: DataTable; ApplySchema: Boolean)

 

void doReadDataTable(StreamElementInfo anElement, DataTable aDestination, Boolean ApplySchema)

Parameters:

  • anElement: A stream element the represents table in the destination object.
  • aDestination: A target data table object to store read data.
  • ApplySchema: The flag defines, if a Schema should be applied to the given table.

doReadDataTable (StreamElementInfo, DataTable, Boolean, Boolean)  protected

Abstract method that is used internally by readDataTable method.

 

method doReadDataTable(anElement: StreamElementInfo; aDestination: DataTable; ApplySchema: Boolean; LoadRecords: Boolean)

 

void doReadDataTable(StreamElementInfo anElement, DataTable aDestination, Boolean ApplySchema, Boolean LoadRecords)

Parameters:

  • anElement: A stream element the represents table in the destination object.
  • aDestination: A target data table object to store read data.
  • ApplySchema: The flag defines, if a Schema should be applied to the given table.
  • LoadRecords: The flag defines, if method should load data for the table.

doReadDataTableSchema  protected

Abstract method that is used internally by readDataTableSchema method.

 

method doReadDataTableSchema(aDataTableName: String): SchemaDataTable

 

SchemaDataTable doReadDataTableSchema(String aDataTableName)

Parameters:

  • aDataTableName: A name of the data table.

doReadDelta  protected

Abstract method that is used internally by readDelta method.

 

method doReadDelta(anElement: StreamElementInfo; aDestination: Delta)

 

void doReadDelta(StreamElementInfo anElement, Delta aDestination)

Parameters:

  • anElement: A stream element the represents table in destination object.
  • aDestination: A delta object to be filled.

doWriteDataTable  protected

Abstract method that is used internally by writeDataTable method.

 

method doWriteDataTable(aTable: DataTable; aTableSchema: SchemaDataTable; aMaxRecords: Integer; aIncludeSchema: Boolean)

 

void doWriteDataTable(DataTable aTable, SchemaDataTable aTableSchema, Integer aMaxRecords, Boolean aIncludeSchema)

Parameters:

  • aTable: A data table to stream.
  • aTableSchema: A data table's schema to use while streaming.
  • aMaxRecords: A number of maximum table records the server supposed to send back to the client.
  • aIncludeSchema: The flag defines wheter or not server should include table schema in response.

doWriteDelta  protected

Abstract method that is used internally by writeDelta method.

 

method doWriteDelta(aDelta: Delta; aDynamicSelect: Boolean)

 

void doWriteDelta(Delta aDelta, Boolean aDynamicSelect)

Parameters:

  • aDelta: A delta to be streamed.
  • aDynamicSelect: A flag defines whether or not the streamer should use Dynamic Select feature while writing the delta.

finalizeStreamer

The method finalizes the reading/writing of data. It should be called after all elements are written or when reading is complete.

 

method finalizeStreamer

 

void finalizeStreamer()

initializeStreamer

This method initializes current streamer object. First parameter should contain the stream or String containing the data to process. All other read/wirte streamer methods will use this given object as a source to read from or as a destination to write to. Second parameter should contain the mode in which this Streamer should be initialized.

 

method initializeStreamer(aSource: Object; aStreamerMode: StreamerInitialization)

 

void initializeStreamer(Object aSource, StreamerInitialization aStreamerMode)

Parameters:

  • aSource: a data for the streamer to worm with(usually a string or a stream).
  • aStreamerMode: an initialization mode of the streamer.

needIncludeValuesToStream  protected

The method checks if specific row value must be included wile streaming data. It can be ommited, if if hasn't been changed. This approach is ussed in Reduced Delta feature of Bin2DataStreamer.

 

method needIncludeValuesToStream(aOldValue: Object; aNewValue: Object; aIsReducedDelta: Boolean; aIsPK: Boolean; aIncludeOld: ReferenceType<Boolean>; aIncludeNew: ReferenceType<Boolean>): Boolean

 

Boolean needIncludeValuesToStream(Object aOldValue, Object aNewValue, Boolean aIsReducedDelta, Boolean aIsPK, ReferenceType<Boolean> aIncludeOld, ReferenceType<Boolean> aIncludeNew)

Parameters:

  • aOldValue: An original field value.
  • aNewValue: A new field value.
  • aIsReducedDelta: A flag defines whether or not the delta should be reduced.
  • aIsPK: The flag used to define whether of not the field belongs to the primary key.
  • aIncludeOld: out param returns whether or not the original value is supposed to be included.
  • aIncludeNew: out param returns whether or not the new value is supposed to be included.

readDataTable

Reads the contents of a DataTable from the stream. This method will throw an exception if no DataTable can be found in the stream by the name passed in the first parameter.

Some cases of usage:

  // to load data without schema (in case table has been previously initialized with the schema):
  streamer.readDataTable("Clients", table, <tt>false</tt>, <tt>true</tt>);
  // to initialize the table column structure without loading the ctual data:
  streamer.readDataTable("Clients", table, <tt>true</tt>, <tt>false</tt>);

 

method readDataTable(aDataTableName: String; aDestination: DataTable; aApplySchema: Boolean; aLoadRecords: Boolean)

 

void readDataTable(String aDataTableName, DataTable aDestination, Boolean aApplySchema, Boolean aLoadRecords)

Parameters:

  • aDataTableName: A name of the data table to be read.
  • aDestination: A data table object to fill with tha data.
  • aApplySchema: The flag defines, if a Schema should be applied to the given table.
  • aLoadRecords: The flag defines, if method should load data for the table.

readDataTableSchema

The method reads the schema for the given table name and returns it.

 

method readDataTableSchema(aDataTableName: String): SchemaDataTable

 

SchemaDataTable readDataTableSchema(String aDataTableName)

Parameters:

  • aDataTableName: A name of the data table.

readDelta (Delta)

The method returns a delta from the provided source. If there is no delta by the name passed it will throw an exception.

 

method readDelta(aDestination: Delta)

 

void readDelta(Delta aDestination)

Parameters:

  • aDestination: A delta object to be filled.

readDelta (Schema, String): Delta

The method creates a new Delta object using the given Schema and fills it from the source associated with the streamer.

 

method readDelta(aSchema: Schema; aTableName: String): Delta

 

Delta readDelta(Schema aSchema, String aTableName)

Parameters:

  • aSchema: A schema for a new delta.
  • aTableName: A table name, that is used to find delta's data in the streamer's source.

writeDataTable

The method writes a DataTable to the streamer destination. This method will throw an exception if a DataTable by the same name already exists in the stream.

 

method writeDataTable(aTable: DataTable; aTableSchema: SchemaDataTable; aMaxRecords: Integer; aIncludeSchema: Boolean)

 

void writeDataTable(DataTable aTable, SchemaDataTable aTableSchema, Integer aMaxRecords, Boolean aIncludeSchema)

Parameters:

  • aTable: A data table to stream.
  • aTableSchema: A data table's schema to use while streaming.
  • aMaxRecords: A number of maximum table records the server supposed to send back to the client.
  • aIncludeSchema: The flag defines wheter or not server should include table schema in response.

writeDelta (DataTable, Boolean): Delta

 

method writeDelta(aDataTable: DataTable; aDynamicSelect: Boolean): Delta

 

Delta writeDelta(DataTable aDataTable, Boolean aDynamicSelect)

Parameters:

  • aDataTable:
  • aDynamicSelect:

writeDelta (Delta, Boolean)

The method streams the gived delta considering usage of Dynamic Select feature.

 

method writeDelta(aDelta: Delta; aDynamicSelect: Boolean)

 

void writeDelta(Delta aDelta, Boolean aDynamicSelect)

Parameters:

  • aDelta: A delta to be streamed.
  • aDynamicSelect: A flag defines whether or not the streamer should use Dynamic Select feature while writing the delta.

Descendants