Search Results for

    Show / Hide Table of Contents

    Class DictionaryTargetFactory

    Factory methods that create a DictionaryTarget<TInput, TKey, TValue> dataflow worker, which consumes incoming rows and adds selected values to an IDictionary<TKey,TValue>.

    Note that by default on .NET Framework, maximum array size is 2GB, which in turn limits the Dictionary<TKey,TValue> size with a 64-bit application (using references as key and value) to a maximum of 47.9 million items. You can remove this limit by enabling support for larger arrays, as described in <gcAllowVeryLargeObjects> Element.

    .NET 6+ on the other hand supports >2GB arrays by default.

    The Input port is linked to (if available) the upstream output or error output port specified by the factory.

    Get the factory from Link when the upstream port is known ahead of time (which is usually the case). Otherwise get it from GetDownstreamFactory<TInput>(), and link the transform or target explicitly using LinkTo(InputPort<TOutput>) or LinkFrom(OutputPortBase<TInput>).

    Inheritance
    Object
    DictionaryTargetFactory
    Namespace: actionETL
    Assembly: actionETL.dll
    Syntax
    public static class DictionaryTargetFactory

    Methods

    DictionaryTarget<TInput, TKey, TValue>(in DownstreamFactory<TInput>, String, IDictionary<TKey, TValue>, Func<TInput, KeyValuePair<TKey, TValue>>)

    Initializes a new instance of the DictionaryTarget<TInput, TKey, TValue> dataflow worker, which consumes incoming rows and adds selected values to an IDictionary<TKey,TValue>.

    Any duplicate key returned by selectKeyValueFunc will fail the worker with a Fatal state.

    The Input port is linked to (if available) the upstream output or error output port specified by the factory.

    Declaration
    public static DictionaryTarget<TInput, TKey, TValue> DictionaryTarget<TInput, TKey, TValue>(this in DownstreamFactory<TInput> downstreamFactory, string workerName, IDictionary<TKey, TValue> dictionary, Func<TInput, KeyValuePair<TKey, TValue>> selectKeyValueFunc)
        where TInput : class
    Parameters
    Type Name Description
    DownstreamFactory<TInput> downstreamFactory

    The downstream factory, which specifies the parent worker and (optionally) the upstream port to link the "first" input port of this dataflow worker to.

    Get it from Link when the upstream port is known ahead of time (which is usually the case). Otherwise get it from GetDownstreamFactory<TInput>(), and link the transform or target explicitly using LinkTo(InputPort<TOutput>) or LinkFrom(OutputPortBase<TInput>).

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    IDictionary<TKey, TValue> dictionary

    The dictionary to store lookup items (from the incoming rows) into. Can be null, in which case either set Dictionary before the worker runs, or a Dictionary<TKey,TValue> will be automatically created when he worker runs.

    Func<TInput, KeyValuePair<TKey, TValue>> selectKeyValueFunc

    A callback function that receives a row as a parameter, and must return a key and value pair, from a column or a calculation, e.g.:

    public class MyRow
    {
        public int MyKey;
        public string MyValue;
        // Any other members...
    }
    
    // ...
    
    // selectKeyValueFunc:
    row => new KeyValuePair<TKey, TValue>(row.MyKey, row.MyValue + "MySuffix") 
    Returns
    Type Description
    DictionaryTarget<TInput, TKey, TValue>

    The newly created and (optionally) linked worker.

    Type Parameters
    Name Description
    TInput

    The type of the incoming rows.

    TKey

    The type of the dictionary key.

    TValue

    The type of the dictionary value.

    Exceptions
    Type Condition
    ArgumentNullException

    selectKeyValueFunc

    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException

    workerParent - All workers must have a parent. The top level workers have the worker system as parent.

    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    DictionaryTarget<TInput, TKey, TValue>(in DownstreamFactory<TInput>, String, IDictionary<TKey, TValue>, Func<TInput, KeyValuePair<TKey, TValue>>, DictionaryAddKeyTreatment)

    Initializes a new instance of the DictionaryTarget<TInput, TKey, TValue> dataflow worker, which consumes incoming rows and adds selected values to an IDictionary<TKey,TValue>.

    The Input port is linked to (if available) the upstream output or error output port specified by the factory.

    Declaration
    public static DictionaryTarget<TInput, TKey, TValue> DictionaryTarget<TInput, TKey, TValue>(this in DownstreamFactory<TInput> downstreamFactory, string workerName, IDictionary<TKey, TValue> dictionary, Func<TInput, KeyValuePair<TKey, TValue>> selectKeyValueFunc, DictionaryAddKeyTreatment dictionaryAddKeyTreatment)
        where TInput : class
    Parameters
    Type Name Description
    DownstreamFactory<TInput> downstreamFactory

    The downstream factory, which specifies the parent worker and (optionally) the upstream port to link the "first" input port of this dataflow worker to.

    Get it from Link when the upstream port is known ahead of time (which is usually the case). Otherwise get it from GetDownstreamFactory<TInput>(), and link the transform or target explicitly using LinkTo(InputPort<TOutput>) or LinkFrom(OutputPortBase<TInput>).

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    IDictionary<TKey, TValue> dictionary

    The dictionary to store lookup items (from the incoming rows) into. Can be null, in which case either set Dictionary before the worker runs, or a Dictionary<TKey,TValue> will be automatically created when he worker runs.

    Func<TInput, KeyValuePair<TKey, TValue>> selectKeyValueFunc

    A callback function that receives a row as a parameter, and must return a key and value pair, from a column or a calculation, e.g.:

    public class MyRow
    {
        public int MyKey;
        public string MyValue;
        // Any other members...
    }
    
    // ...
    
    // selectKeyValueFunc:
    row => new KeyValuePair<TKey, TValue>(row.MyKey, row.MyValue + "MySuffix") 
    DictionaryAddKeyTreatment dictionaryAddKeyTreatment

    Specifies how to handle any duplicate keys returned by selectKeyValueFunc.

    Returns
    Type Description
    DictionaryTarget<TInput, TKey, TValue>

    The newly created and (optionally) linked worker.

    Type Parameters
    Name Description
    TInput

    The type of the incoming rows.

    TKey

    The type of the dictionary key.

    TValue

    The type of the dictionary value.

    Exceptions
    Type Condition
    ArgumentNullException

    selectKeyValueFunc

    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException

    workerParent - All workers must have a parent. The top level workers have the worker system as parent.

    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    DictionaryTarget<TInput, TKey, TValue>(in DownstreamFactory<TInput>, String, Func<TInput, KeyValuePair<TKey, TValue>>)

    Initializes a new instance of the DictionaryTarget<TInput, TKey, TValue> dataflow worker, which consumes incoming rows and adds selected values to an IDictionary<TKey,TValue>.

    Either set Dictionary before the worker runs, or a Dictionary<TKey,TValue> will be automatically created and used when the worker runs.

    Any duplicate key returned by selectKeyValueFunc will fail the worker with a Fatal state.

    The Input port is linked to (if available) the upstream output or error output port specified by the factory.

    Declaration
    public static DictionaryTarget<TInput, TKey, TValue> DictionaryTarget<TInput, TKey, TValue>(this in DownstreamFactory<TInput> downstreamFactory, string workerName, Func<TInput, KeyValuePair<TKey, TValue>> selectKeyValueFunc)
        where TInput : class
    Parameters
    Type Name Description
    DownstreamFactory<TInput> downstreamFactory

    The downstream factory, which specifies the parent worker and (optionally) the upstream port to link the "first" input port of this dataflow worker to.

    Get it from Link when the upstream port is known ahead of time (which is usually the case). Otherwise get it from GetDownstreamFactory<TInput>(), and link the transform or target explicitly using LinkTo(InputPort<TOutput>) or LinkFrom(OutputPortBase<TInput>).

    String workerName

    Name of the worker.

    Set to a prefix plus a trailing "/" (e.g. "MyPrefix-/") to generate a unique name from the prefix plus an increasing number starting at 1.

    While less useful, set to null, whitespace or "/" to generate a unique name from the worker type plus an increasing number starting at 1.

    The name cannot otherwise contain "/", and cannot start with double underscore "__".

    Func<TInput, KeyValuePair<TKey, TValue>> selectKeyValueFunc

    A callback function that receives a row as a parameter, and must return a key and value pair, from a column or a calculation, e.g.:

    public class MyRow
    {
        public int MyKey;
        public string MyValue;
        // Any other members...
    }
    
    // ...
    
    // selectKeyValueFunc:
    row => new KeyValuePair<TKey, TValue>(row.MyKey, row.MyValue + "MySuffix") 
    Returns
    Type Description
    DictionaryTarget<TInput, TKey, TValue>

    The newly created and (optionally) linked worker.

    Type Parameters
    Name Description
    TInput

    The type of the incoming rows.

    TKey

    The type of the dictionary key.

    TValue

    The type of the dictionary value.

    Exceptions
    Type Condition
    ArgumentNullException

    selectKeyValueFunc

    ArgumentException

    workerName:

    • Workers with the same parent must have unique names.
    • Worker and worker system names cannot contain '/' or start with double underscore '__'.
    ArgumentNullException

    workerParent - All workers must have a parent. The top level workers have the worker system as parent.

    InvalidOperationException
    • Cannot add child worker to parent which has completed. Are you adding it to the correct parent?
    • Cannot add worker to parent, since its children have been started. Are you adding it to the correct parent?

    See Also

    DictionaryTarget<TInput, TKey, TValue>
    IDictionary<TKey, TValue>
    In This Article
    Back to top Copyright © 2023 Envobi Ltd