Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
if (((String)globalMap.get("PreviousHHID")).equals(input_row.hhid))
globalMap.put("SeqNum",(Integer)globalMap.get("SeqNum")+1);
else
globalMap.put("SeqNum",1);
output_row.hhid = input_row.hhid;
output_row.seqnum = (Integer)globalMap.get("SeqNum");
output_row.city = input_row.city;
output_row.state = input_row.state;
globalMap.put("PreviousHHID",input_row.hhid);
The suggested approach creates a new variable for each HHID so you will run out of memory if there are a large number of unique HHIDs in your data.
A better way might be to replace your tMap with a tFilterColumns to simplify your flow to just (hhid, city, state) before you sort it and then use a tJavaRow to create the sequence along these lines:if (((String)globalMap.get("PreviousHHID")).equals(input_row.hhid))
globalMap.put("SeqNum",(Integer)globalMap.get("SeqNum")+1);
else
globalMap.put("SeqNum",1);
output_row.hhid = input_row.hhid;
output_row.seqnum = (Integer)globalMap.get("SeqNum");
output_row.city = input_row.city;
output_row.state = input_row.state;
globalMap.put("PreviousHHID",input_row.hhid);
I dont know how many rows you're processing but try the option "sort on disk" for the tSort component