Class DictionaryTarget<TInput, TKey, TValue>
A dataflow target that populates an IDictionary<TKey,TValue>, by default a Dictionary<TKey,TValue>.
The input rows can be of any type, and a function selects the key and value from each row. When the row only needs a key and value, consider using the immutable KeyValuePair<TKey,TValue> struct, or the mutable MutableKeyValue<TKey, TValue> class.
Note: Use the factory methods in DictionaryTargetFactory to create instances of this class.
Inheritance
Implements
Inherited Members
Namespace: actionETL
Assembly: actionETL.dll
Syntax
public class DictionaryTarget<TInput, TKey, TValue> : WorkerBase<DictionaryTarget<TInput, TKey, TValue>>, IDisposeOnFinished where TInput : class
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. |
Properties
Dictionary
Gets or sets the dictionary to store lookup items
(from the incoming rows) into.
If null when he worker runs, it will be set to an automatically created
Dictionary<TKey,TValue>.
The property can only be accessed when the worker is not running. The populated dictionary is only available after the worker has completed successfully.
Note: This property is thread-safe.
Note that the dictionary can optionally be set to null after the worker
has completed, to allow it to be garbage collected before the worker itself is garbage collected,
which in rare circumstances can be useful with a large collection.
Declaration
public IDictionary<TKey, TValue> Dictionary { get; set; }
Property Value
| Type | Description |
|---|---|
| IDictionary<TKey, TValue> | The dictionary. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Cannot get or set the value while the worker is running. |
InitialCapacity
Gets or sets the initial capacity if the worker creates the dictionary.
Set to less than 1 to get the default (7 items).
Consider setting a large capacity, ideally the exact number of unique keys that will be received,
to minimize allocations and copying. This does however increase up-front memory
utilization.
Cannot be set after the worker has started running.
Note: This property is thread-safe.
Declaration
public int InitialCapacity { get; set; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Cannot set the value after the worker has started running. |
Input
Gets the input port for receiving rows from an upstream worker.
Declaration
public InputPort<TInput> Input { get; }
Property Value
| Type | Description |
|---|---|
| InputPort<TInput> |
Methods
RunAsync()
This method can be overridden to add custom functionality to the derived worker that runs before
and after the row processing. In this case, the base class base.RunAsync() must
be called for the worker to function correctly.
Typically, this worker is used without overriding this method.
Declaration
protected override Task<OutcomeStatus> RunAsync()
Returns
| Type | Description |
|---|---|
| Task<OutcomeStatus> | A |