diff --git a/27-functional-programming/log-parser-exp/Makefile b/27-functional-programming/log-parser-exp/Makefile index 87685d5..1a795c2 100644 --- a/27-functional-programming/log-parser-exp/Makefile +++ b/27-functional-programming/log-parser-exp/Makefile @@ -1,25 +1,29 @@ SHELL := /bin/bash -LINES = echo -e ">> log.txt has $$(wc -l log.txt | cut -f1 -d' ') lines" +LINES = $$(wc -l log.txt | cut -f1 -d' ') +ECHO_LINES = echo -e ">> log.txt has $(LINES) lines" -ifeq ($(n),) - n := 18 -endif - -s: +s: time go run . < log.txt -r: +r: go run . < log.txt -# make n=18 +n ?= 18 load: restore - @echo "enlarging the file with itself, please wait..." - @for i in {1..$(n)}; do awk 1 log.txt log.txt > log_.txt; mv log_.txt log.txt; rm -f log_.txt; done - @$(LINES) + @echo "enlarging the file with itself, please wait..." + + @for i in {1..$(n)}; do \ + awk 1 log.txt log.txt > log_.txt; \ + mv log_.txt log.txt; \ + rm -f log_.txt; \ + done + + @$(ECHO_LINES) restore: - @$(LINES) - git checkout log.txt - + @echo "restoring the file..." + @git checkout log.txt + @$(ECHO_LINES) + lines: - @$(LINES) \ No newline at end of file + @$(ECHO_LINES) \ No newline at end of file diff --git a/27-functional-programming/log-parser-exp/main.go b/27-functional-programming/log-parser-exp/main.go index 6f1524d..77bfc34 100644 --- a/27-functional-programming/log-parser-exp/main.go +++ b/27-functional-programming/log-parser-exp/main.go @@ -41,6 +41,14 @@ Result -> report.Line notUsing = report.Not +pl := newPipeline(pipeOpts{ + from: fastTextReader(os.Stdin), + filterBy: notUsing(domainExtFilter("com", "io")), + groupBy: domainGrouper, +}) + +err := pl.start() + _, err := report.New(). From(report.TextReader(os.Stdin)). To(report.TextWriter(os.Stdout)).