/Count.groovy
http://groovy-log-analyzer.googlecode.com/ · Groovy · 38 lines · 34 code · 4 blank · 0 comment · 5 complexity · 4e1765c5e38fb33334c76a3f4423f3cd MD5 · raw file
- def countTypesTable = [ : ]
-
- count = {ln, type, categorizationFunction ->
- def c = categorizationFunction(ln)
- def table = countTypesTable[type]
- if(!table){
- table = [:]
- countTypesTable[type]=table
- }
- if(c)
- {
- table[c]=(table[c]?:0)+1
- }
- }
-
- countResult= {type ->
- def res = countTypesTable[type]
- def total = 0
- res.each{total+=it.value}
- res["total"]=total
- return res
- }
-
- printUnknownRequests = { ln, categorizationFunction ->
- def c = categorizationFunction(ln)
- if (c == "UNKNOWN_REQUEST")
- println ln
- }
-
- def accumulateTypesTable = [ : ]
- accumulate = {ln, type, numberFunction ->
- def n = numberFunction(ln)
- if(!n) return
- accumulateTypesTable[type] = n + accumulateTypesTable[type]?:0
- }
- accumulateResult = {type ->
- return accumulateTypesTable[type]
- }