Exemple #1
0
func countDomainRows(acc []string, s string) []string {
	if len(acc) == 0 {
		row := util.LogRow{}
		util.StructFromString(s, &row)
		return []string{util.StructToString(outputRow{
			Domain: row.Domain,
			Count:  1,
		})}
	}
	row := outputRow{}
	util.StructFromString(acc[0], &row)
	row.Count = row.Count + 1
	return []string{util.StructToString(row)}
}
func outputRowsToStrings(outputRows []outputRow) []string {
	rows := []string{}
	for _, or := range outputRows {
		rows = append(rows, util.StructToString(or))
	}
	return rows
}
Exemple #3
0
func generateTestDataFile(
	directory string,
	rowCount int,
	timeOrigin int64, timeDistance int,
	uidCount int,
	domains domains,
	geoOrigin util.GeoPoint, geoDistance int,
) (filename string, err error) {
	output := ""
	for i := 0; i < rowCount; i++ {
		row := generateTestDataRow(
			timeOrigin, timeDistance,
			uidCount,
			domains,
			geoOrigin, geoDistance,
		)
		rowOutput := util.StructToString(row)
		output = output + rowOutput + "\n"
	}
	filename = generateFilename()
	err = ioutil.WriteFile(directory+"/"+filename, []byte(output), 0644)
	return filename, err
}