Documentation ¶
Overview ¶
Package assemble provides functions to build the various components (nodes, edges, and decorations) of an xrefs serving table.
Index ¶
- func AppendEntry(src *ipb.Source, e *spb.Entry)
- func CrossReference(file *srvpb.File, norm *span.Normalizer, d *srvpb.FileDecorations_Decoration, ...) (*ipb.CrossReference, error)
- func ExpandAnchor(anchor *srvpb.RawAnchor, file *srvpb.File, norm *span.Normalizer, kind string) (*srvpb.ExpandedAnchor, error)
- func FactsToMap(facts []*cpb.Fact) map[string][]byte
- func FilterTextFacts(n *srvpb.Node) *srvpb.Node
- func GetFact(facts []*cpb.Fact, name string) []byte
- func Node(s *ipb.Source) *srvpb.Node
- func PartialReverseEdges(src *ipb.Source) []*srvpb.Edge
- func SourceFromEntries(entries []*spb.Entry) *ipb.Source
- func Sources(rd stream.EntryReader, f func(*ipb.Source) error) error
- type ByAnchorTicket
- type ByOffset
- type ByTicket
- type CrossReferencesBuilder
- type DecorationFragmentBuilder
- type EdgeSetBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendEntry ¶ added in v0.0.21
AppendEntry adds the given Entry to the Source's facts or edges. It is assumed that src.Ticket == kytheuri.ToString(e.Source).
func CrossReference ¶ added in v0.0.17
func CrossReference(file *srvpb.File, norm *span.Normalizer, d *srvpb.FileDecorations_Decoration, tgt *srvpb.Node) (*ipb.CrossReference, error)
CrossReference returns a (Referent, TargetAnchor) *ipb.CrossReference equivalent to the given decoration. The decoration's anchor is expanded given its parent file and associated Normalizer.
func ExpandAnchor ¶ added in v0.0.18
func ExpandAnchor(anchor *srvpb.RawAnchor, file *srvpb.File, norm *span.Normalizer, kind string) (*srvpb.ExpandedAnchor, error)
ExpandAnchor returns the ExpandedAnchor equivalent of the given RawAnchor where file (and its associated Normalizer) must be the anchor's parent file.
func FactsToMap ¶ added in v0.0.16
FactsToMap returns a map from fact name to value.
func FilterTextFacts ¶ added in v0.0.16
FilterTextFacts returns a new Node without any text facts.
func GetFact ¶ added in v0.0.16
GetFact returns the value of the first fact in facts with the given name; otherwise returns nil.
func PartialReverseEdges ¶ added in v0.0.16
PartialReverseEdges returns the set of partial reverse edges from the given source. Each reversed Edge has its Target fully populated and its Source will have no facts. To ensure every node has at least 1 Edge, the first Edge will be a self-edge without a Kind or Target. To reduce the size of edge sets, each Target will have any text facts filtered (see FilterTextFacts).
func SourceFromEntries ¶
SourceFromEntries returns a new Source from the given a set of entries with the same source VName.
Types ¶
type ByAnchorTicket ¶ added in v0.0.22
type ByAnchorTicket []*srvpb.ExpandedAnchor
ByAnchorTicket sorts anchors by their ticket.
func (ByAnchorTicket) Len ¶ added in v0.0.22
func (s ByAnchorTicket) Len() int
func (ByAnchorTicket) Less ¶ added in v0.0.22
func (s ByAnchorTicket) Less(i, j int) bool
func (ByAnchorTicket) Swap ¶ added in v0.0.22
func (s ByAnchorTicket) Swap(i, j int)
type ByOffset ¶
type ByOffset []*srvpb.FileDecorations_Decoration
ByOffset sorts file decorations by their byte offsets.
type CrossReferencesBuilder ¶ added in v0.0.17
type CrossReferencesBuilder struct { MaxPageSize int Output func(context.Context, *srvpb.PagedCrossReferences) error OutputPage func(context.Context, *srvpb.PagedCrossReferences_Page) error // contains filtered or unexported fields }
CrossReferencesBuilder is a type wrapper around a pager.SetPager that emits *srvpb.PagedCrossReferences and *srvpb.PagedCrossReferences_Pages. Each PagedCrossReferences_Group added the builder should be in sorted order so that groups of the same kind are added sequentially. Before each set of like-kinded groups, StartSet should be called with the source ticket of the proceeding groups. See also EdgeSetBuilder.
func (*CrossReferencesBuilder) AddGroup ¶ added in v0.0.17
func (b *CrossReferencesBuilder) AddGroup(ctx context.Context, g *srvpb.PagedCrossReferences_Group) error
AddGroup add the given group of cross-references to the currently being built *srvpb.PagedCrossReferences. The group should share the same source ticket as given to the mostly recent invocation to StartSet.
type DecorationFragmentBuilder ¶ added in v0.0.16
type DecorationFragmentBuilder struct { Output func(ctx context.Context, file string, fragment *srvpb.FileDecorations) error // contains filtered or unexported fields }
DecorationFragmentBuilder builds pieces of FileDecorations given an ordered (see AddEdge) stream of completed Edges. Each fragment constructed (either by AddEdge or Flush) will be emitted using the Output function in the builder. There are two types of fragments: file fragments (which have their SourceText, FileTicket, and Encoding set) and decoration fragments (which have only Decoration set).
func (*DecorationFragmentBuilder) AddEdge ¶ added in v0.0.16
AddEdge adds the given edge to the current fragment (or emits some fragments and starts a new fragment with e). AddEdge must be called in GraphStore sorted order of the Edges with the beginning to every set of edges with the same Source having a signaling Edge with only its Source set (no Kind or Target). Otherwise, every Edge must have a completed Source, Kind, and Target. Flush must be called after every call to AddEdge in order to output any remaining fragments.
func (*DecorationFragmentBuilder) Flush ¶ added in v0.0.16
func (b *DecorationFragmentBuilder) Flush(ctx context.Context) error
Flush outputs any remaining fragments that are being built. It is safe, but usually unnecessary, to call Flush in between sets of Edges with the same Source. This also means that DecorationFragmentBuilder can be used to construct decoration fragments in parallel by partitioning edges along the same boundaries.
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 Nodes and EdgeSet_Groups. For each set of groups with the same source, a call to StartEdgeSet must precede. All EdgeSet_Groups for the same source are then 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 ¶
AddGroup adds a EdgeSet_Group to current EdgeSet being built, possibly emitting a new PagedEdgeSet and/or EdgePage. StartEdgeSet must be called before any calls to this method. See EdgeSetBuilder's documentation for the assumed order of the groups and this method's relation to StartEdgeSet.
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.
func (*EdgeSetBuilder) StartEdgeSet ¶ added in v0.0.16
StartEdgeSet begins a new EdgeSet for the given source node, possibly emitting a PagedEdgeSet for the previous EdgeSet. Each following call to AddGroup adds the group to this new EdgeSet until another call to StartEdgeSet is made.