assemble

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2015 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Overview

Package assemble provides functions to build the various components (nodes, edges, and decorations) of an xrefs serving table.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecorationFragments

func DecorationFragments(src *Source) []*srvpb.FileDecorations

DecorationFragments returns 0 or more FileDecorations fragments from the given Source, depending on its node kind. If given an anchor, decoration fragments will be returned for each of the anchor's parents (assumed to be files). If given a file, 1 decoration fragment will be returned with the file's source text and encoding populated. All other nodes return 0 decoration fragments.

func NodeFact

func NodeFact(e *spb.Entry) *srvpb.Node_Fact

NodeFact returns a Node_Fact from the given Entry. If e == nil or e is not a node fact, nil is returned.

func Sources

func Sources(entries <-chan *spb.Entry) <-chan *Source

Sources returns a channel of Sources derived from a channel of entries in GraphStore order.

Types

type ByOffset

ByOffset sorts file decorations by their byte offsets.

func (ByOffset) Len

func (s ByOffset) Len() int

func (ByOffset) Less

func (s ByOffset) Less(i, j int) bool

func (ByOffset) Swap

func (s ByOffset) Swap(i, j int)

type EdgeSetBuilder

type EdgeSetBuilder struct {
	// MaxEdgePageSize is maximum number of edges that are allowed in the
	// PagedEdgeSet and any EdgePage.  If MaxEdgePageSize <= 0, no paging is
	// attempted.
	MaxEdgePageSize int

	// Output is used to emit each PagedEdgeSet constructed.
	Output func(context.Context, *srvpb.PagedEdgeSet) error
	// OutputPage is used to emit each EdgePage constructed.
	OutputPage func(context.Context, *srvpb.EdgePage) error
	// contains filtered or unexported fields
}

EdgeSetBuilder constructs a set of PagedEdgeSets and EdgePages from a sequence of EdgeSet_Groups. All EdgeSet_Groups for the same source are assumed to be given sequentially to AddGroup, secondarily ordered by the group's edge kind. If given in this order, Output will be given exactly 1 PagedEdgeSet per source with as few EdgeSet_Group per edge kind as to satisfy MaxEdgePageSize (MaxEdgePageSize == 0 indicates that there will be exactly 1 edge group per edge kind). If not given in this order, no guarantees can be made. Flush must be called after the final call to AddGroup.

func (*EdgeSetBuilder) AddGroup

func (b *EdgeSetBuilder) AddGroup(ctx context.Context, src string, eg *srvpb.EdgeSet_Group) error

AddGroup adds the given EdgeSet_Group to the builder, possibly emitting a new PagedEdgeSet and/or EdgePage. See EdgeSetBuilder's documentation for the assumed order of the groups.

func (*EdgeSetBuilder) Flush

func (b *EdgeSetBuilder) Flush(ctx context.Context) error

Flush signals the end of the current PagedEdgeSet being built, flushing it, and its EdgeSet_Groups to the output function. This should be called after the final call to AddGroup. Manually calling Flush at any other time is unnecessary.

type Source

type Source struct {
	Ticket string

	Facts map[string][]byte
	Edges map[string][]string
}

Source is a collection of facts and edges with a common source.

func SourceFromEntries

func SourceFromEntries(entries []*spb.Entry) *Source

SourceFromEntries returns a new Source from the given a set of entries with the same source VName.

Jump to

Keyboard shortcuts

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