} } func main() { //WC() //Top10() //textSearch() saveTextFile() } var fnMap_line = gopark.NewMapperFunc("fnMap_line", func(x interface{}) interface{} { return strings.TrimSpace(x.(string)) }) var filter_fn = gopark.NewFilterFunc("filter_fn", func(x interface{}) bool { return strings.Contains(x.(string), "glog") }) var filter_fatal = gopark.NewFilterFunc("filter_fatal", func(x interface{}) bool { return strings.Contains(x.(string), "Fatal") }) var filter_info = gopark.NewFilterFunc("filter_info", func(x interface{}) bool { return strings.Contains(x.(string), "Info") }) func init() { gopark.RegisterFunc(fnMap_line) gopark.RegisterFunc(filter_fn) gopark.RegisterFunc(filter_fatal) gopark.RegisterFunc(filter_info)
gopark.RegisterFunc(random_once) gopark.RegisterFunc(map_func) gopark.RegisterFunc(flatmap_func) gopark.RegisterFunc(reducer_func) gopark.RegisterFunc(filter_func) gopark.RegisterFunc(less_func) } var map_func = gopark.NewMapperFunc("map_func", func(x interface{}) interface{} { return &gopark.KeyValue{x, 1} }) var filter_func = gopark.NewFilterFunc("filter_func", func(x interface{}) bool { result := x.(*gopark.KeyValue).Value.(int) > 30 return result }) var less_func = gopark.NewLessFunc("less_func", func(x, y interface{}) bool { a := x.(*gopark.KeyValue).Value.(int) b := y.(*gopark.KeyValue).Value.(int) return a < b }) func testTextFile() { flag.Parse() ctx := gopark.NewContext("gopark") defer ctx.Stop() p := "." txt := ctx.TextFileExt(p, "")