Version: v0.0.0-...-c884529 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2020 License: MIT Imports: 1 Imported by: 0




This section is empty.


This section is empty.


func FilterOutDuplicates

func FilterOutDuplicates(out chan<- Value, in <-chan KeyValue)

FilterOutDuplicates is a standard reducer that drops values with duplicate keys sending out only unique matches.

func FilterOutUniques

func FilterOutUniques(out chan<- Value, in <-chan KeyValue)

FilterOutUniques is a standard reducer that drops values with unique keys sending out the rest of the values.

func Map

func Map(in <-chan Value, mapFn MapFn) <-chan KeyValue

Map run provided Key/Value generator in a separate go-routine. It returns channel of KeyValue values.

func Pipeline

func Pipeline(pairs ...MapReducePair) <-chan Value

Pipeline builds a pipeline by chaining together provided Map/Reducer pairs. It returns a <-chan of Value.

func Reduce

func Reduce(in <-chan KeyValue, reduceFn ReduceFn) <-chan Value

Reduce takes input KeyValue channel and reduce function. It returns Value channel used by reducer for output.


type KVType

type KVType struct {
	// contains filtered or unexported fields

func NewKVType

func NewKVType(k Key, v Value) *KVType

func (KVType) Key

func (kvt KVType) Key() KeyType

func (KVType) Value

func (kvt KVType) Value() interface{}

type Key

type Key interface {
	Key() KeyType

Key interface is there to make sure that the value can be used in go built-in map as a key.

type KeyType

type KeyType string

func KeyTypeFromInt

func KeyTypeFromInt(i int) KeyType

func KeyTypeFromInt64

func KeyTypeFromInt64(i int64) KeyType

func KeyTypeFromString

func KeyTypeFromString(s string) KeyType

func (KeyType) Key

func (kt KeyType) Key() KeyType

func (KeyType) String

func (kt KeyType) String() string

type KeyValue

type KeyValue interface {

KeyValue interface describes objects produced by Map and used by Reduce as its input stream

type MapFn

type MapFn func(out chan<- KeyValue, in <-chan Value)

MapFn provided by the client code. It is responsible to perform actual work and send it to the out channel as KeyValue tuple.

type MapReducePair

type MapReducePair struct {
	Map    MapFn
	Reduce ReduceFn

MapReducePair is a necessary type for pipeline builder

type ReduceFn

type ReduceFn func(out chan<- Value, in <-chan KeyValue)

ReduceFn a function provided by the client code. It expects to aggregate over the values provided by the in channel of KeyValue objects and send its result to out Value channel.

type Value

type Value interface {
	Value() interface{}

Value interface for objects that Map expects it its input stream

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL