Beispiel #1
0
// Reduce
func (this *FileWorker) Reduce(key interface{}, values []interface{}) (kv mr.KeyValue) {
	const threhold = 0
	var occurence = stats.StatsSum(mr.ConvertAnySliceToFloat(values))
	if occurence > threhold {
		kv = mr.NewKeyValue()
		kv[NIL_KEY] = occurence
	}

	return
}
Beispiel #2
0
func (this *UniWorker) Reduce(key interface{}, values []interface{}) (kv mr.KeyValue) {
	// here we don't care about the key
	// we only care about values
	aggregate := stats.StatsSum(mr.ConvertAnySliceToFloat(values))
	if aggregate > 100 {
		kv = mr.NewKeyValue()
		kv[NIL_KEY] = aggregate
	}

	return
}
Beispiel #3
0
// The key is already sorted
func (this *KxiWorker) Reduce(key interface{}, values []interface{}) (kv mr.KeyValue) {
	kv = mr.NewKeyValue()
	switch key.(mr.GroupKey).Group() {
	case GROUP_URL_SERV:
		vals := mr.ConvertAnySliceToFloat(values)
		kv[TIME_ALL] = stats.StatsSum(vals)
		kv[TIME_MAX] = stats.StatsMax(vals)
		kv[TIME_TOP] = stats.StatsSumTopN(vals, topsum)
		kv[TIME_AVG] = stats.StatsMean(vals)
		kv[TIME_STD] = stats.StatsSampleStandardDeviationCoefficient(vals)
		kv[CALL_ALL] = float64(stats.StatsCount(vals))
	case GROUP_KXI:
		vals := mr.ConvertAnySliceToFloat(values)
		kv[TIME_ALL] = stats.StatsSum(vals)
		kv[TIME_MIN] = stats.StatsMin(vals)
		kv[TIME_TOP] = stats.StatsSumTopN(vals, topsum)
		kv[TIME_MAX] = stats.StatsMax(vals)
		kv[TIME_AVG] = stats.StatsMean(vals)
		kv[TIME_STD] = stats.StatsSampleStandardDeviationCoefficient(vals)
		kv[CALL_ALL] = float64(stats.StatsCount(vals))
	case GROUP_URL_RID:
		vals := mr.ConvertAnySliceToFloat(values)
		kv[CALL_ALL] = float64(stats.StatsCount(vals))
		kv[TIME_ALL] = stats.StatsSum(vals)
	case GROUP_URL_SQL:
		vals := mr.ConvertAnySliceToFloat(values)
		kv[CALL_ALL] = float64(stats.StatsCount(vals))
		kv[TIME_MAX] = stats.StatsMax(vals)
		kv[TIME_AVG] = stats.StatsMean(vals)
	case GROUP_URL:
		vals := mr.ConvertAnySliceToString(values) // rids of this url
		c := stats.NewCounter(vals)
		kv[REQ_ALL] = float64(len(c))
	}

	return
}