Unpack

Extracts an embedded relation from the specified attribute of a parent relation.

Usage

unpack (indata, attribute : outdata)

Details

Extracts an embedded relation outdata from the attribute of the relation indata. Unpacking is sometimes necessary after an aggregate function or when handling data that previously packed for other reasons.

Notes

Known Bugs

Example

Using the input:
      RELATION books: title char, author char, pub_date date, pages number
      Title1|Author1|09-01-1991|34
      Title2|Author2|12-23-1954|479
      Title3|Author2|05-09-2002|733
      Title4|Author3|01-01-1968|32
      Title5|Author2|07-03-2001|1152
    
and the externally compiled MyFunctions.java that contains:
      import java.text.*;
      import java.util.*;
  
      public class MyFunctions
      {
        public static double average (ArrayList a_data)
        {
          double sum = 0;
          for (int i=0; i<a_data.size(); i++) {
            sum += Double.parseDouble(a_data.get(i).toString());
          }
          return sum/((double)a_data.size());
        }
      }
    
when executing the plan:
      PLAN test
      {
        INPUT: stream books
        OUTPUT: stream result
  
        BODY
        {
          aggregate (books, "Uaggregate.average(pages)", "old_rel", "avg_pages" : post-agg)
          unpack (post-agg, "old_rel" : result)
        }
      }
    
generates the following output:
      ----------------------------------------------
      RELATION: uunpack1_result
         attrs: title, author, pub_date, pages
      ----------------------------------------------
      Title1|Author1|09-01-1991|34
      Title3|Author2|05-09-2002|733
      Title4|Author3|01-01-1968|32
      Title5|Author2|07-03-2001|1152
      Title2|Author2|12-23-1954|479
      ----------------------------------------------