Documentation ¶
Overview ¶
Package reduce provides a simple interface for transforming a stream of inputs. Currently, other than utility functions/interfaces, the only transformation available is Sort.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KeyValueSorter ¶
KeyValueSorter returns a disksort for arbitrary *ipb.SortedKeyValues.
Types ¶
type ChannelInput ¶
type ChannelInput <-chan ChannelInputValue
ChannelInput implements the Input interface, yielding each channel value when Next is called.
func (ChannelInput) Next ¶
func (c ChannelInput) Next() (interface{}, error)
Next implements the Input interface.
type ChannelInputValue ¶
type ChannelInputValue struct { Value interface{} Err error }
ChannelInputValue represents the return value of Input#Next.
type ChannelSplitInput ¶
type ChannelSplitInput <-chan ChannelSplitInputValue
ChannelSplitInput implements the SplitInput interface over a channel of ReduceInputs to return on each call to NextSplit.
func (ChannelSplitInput) NextSplit ¶
func (c ChannelSplitInput) NextSplit() (Input, error)
NextSplit implements the SplitInput interface.
type ChannelSplitInputValue ¶
ChannelSplitInputValue represents the return values of SplitInput#NextSplit.
type CombinedReducers ¶
type CombinedReducers struct {
Reducers []Reducer
}
CombinedReducers allows multiple Reducers to consume the same ReducerInput and output to the same ReducerOutput.
func (*CombinedReducers) End ¶
func (c *CombinedReducers) End(ctx context.Context) error
End implements part of the Reducer interface.
type Func ¶
A Func implements the Reducer interface with no-op Start/End methods.
type Input ¶
type Input interface {
Next() (interface{}, error)
}
A Input yields input to a Reducer.
type Reducer ¶
type Reducer interface { Start(context.Context) error Reduce(context.Context, IO) error End(context.Context) error }
A Reducer transforms one stream of values into another stream of values. Reduce may be called multiple times (once per input shard). Start and End will be called once before any call to Reduce and once after every call to Reduce, respectively.
type SplitInput ¶
SplitInput represents an input that is sharded.
func Sort ¶
func Sort(ctx context.Context, splits SplitInput, r Reducer) (SplitInput, error)
Sort applies r to each separate input in splits. r should be a Reducer that accepts the same input type that splits contains and MUST output *ipb.SortedKeyValues. The resulting SplitInput will be the set of outputs from r, split on groups sharing the same SortedKeyValue.Key and sorted within a group by SortedKeyValue.SortKey (see SplitSortedKeyValues). The Reducer's Start method will be called once before any call to Reduce and the Reducer's End method will be called once after the final Reduce call is completed.
Sort will return on the first error it encounters. This may cause some of the input to not be read and Start/Reduce/End may not be called depending on when the error occurs.
func SplitSortedKeyValues ¶
func SplitSortedKeyValues(sorter disksort.Interface) (SplitInput, error)
SplitSortedKeyValues constructs a SplitInput that returns a Input for each set of *ipb.SortedKeyValues with the same key.