Class RepeatRowsSource<TOutput>
A dataflow worker that generates an arbitrary number of rows, often used for
testing, debugging etc. The caller provides template rows as an
IEnumerable
, or as rows specified in the constructor, which are
by default repeatedly cloned (using
CreateDeepCloneFunc()) in a
round-robin fashion, to generate and pass the output rows to a downstream worker.
This way, only the new cloned rows with distinct references are sent downstream.
Note: When cloning rows (the default), all mapped column data types must support multi-copy. To only select some columns for copying, use ColumnMapperCommandAction.
Alternatively, you can set SendTemplateRows to true
to instead repeatedly send the template rows as is downstream.
Note that if true
and TotalNumberOfRows is larger than
the number of template rows, the same row object reference will be sent multiple
times, which is strongly discouraged unless the row type is immutable,
or you can guarantee that no downstream worker will modify the rows.
See Row Ownership
for details.
By default, all (readable and writable) columns in the template rows are included in the cloning. Use ColumnMapperCommandAction to only clone selected columns.
Implements
Inherited Members
Namespace: actionETL
Assembly: actionETL.dll
Syntax
public class RepeatRowsSource<TOutput> : WorkerBase<RepeatRowsSource<TOutput>>, IDisposeOnFinished where TOutput : class
Type Parameters
Name | Description |
---|---|
TOutput | The type of each |
Constructors
RepeatRowsSource(WorkerParent, String, Func<Boolean>, Int64, TOutput[])
Initializes a new instance of the RepeatRowsSource<TOutput> dataflow worker that generates an arbitrary number of rows by cloning provided template rows, and passes them to a downstream worker.
Declaration
public RepeatRowsSource(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, long totalNumberOfRows, params TOutput[] rows)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<Boolean> | isStartableFunc | Function to calculate the worker start constraint; it should return |
Int64 | totalNumberOfRows | The total number of rows to generate. |
TOutput[] | rows | The template rows to generate output rows from. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
InvalidOperationException |
|
RepeatRowsSource(WorkerParent, String, Func<Boolean>, Int64, IEnumerable<TOutput>)
Initializes a new instance of the RepeatRowsSource<TOutput> dataflow worker that generates an arbitrary number of rows by cloning provided template rows, and passes them to a downstream worker.
Declaration
public RepeatRowsSource(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, long totalNumberOfRows, IEnumerable<TOutput> rows)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<Boolean> | isStartableFunc | Function to calculate the worker start constraint; it should return |
Int64 | totalNumberOfRows | The total number of rows to generate. |
IEnumerable<TOutput> | rows | The enumerable with template rows to generate output rows from. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
InvalidOperationException |
|
RepeatRowsSource(WorkerParent, String, Int64, TOutput[])
Initializes a new instance of the RepeatRowsSource<TOutput> dataflow worker that generates an arbitrary number of rows by cloning provided template rows, and passes them to a downstream worker.
Declaration
public RepeatRowsSource(WorkerParent workerParent, string workerName, long totalNumberOfRows, params TOutput[] rows)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Int64 | totalNumberOfRows | The total number of rows to generate. |
TOutput[] | rows | The template rows to generate output rows from. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
InvalidOperationException |
|
RepeatRowsSource(WorkerParent, String, Int64, IEnumerable<TOutput>)
Initializes a new instance of the RepeatRowsSource<TOutput> dataflow worker that generates an arbitrary number of rows by cloning provided template rows, and passes them to a downstream worker.
Declaration
public RepeatRowsSource(WorkerParent workerParent, string workerName, long totalNumberOfRows, IEnumerable<TOutput> rows)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Int64 | totalNumberOfRows | The total number of rows to generate. |
IEnumerable<TOutput> | rows | The enumerable with template rows to generate output rows from. |
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
InvalidOperationException |
|
Properties
ColumnMapperCommandAction
Gets or sets the column mapping. Defaults to mapping all columns, i.e.
cb => cb.AutoName()
. Set this property to only map selected columns,
see Dataflow Column Mapping
for details.
Columns that are not mapped will retain their default value in the output rows,
which can be used to avoid copying SingleShallow
columns (which would fail).
Cannot be set after the worker has started running.
Column name matching is ordinal case insensitive, but a case sensitive match takes precedence over a case insensitive match.
Note: This property is thread-safe.
Declaration
public Action<IColumnMapperCommand> ColumnMapperCommandAction { get; set; }
Property Value
Type | Description |
---|---|
Action<IColumnMapperCommand> |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Cannot set the value after the worker has started running. |
Output
Gets the output port for sending rows to the downstream worker.
Declaration
public OutputPort<TOutput> Output { get; }
Property Value
Type | Description |
---|---|
OutputPort<TOutput> |
Rows
Sets an enumerable that contains or produces the template rows. This overwrites any template rows specified in the constructor. Cannot be set after the worker has started running.
Note: This property is thread-safe.
Declaration
public IEnumerable<TOutput> Rows { set; }
Property Value
Type | Description |
---|---|
IEnumerable<TOutput> |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Cannot set the value after the worker has started running. |
SendTemplateRows
Gets or sets whether to repeatedly send the template rows as is (true
),
or repeatedly clone them and only send cloned rows (false
, the default).
Note that if true
and TotalNumberOfRows is larger than
the number of template rows, the same row object reference will be sent multiple
times, which is strongly discouraged unless the row type is immutable,
or you can guarantee that no downstream worker will modify the rows.
See Row Ownership
for details.
Note: This property is thread-safe.
Declaration
public bool SendTemplateRows { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Cannot set the value after the worker has started running. |
TotalNumberOfRows
Get or sets the total number of rows to generate. Cannot be set after the worker has started running.
Note: This property is thread-safe.
Declaration
public long TotalNumberOfRows { get; set; }
Property Value
Type | Description |
---|---|
Int64 |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Cannot set the value after the worker has started running. |
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 async Task<OutcomeStatus> RunAsync()
Returns
Type | Description |
---|---|
Task<OutcomeStatus> | A |