Record Comparator
File Compare can be customizied with user logic to compare columns, custom logic for the record comparison can be provided.
Such logic must be coded in a a record comparator which must implement the HPE.Ianus.Scripting.IRecordComparator
interface.
namespace HPE.Ianus.Scripting
{
public interface IRecordComparator
{
int Compare(LoggerFacade log, Record left, Record right);
}
}
Therefore it must implement the method Compare
, that takes care of comparing the left and right records and return the comparison result.
The method Compare
receives the following input parameters:
Parameter | Description |
---|---|
log | LoggerFacade object to write entries in the job log |
left | Left Record object |
right | Right Record object |
Once data is compared, the method should return an integer value indicating the comparison result:
Return code | Meaning |
---|---|
<0 | The left record is less than right record (left < right) |
0 | Records are equal (left=right) |
>0 | The right record is greater than left record (left > right) |
The comparator class can be coded in C# when embedded as script, and in any .NET language (including COBOL if available) when provided as DLL.
Note
Ianus provides data to the Compare
method exactly as it reads from the files. Therefore, in case of EBCDIC files, the user code needs to handle any necessary code page conversion.
Example
namespace ExternalCompareCS
{
public class TestComparator01 : HPE.Ianus.Scripting.IRecordComparator
{
public int Compare(LoggerFacade log, Record left, Record right)
{
return left.Bytes[0].CompareTo(right.Bytes[0]);
}
}
}