Search

Home

Home

COMPUTING

COMPUTING

The COMPUTING operator enables the execution of computational operations and data transformations using algorithms written in C#, operating on bits of the data bus.

The COMPUTING operator provides full flexibility for data transformation and serves as a powerful tool for implementing custom business logic in GRAVITY processes.

Within a single operator, it is possible to define multiple processing operations. These operations are executed sequentially, allowing subsequent operations to use the results of earlier processing steps within the same record.

The operator does not create new bits—each result must be assigned to a bit that already exists on the data bus.

The COMPUTING operator:

  • executes the defined algorithm,
  • writes the result to a previously specified data bus bit.

Processing is performed for each record of the input data bus. The user can define any number of operations, each of which operates on bits that have already been modified by previous operations.

An example of a GRAVITY project using the COMPUTING operator:

image

OPERATOR CONFIGURATION

The operator is configured by selecting the column to which the value returned by the algorithm will be assigned.

The algorithm must be written in C#. The algorithm constitutes the body of a function, which must return a value whose data type is identical to the type of the selected column. For example, for a column named invoice_number of type Text, the algorithm entered in the operator must return a value of type string and will form the body of the function:

private string func_23()

Therefore, the algorithm must return a string value:

return "invoiceNumber";

By default, the following using declarations are available to the algorithm:

"System",
"System.Xml",
"System.Xml.Linq",
"System.Data",
"System.Linq",
"System.Collections",
"System.Collections.Generic",
"System.Windows",
"System.Windows.Forms",
"System.Data.Common",
"System.Text",
"Newtonsoft.Json.Linq",
"MongoDB.Bson"

To add processing for a selected bit, click an empty row in the list and, in the Column field, select the column for which you will define a processing algorithm that returns a new value for that column.

image

Enter the algorithm in C#. In the algorithm, you can use data from the data bus bits (the record currently being processed), aggregations (the entire data bus), as well as project parameters and global variables, by selecting the appropriate function or parameter name.

image

Available functions:

  • GET_VALUE → the value of the selected data bus column
  • GET_AGGR → the sum of the values in the selected data bus column, across all input data
  • GET_OUTTEMP_AGGR → the sum of the values in the data column collected in the OUTPUT_TEMPORARY set
  • IS_OPERATOR_EXECUTED → returns true if the selected operator used in the project has already been executed, and false if it has not.

Place the mouse cursor where you want to insert a function, select the function from the drop-down list.

After selecting a function, use the insert value button.

image

For the selected function, you will see a wizard where you must choose the data bus bit whose value you want to use and confirm inserting it into the algorithm by clicking Insert.

image

You can now test the algorithm using the Test button.

image

If everything is correct, you will see the Result tab with the algorithm output.

image

If you made a mistake—for example, in the C# syntax—you will see an error message.

image
icon
During algorithm testing, default values are substituted for function return values and project parameters. The following default values are used for each data type:

DateTime → DateTime.Now string → "Text" double → 1.0 int → 1; bool → true

icon
Algorithms are processed in the order they are added. As a result, bits used in subsequent algorithms already have the values assigned by earlier algorithms.