MCPcopy
hub / github.com/chrislusf/glow / Map

Method Map

flow/dataset_map.go:19–33  ·  view source on GitHub ↗

map can work with multiple kinds of inputs and outputs Input Types: 1. single value 2. (key, value) : Most common format for key value pair 3. (key, values) : GroupByKey() outputs 4. (key, values1, values2) : CoGroup() outputs 5. (key, value1, value2) : Join() outputs Output Types: 1. return single

(f interface{})

Source from the content-addressed store, hash-verified

17// 3. return no value
18// 4. return no value, but last parameter is a output channel
19func (d *Dataset) Map(f interface{}) *Dataset {
20 outType := guessFunctionOutputType(f)
21 ret, step := add1ShardTo1Step(d, outType)
22 step.Name = "Map"
23 step.Function = func(task *Task) {
24
25 invokeMapFunc := _buildMapperFunction(f, task)
26
27 for input := range task.InputChan() {
28 invokeMapFunc(input)
29 }
30 // println("exiting d:", d.Id, "step:", step.Id, "task:", task.Id)
31 }
32 return ret
33}
34
35func _buildMapperFunction(f interface{}, task *Task) func(input reflect.Value) {
36 fn, ft := reflect.ValueOf(f), reflect.TypeOf(f)

Callers 15

TestMapSingleParameterFunction · 0.80
TestGroupByKeyMapFunction · 0.80
TestCoGroupMapFunction · 0.80
SourceFunction · 0.80
mainFunction · 0.80
testBasicMapReduceFunction · 0.80
testPartitionAndSortFunction · 0.80
testSelfJoinFunction · 0.80
testJoinFunction · 0.80
testInputOutputChannelsFunction · 0.80
testUnrolledStaticLoopFunction · 0.80

Calls 4

guessFunctionOutputTypeFunction · 0.85
add1ShardTo1StepFunction · 0.85
_buildMapperFunctionFunction · 0.85
InputChanMethod · 0.80

Tested by 4

TestMapSingleParameterFunction · 0.64
TestGroupByKeyMapFunction · 0.64
TestCoGroupMapFunction · 0.64