Exemple #1
0
func (e *Edge) CollectMaps(m *MapResult) error {
	if wlog.LogLevel() == wlog.DEBUG {
		// Explicitly check log level since this is expensive and frequent
		e.logger.Printf(
			"D! collect maps c: %s e: %s\n",
			e.statMap.Get(statCollected),
			e.statMap.Get(statEmitted),
		)
	}
	e.statMap.Add(statCollected, 1)
	select {
	case <-e.aborted:
		return ErrAborted
	case e.reduce <- m:
		return nil
	}
}
Exemple #2
0
func (e *Edge) CollectBatch(b models.Batch) error {
	if wlog.LogLevel() == wlog.DEBUG {
		// Explicitly check log level since this is expensive and frequent
		e.logger.Printf(
			"D! collect batch c: %s e: %s\n",
			e.statMap.Get(statCollected),
			e.statMap.Get(statEmitted),
		)
	}
	e.statMap.Add(statCollected, 1)
	select {
	case <-e.aborted:
		return ErrAborted
	case e.batch <- b:
		return nil
	}
}
Exemple #3
0
func (e *Edge) NextMaps() (m *MapResult, ok bool) {
	if wlog.LogLevel() == wlog.DEBUG {
		// Explicitly check log level since this is expensive and frequent
		e.logger.Printf(
			"D! next maps c: %s e: %s\n",
			e.statMap.Get(statCollected),
			e.statMap.Get(statEmitted),
		)
	}
	select {
	case <-e.aborted:
	case m, ok = <-e.reduce:
		if ok {
			e.statMap.Add(statEmitted, 1)
		}
	}
	return
}
Exemple #4
0
func (e *Edge) NextBatch() (b models.Batch, ok bool) {
	if wlog.LogLevel() == wlog.DEBUG {
		// Explicitly check log level since this is expensive and frequent
		e.logger.Printf(
			"D! next batch c: %s e: %s\n",
			e.statMap.Get(statCollected),
			e.statMap.Get(statEmitted),
		)
	}
	select {
	case <-e.aborted:
	case b, ok = <-e.batch:
		if ok {
			e.statMap.Add(statEmitted, 1)
		}
	}
	return
}