You are on page 1of 5

Scan with rollup:

Scan with rollup as the names implies that it functions both as rollup and scan component i.e,
from the out port we get the cumulative summary of the input record for the group it belongs
as scan component and from the rollup component we get the summary of the input group in
the output record.

Properties of Scan with rollup:

Sorted-input: There are 2 values for this parameter. When set to “Input must be sorted or
grouped”, the component requires grouped inputs which are sorted. This is the default option
for this parameter. When set to “In-memory: Input need not be sorted”, the component
accepts ungrouped input and it requires use of max_core parameter.
Key-method: Method by which component group records. There are 2 options for this
parameter.
Use Key Specifier
Use Key_change function
Key: Name of the key fields, that the component will use to group records are mentioned
here. This parameter is available only when Key method parameter is set as “Use Key
specifier”.
Max-core: Maximum memory usage in bytes. Default is 10MB.
Check-sort: If you use a key specifier, this parameter indicates whether or not to abort
execution on the first input record that is out of sorted order.
Transform: The name of the file containing the types and transform functions, or a transform
string.
Logging: Specifies whether or not to log component events.
Sample Graph

Example 1
To Assign sequence Number & cumulative sum from Scan output port and
the sum fo each cust_id group from rollup output:
Input
record
decimal("|") cust_id;
string("|") cust_name;
decimal("|") bill_no;
decimal("\n") amount;
end
Code in Transform
type temporary_type=record
decimal(4) SeqNo;
decimal(8) Sum;end; /*Temporary variable*/
temp :: initialize(in) =
begin
temp.SeqNo :: 0;
temp.Sum :: 0;
end;

temp :: scan(temp, in) =


begin
temp.SeqNo :: temp.SeqNo+1;
temp.Sum :: temp.Sum+in.amount;
end;

out :: finalize(temp, in) =


begin
out.Sno:: temp.SeqNo;
out.*:: in.*;
out.Total_amount :: temp.Sum;
end;

rollup :: rollup_finalize(temp, in) =


begin
rollup.Total_amount :: temp.Sum;
rollup.* :: in.*;
end;

Output
Scan Output port
record
decimal("|") Sno;
decimal("|") cust_id;
string("|") cust_name;
decimal("|") bill_no;
decimal("|") amount;
decimal("\n") Total_amount;
end

Rollup output port


record
decimal("|") cust_id;
string("|") cust_name;
decimal("|") bill_no;
decimal("\n") Total_amount;
end
*******************************************************************

Example 2
To show key_change function:
Input
record
decimal("|") cust_id;
string("|") cust_name;
decimal("|") bill_no;
decimal("\n") amount;
end

Key specifier - cust_id not specified in parameters.

Code in Transform:
type temporary_type=record
decimal(4) SeqNo;
decimal(8) Sum;end; /*Temporary variable*/
temp :: initialize(in) =
begin
temp.SeqNo :: 0;
temp.Sum :: 0;
end;

temp :: scan(temp, in) =


begin
temp.SeqNo :: temp.SeqNo+1;
temp.Sum :: temp.Sum+in.amount;
end;

out :: finalize(temp, in) =


begin
out.Sno:: temp.SeqNo;
out.*:: in.*;
out.Total_amount :: temp.Sum;
end;

rollup :: rollup_finalize(temp, in) =


begin
rollup.Total_amount :: temp.Sum;
rollup.* :: in.*;
end;

Output
Scan Output port
record
decimal("|") Sno;
decimal("|") cust_id;
string("|") cust_name;
decimal("|") bill_no;
decimal("|") amount;
decimal("\n") Total_amount;
end

Rollup output port


record
decimal("|") cust_id;
string("|") cust_name;
decimal("|") bill_no;
decimal("\n") Total_amount;
end

*******************************************************************

You might also like