Hardly, one would find blogs/articles/tutorials on Ab Initio transformation functions. I introduce you to another set of functions which will make you understands vectors in a different way.
Suppose, there is data file whose record format has 5 fields, namely A, B, C and D. Let us give them useful meaning, A – student_id, B – student_nm, C – sem_num, D – subject_name, E – marks.
There will be a possibility that combination of A, B remains the same across several records in the data, whereas remaining columns may change. For instance, student Mr. X has 3 subjects in semester 1, whereas Mr. Y has 4 subjects in semester 2 and Mr. Z also having 4 subjects, but in semester 2.
What if there’s a need to consolidate so much information in a single record and present it as a report. This report must have Student Name, Student Id, Semesters covered so far (comma-delimited), Courses taken (pipe-delimited) and Average Marks.
The following transformation rule uses string_join() and vector_sort_dedup_first() to solve the purpose, i.e. to get an output string of pipe-delimited vector elements.
out.target_field :: string_join(vector_sort_dedup_first(in), "|");
One can create user-defined function which wraps the above functionality, which would be generic enough to be used in any transformation where vectors are involved.
out :: get_delim_vec_ele(input_vec, delim) begin out :: string_join(vector_sort_dedup_first(input_vec), delim); end;
This function takes 2 arguments, input vector and delimiter to form delimited string of vector elements as output. So, your actual transformation can now look like;
out.target_field :: get_delim_vec_ele(in, "|");
Hope this helps