code: func mergeGroupCounts(a, b []GroupCount, limit int) []GroupCount {
  	if limit > len(a)+len(b) {
  		limit = len(a) + len(b)
  	}
  	ret := make([]GroupCount, 0, limit)
  	i, j := 0, 0
  	for i < len(a) && j < len(b) && len(ret) < limit {
  		switch a[i].Compare(b[j]) {
  		case -1:
  			ret = append(ret, a[i])
  			i++
  		case 0:
  			a[i].Count += b[j].Count
  			ret = append(ret, a[i])
  			i++
  			j++
  		case 1:
  			ret = append(ret, b[j])
  			j++
  		}
  	}
  	for ; i < len(a) && len(ret) < limit; i++ {
  		ret = append(ret, a[i])
  	}
  	for ; j < len(b) && len(ret) < limit; j++ {
  		ret = append(ret, b[j])
  	}
  	return ret
  }
docs: // mergeGroupCounts merges two slices of GroupCounts throwing away any that go
  // beyond the limit. It assume that the two slices are sorted by the row ids in
  // the fields of the group counts. It may modify its arguments.