Skip to content
This repository has been archived by the owner on Jul 25, 2018. It is now read-only.

Commit

Permalink
Merge pull request #31 from rcoh/master
Browse files Browse the repository at this point in the history
Assorted improvements
  • Loading branch information
rcoh authored Mar 2, 2017
2 parents 66ad8be + 51cb6e9 commit 62ef874
Show file tree
Hide file tree
Showing 6 changed files with 3,065 additions and 32 deletions.
17 changes: 11 additions & 6 deletions average/Average.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,17 @@ func currentState(a average) map[string]interface{} {
func (a average) Process(inp map[string]interface{}) {
a.mu.Lock()
defer a.mu.Unlock()
v, keyInMap := inp[a.key]
if keyInMap {
f, keyIsNumber := strconv.ParseFloat(fmt.Sprint(v), 64)
if keyIsNumber == nil {
*a.samples += 1
*a.sum += f
if util.IsPlus(inp) || util.IsRelation(inp) {
v, keyInMap := inp[a.key]
if keyInMap {
f, keyIsNumber := strconv.ParseFloat(fmt.Sprint(v), 64)
if keyIsNumber == nil {
*a.samples += 1
*a.sum += f
}
}
} else if util.IsStartRelation(inp) {
*a.samples = 0
*a.sum = 0
}
}
6 changes: 5 additions & 1 deletion count/Count.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ func currentState(ct count) map[string]interface{} {
func (ct count) Process(inp map[string]interface{}) {
ct.mu.Lock()
defer ct.mu.Unlock()
if util.IsPlus(inp) {
if util.IsStartRelation(inp) {
*ct.ct = 0
} else if util.IsEndRelation(inp) {
//ct.Flush()
} else if util.IsPlus(inp) || util.IsRelation(inp) {
*ct.ct += 1
}
}
Loading

0 comments on commit 62ef874

Please sign in to comment.