예제 #1
0
func (d *Dataset) sendToExternalOutputChans(t reflect.Value) {
	for _, ch := range d.ExternalOutputChans {
		elemType := ch.Type().Elem()
		t = io.CleanObject(t, d.Type, elemType)
		ch.Send(t)
	}
}
예제 #2
0
func (s *Scheduler) setupOutputChannels(shards []*flow.DatasetShard, waitGroup *sync.WaitGroup) {
	for _, shard := range shards {
		ds := shard.Parent
		if len(ds.ExternalOutputChans) == 0 {
			continue
		}
		// connect remote raw chan to local typed chan
		readChanName := shard.Name()
		location := s.datasetShard2Location[readChanName]
		rawChan, err := io.GetDirectReadChannel(readChanName, location.URL())
		if err != nil {
			log.Panic(err)
		}
		for _, out := range ds.ExternalOutputChans {
			ch := make(chan reflect.Value)
			io.ConnectRawReadChannelToTyped(rawChan, ch, ds.Type, waitGroup)
			waitGroup.Add(1)
			go func() {
				defer waitGroup.Done()
				for v := range ch {
					v = io.CleanObject(v, ds.Type, out.Type().Elem())
					out.Send(v)
				}
			}()
		}
	}
}