mapreduce

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 3 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotSupported   = errors.New("not supported")
	ErrInvalidChanDir = errors.New("not readable channel")
)
View Source
var (
	ErrNilMapper     = errors.New("mapper function cannot be nil")
	ErrMapperNotFunc = errors.New("mapper must be a function")
	ErrInvalidMapper = errors.New("invalid Mapper signature, must be \"mapper(TypeA) TypeB\" or \"mapper(TypeA, int) TypeB\"")
)

Map Error Collection

View Source
var (
	ErrNilReducer          = errors.New("reducer cannot be nil")
	ErrReducerNotFunc      = errors.New("reducer must be a function")
	ErrMissingInitialValue = errors.New("missing initial value")
	ErrInvalidReducer      = errors.New("invalid reducer signature, must be \"reducer(TypeA, TypeB, int) TypeA\" or \"reducer(TypeA, TypeB) TypeA\"")
)

Reducer Error Collection

Functions

func Map

func Map(mapper interface{}, source interface{}) (interface{}, error)

Map maps iteratible objects into another slice. The mapper can be mapper(TypeA, int) TypeB or mapper(TypeA) TypeB The source accept array, slice, channel or Iterator.

func ParallelMap

func ParallelMap(mapper interface{}, source interface{}) (interface{}, error)

ParallelMap maps iteratible objects in parallel.

func Reduce

func Reduce(reducer, source interface{}, initials ...interface{}) (interface{}, error)

Reduce reduces iteratible objects into a scalar value. The reducer can be reducer(TypeA, TypeB, int) TypeA or reducer(TypeA, TypeB) TypeA The source accept array, slice, channel or Iterator.

Types

type ArrayEnumerator added in v1.2.2

type ArrayEnumerator struct {
	// contains filtered or unexported fields
}

func (*ArrayEnumerator) Cap added in v1.2.2

func (enum *ArrayEnumerator) Cap() int

func (*ArrayEnumerator) Container added in v1.2.2

func (enum *ArrayEnumerator) Container() interface{}

func (*ArrayEnumerator) Item added in v1.2.2

func (enum *ArrayEnumerator) Item(i int) interface{}

func (*ArrayEnumerator) Len added in v1.2.2

func (enum *ArrayEnumerator) Len() int

type ArrayIterator

type ArrayIterator struct {
	ContainerIterator
}

func (*ArrayIterator) Next

func (iter *ArrayIterator) Next() bool

func (*ArrayIterator) Value

func (iter *ArrayIterator) Value() (int, interface{})

type Capacitor

type Capacitor interface {
	Length
	Cap() int
}

type ChanIterator

type ChanIterator struct {
	ContainerIterator
	// contains filtered or unexported fields
}

func (*ChanIterator) Next

func (iter *ChanIterator) Next() (ok bool)

func (*ChanIterator) Value

func (iter *ChanIterator) Value() (int, interface{})

type Container added in v1.2.2

type Container interface {
	Container() interface{}
}

type ContainerIterator

type ContainerIterator struct {
	// contains filtered or unexported fields
}

func (*ContainerIterator) Cap

func (iter *ContainerIterator) Cap() int

func (*ContainerIterator) Container added in v1.2.2

func (iter *ContainerIterator) Container() interface{}

func (*ContainerIterator) Len

func (iter *ContainerIterator) Len() int

type Enumerator added in v1.2.2

type Enumerator interface {
	Len() int
	Item(int) interface{}
}

func NewEnumerator added in v1.2.2

func NewEnumerator(slice interface{}) (Enumerator, error)

type EnumeratorIterator added in v1.2.2

type EnumeratorIterator struct {
	Enumerator
	// contains filtered or unexported fields
}

func (*EnumeratorIterator) Next added in v1.2.2

func (enum *EnumeratorIterator) Next() bool

func (*EnumeratorIterator) Value added in v1.2.2

func (enum *EnumeratorIterator) Value() (int, interface{})

type Iterator

type Iterator interface {
	Next() bool
	Value() (int, interface{})
}

func NewIterator

func NewIterator(sliceOrChan interface{}) (Iterator, error)

type Length

type Length interface {
	Len() int
}

Jump to

Keyboard shortcuts

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