def groupby_size(columns, column_tys, grouping_columns, grouping_column_tys):
    """
    Groups the given columns by the corresponding grouping column
    value, and aggregate by summing values.

    Args:
        columns (List<WeldObject>): List of columns as WeldObjects
        column_tys (List<str>): List of each column data ty
        grouping_column (WeldObject): Column to group rest of columns by

    Returns:
          A WeldObject representing this computation
    """
    weld_obj = WeldObject(encoder_, decoder_)

    if len(grouping_columns) == 1 and len(grouping_column_tys) == 1:
        grouping_column_var = weld_obj.update(grouping_columns[0])
        if isinstance(grouping_columns[0], WeldObject):
            grouping_column_var = grouping_columns[0].weld_code
        grouping_column_ty_str = "%s" % grouping_column_tys[0]
    else:
        grouping_column_vars = []
        for column in grouping_columns:
            column_var = weld_obj.update(column)
            if isinstance(column_var, WeldObject):
                column_var = column_var.weld_code
            grouping_column_vars.append(column_var)
        grouping_column_var = ", ".join(grouping_column_vars)
        grouping_column_var = "zip(%s)" % grouping_column_var
        grouping_column_tys = [str(ty) for ty in grouping_column_tys]
        grouping_column_ty_str = ", ".join(grouping_column_tys)
        grouping_column_ty_str = "{%s}" % grouping_column_ty_str

    weld_template = """
    let group = sort(
      tovec(
        result(
          for(
            %(grouping_column)s,
            dictmerger[%(gty)s, i64, +],
            |b, i, e| merge(b, {e, 1L})
          )
        )
      ),
      |x:{%(gty)s, i64}, y:{%(gty)s, i64}| compare(x.$0, y.$0)
    );
    {
      map(
      group,
        |x:{%(gty)s,i64}| x.$0
      ),
      map(
        group,
        |x:{%(gty)s,i64}| x.$1
      )
    }
  """

    weld_obj.weld_code = weld_template % {"grouping_column": grouping_column_var,
                                          "gty": grouping_column_ty_str}
    return weld_obj
def groupby_size ( columns , column_tys , grouping_columns , grouping_column_tys ) : weld_obj = WeldObject ( encoder_ , decoder_ ) if len ( grouping_columns ) == 1 and len ( grouping_column_tys ) == 1 : grouping_column_var = weld_obj . update ( grouping_columns [ 0 ] ) if isinstance ( grouping_columns [ 0 ] , WeldObject ) : grouping_column_var = grouping_columns [ 0 ] . weld_code grouping_column_ty_str = "%s" % grouping_column_tys [ 0 ] else : grouping_column_vars = [ ] for column in grouping_columns : column_var = weld_obj . update ( column ) if isinstance ( column_var , WeldObject ) : column_var = column_var . weld_code grouping_column_vars . append ( column_var ) grouping_column_var = ", " . join ( grouping_column_vars ) grouping_column_var = "zip(%s)" % grouping_column_var grouping_column_tys = [ str ( ty ) for ty in grouping_column_tys ] grouping_column_ty_str = ", " . join ( grouping_column_tys ) grouping_column_ty_str = "{%s}" % grouping_column_ty_str weld_template = """
    let group = sort(
      tovec(
        result(
          for(
            %(grouping_column)s,
            dictmerger[%(gty)s, i64, +],
            |b, i, e| merge(b, {e, 1L})
          )
        )
      ),
      |x:{%(gty)s, i64}, y:{%(gty)s, i64}| compare(x.$0, y.$0)
    );
    {
      map(
      group,
        |x:{%(gty)s,i64}| x.$0
      ),
      map(
        group,
        |x:{%(gty)s,i64}| x.$1
      )
    }
  """ weld_obj . weld_code = weld_template % { "grouping_column" : grouping_column_var , "gty" : grouping_column_ty_str } return weld_obj
Groups the given columns by the corresponding grouping column
    value, and aggregate by summing values.

    Args:
        columns (List<WeldObject>): List of columns as WeldObjects
        column_tys (List<str>): List of each column data ty
        grouping_column (WeldObject): Column to group rest of columns by

    Returns:
          A WeldObject representing this computation