| a | b | |
|---|
| 0 | + | function(keys, values, rereduce) { |
|---|
| 0 | + | |
|---|
| 0 | + | |
|---|
| 0 | + | var ucount = 0; |
|---|
| 0 | + | var seen = new Object(); |
|---|
| 0 | + | |
|---|
| 0 | + | if (!rereduce) { |
|---|
| 0 | + | // This is the reduce phase, we are reducing over emitted values from |
|---|
| 0 | + | // the map functions. |
|---|
| 0 | + | |
|---|
| 0 | + | // we count 1 if a given uname has not been seen |
|---|
| 0 | + | |
|---|
| 0 | + | for(var i in values) { |
|---|
| 0 | + | if (seen[values[i][0]] == undefined) { |
|---|
| 0 | + | seen[values[i][0]] = 1; |
|---|
| 0 | + | ucount += 1; |
|---|
| 0 | + | } |
|---|
| 0 | + | } |
|---|
| 0 | + | |
|---|
| 0 | + | } |
|---|
| 0 | + | else { |
|---|
| 0 | + | // This is the rereduce phase, we are re-reducing previosuly |
|---|
| 0 | + | // reduced values. |
|---|
| 0 | + | for(var i in values) { |
|---|
| 0 | + | // loop around seen object values |
|---|
| 0 | + | |
|---|
| 0 | + | for(var j in values[i][1]) { |
|---|
| 0 | + | if (seen[j] == undefined) { |
|---|
| 0 | + | seen[j] = 1; |
|---|
| 0 | + | ucount += 1; |
|---|
| 0 | + | } |
|---|
| 0 | + | } |
|---|
| 0 | + | } |
|---|
| 0 | + | } |
|---|
| 0 | + | return [ucount, seen]; |
|---|
| 0 | + | } |
|---|
| ... | |
|---|