paths

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2016 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package paths specializes the util/reduce interfaces for Kythe *ipb.Paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromSource

func FromSource(src *ipb.Source) []*ipb.Path

FromSource creates a set of *ipb.Paths for each of its edges as well as a single *ipb.Path with only its pivot set to be the source node.

func KeyValue

func KeyValue(sortKey string, p *ipb.Path) (*ipb.SortedKeyValue, error)

KeyValue returns an equivalent SortedKeyValue of the given Path. Steps will be taken to mimimize the data stored in p. Each key value is meant to be read as a sorted ReducerIO stream.

func OriginalNode

func OriginalNode(n *ipb.Path_Node) (g *srvpb.Node)

OriginalNode returns the given node's original serving node, synthesizing one if necessary.

func RawAnchor

func RawAnchor(n *ipb.Path_Node) *srvpb.RawAnchor

RawAnchor returns and coerces n if it is an anchor node. nil will be returned otherwise.

func ReverseSinglePath

func ReverseSinglePath(p *ipb.Path) *ipb.Path

ReverseSinglePath returns the reverse p, assuming it is a single-edge Path.

func ToString

func ToString(p *ipb.Path) string

ToString returns a human-readable string representation of p.

Types

type Reducer

type Reducer struct {
	Func       func(context.Context, *ipb.Path_Node, ReducerIO) error
	OutputSort func(*ipb.Path) string
}

Reducer implements the reduce.Reduce interface for *ipb.Paths. Func will be called once per Reduce call. If non-nil, OutputSort will be called on each emitted *ipb.Path and used as its sort-key in the constructed *ipb.SortedKeyValue.

The Reducer's underlying input/output values are *ipb.SortedKeyValues with keys matching each Path's pivot ticket and user-defined sort keys. Each Reducer is meant to be used with reduce.Sort.

Paths are not written/read as given. To limit the amount of data written/read, all specializations (and orignal facts) will be removed from each Pivot node. A Reducer can pass-through these fields with a Path only populated with its Pivot node (not edges). These pivot-only paths will be yielded to Func as its second parameter (and not through its ReducerIO). Prefix pivot-only paths will also be used to replace later Path pivots. Duplicate pivot-only paths will be discarded; the most specialized version will be chosen (or if that is ambiguous, the first).

Likewise, each file target in an edge will have its specialization (and original facts) removed and ExpandedAnchor specializations will have their kind filled in based on their encompassing Path Edge kind.

func (*Reducer) End

func (r *Reducer) End(_ context.Context) error

End implements part of the reduce.Reduce interface.

func (*Reducer) Reduce

func (r *Reducer) Reduce(ctx context.Context, rio reduce.IO) error

Reduce implements part of the reduce.Reduce interface.

func (*Reducer) Start

func (r *Reducer) Start(_ context.Context) error

Start implements part of the reduce.Reduce interface.

type ReducerIO

type ReducerIO interface {
	Next() (sortKey string, p *ipb.Path, err error)
	Emit(ctx context.Context, p *ipb.Path) error
}

ReducerIO is a Path-specialized interface mirroring reduce.IO.

Jump to

Keyboard shortcuts

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