// Run tries to be short. func (task Dummy) Run() error { file := dagger.Output(task).MustCreateLocalTarget() defer file.Close() for _, p := range dagger.Input(task).PathList() { if _, err := io.WriteString(file, fmt.Sprintf("OK\t%s\n", p)); err != nil { return err } } return nil }
// Run creates the data. func (task BogusData) Run() error { file, err := dagger.Output(task).CreateLocalTarget() if err != nil { return err } defer file.Close() for i := 0; i < task.Length; i++ { var vals []string for j := 0; j < task.Cols; j++ { vals = append(vals, strconv.Itoa(rand.Intn(1000))) } if _, err := io.WriteString(file, strings.Join(vals, "\t")+"\n"); err != nil { return err } } return nil }
func (task BogusAggregation) Run() error { scanner, err := dagger.Input(task).Scanner() if err != nil { return err } var sum int for scanner.Scan() { fields := strings.Fields(scanner.Text()) v, err := strconv.Atoi(fields[task.Col]) if err != nil { return err } sum += v } file, err := dagger.Output(task).CreateLocalTarget() if err != nil { return err } defer file.Close() _, err = io.WriteString(file, fmt.Sprintf("%d\n", sum)) return err }