mapreduce

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

func (*ArrayEnumerator) Cap

func (enum *ArrayEnumerator) Cap() int

func (*ArrayEnumerator) Container

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

func (*ArrayEnumerator) Item

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

func (*ArrayEnumerator) Len

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

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

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

func (*ContainerIterator) Len

func (iter *ContainerIterator) Len() int

type Enumerator

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

func NewEnumerator

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

type EnumeratorIterator

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

func (*EnumeratorIterator) Next

func (enum *EnumeratorIterator) Next() bool

func (*EnumeratorIterator) Value

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