PageRenderTime 13ms CodeModel.GetById 9ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Count.groovy

http://groovy-log-analyzer.googlecode.com/
Groovy | 38 lines | 34 code | 4 blank | 0 comment | 5 complexity | 4e1765c5e38fb33334c76a3f4423f3cd MD5 | raw file
 1def countTypesTable = [ : ]
 2
 3count = {ln, type, categorizationFunction ->
 4        def c = categorizationFunction(ln)
 5        def table = countTypesTable[type]
 6        if(!table){
 7                table = [:]
 8                countTypesTable[type]=table
 9        }
10        if(c)
11        {
12                table[c]=(table[c]?:0)+1
13        }
14}
15
16countResult= {type ->
17       def res = countTypesTable[type] 
18       def total = 0
19       res.each{total+=it.value}
20       res["total"]=total
21       return res
22}
23
24printUnknownRequests = { ln, categorizationFunction ->
25        def c = categorizationFunction(ln)
26        if (c == "UNKNOWN_REQUEST")
27                println ln
28}
29
30def accumulateTypesTable = [ : ]
31accumulate = {ln, type, numberFunction ->
32        def n = numberFunction(ln)
33        if(!n) return
34        accumulateTypesTable[type] = n + accumulateTypesTable[type]?:0
35}
36accumulateResult = {type ->
37        return accumulateTypesTable[type]
38}