xrefs

package
v0.0.67 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0, NCSA Imports: 40 Imported by: 6

Documentation

Overview

Package xrefs provides a high-performance table-based implementation of the xrefs.Service.

Table format:

decor:<ticket>         -> srvpb.FileDecorations
docs:<ticket>          -> srvpb.Document
xrefs:<ticket>         -> srvpb.PagedCrossReferences
xrefPages:<page_key>   -> srvpb.PagedCrossReferences_Page

Index

Constants

View Source
const ColumnarTableKeyMarker = "kythe:columnar"

ColumnarTableKeyMarker is stored within a Kythe columnar table to differentiate it from the legacy combined table format.

Variables

This section is empty.

Functions

func CrossReferencesKey added in v0.0.17

func CrossReferencesKey(ticket string) []byte

CrossReferencesKey returns the cross-references CombinedTable key for the given node ticket.

func CrossReferencesPageKey added in v0.0.17

func CrossReferencesPageKey(key string) []byte

CrossReferencesPageKey returns the cross-references page CombinedTable key for the given key.

func DecorationsKey

func DecorationsKey(ticket string) []byte

DecorationsKey returns the decorations CombinedTable key for the given source location ticket.

func DefaultResolvePath added in v0.0.60

func DefaultResolvePath(cp *cpb.CorpusPath) string

DefaultResolvePath returns the default resolved path for the CorpusPath by joining its corpus, root, and path into a single filepath.

func DocumentationKey added in v0.0.27

func DocumentationKey(ticket string) []byte

DocumentationKey returns the documentation CombinedTable key for the given ticket.

func NewService added in v0.0.29

func NewService(ctx context.Context, t keyvalue.DB) xrefs.Service

NewService returns an xrefs.Service backed by the given table. The format of the table with be automatically detected.

Types

type ColumnarTable added in v0.0.29

type ColumnarTable struct {
	keyvalue.DB

	*Table // fallback non-columnar documentation
}

ColumnarTable implements an xrefs.Service backed by a columnar serving table.

func NewColumnarTable added in v0.0.29

func NewColumnarTable(t keyvalue.DB) *ColumnarTable

NewColumnarTable returns a table for the given columnar xrefs lookup table.

func (*ColumnarTable) CrossReferences added in v0.0.29

CrossReferences implements part of the xrefs.Service interface.

func (*ColumnarTable) Decorations added in v0.0.29

Decorations implements part of the xrefs.Service interface.

type MultiFilePatcher added in v0.0.59

type MultiFilePatcher interface {
	// AddFile adds a file to current set of files to patch against.
	AddFile(context.Context, *srvpb.FileInfo) error

	// PatchAnchors updates the set of anchors given to match their referenced
	// files' state as known by the MultiLinePatcher, usually based on a
	// Workspace.  If an anchor no longer exists, it will be ellided from the
	// returned set.  Otherwise, the ordering of the anchors will be retained.
	PatchAnchors(context.Context, []*xpb.Anchor) ([]*xpb.Anchor, error)

	// PatchRelatedAnchors updates the set of related anchors given to match their
	// referenced files' state as known by the MultiLinePatcher, usually based on
	// a Workspace.  If an anchor no longer exists, it will be ellided from the
	// returned set.  Otherwise, the ordering of the anchors will be retained.
	PatchRelatedAnchors(context.Context, []*xpb.CrossReferencesReply_RelatedAnchor) ([]*xpb.CrossReferencesReply_RelatedAnchor, error)

	// Close releases any resources used the patcher.  Further calls to the
	// patcher will become invalid.
	Close() error
}

A MultiFilePatcher provides an interface to patch sets of xref anchors to an underlying baseline, usually a Workspace.

After creation, the client is required to call AddFile for each possible file referenced by any anchors that will be patched. After the files are added, a set of anchors may be passed to PatchAnchors.

type PathResolver added in v0.0.60

type PathResolver func(*cpb.CorpusPath) string

A PathResolver resolves a CorpusPath into a single filepath.

type SplitTable added in v0.0.9

type SplitTable struct {
	// Decorations is a table of srvpb.FileDecorations keyed by their source
	// location tickets.
	Decorations table.Proto

	// CrossReferences is a table of srvpb.PagedCrossReferences keyed by their
	// source node tickets.
	CrossReferences table.Proto

	// CrossReferencePages is a table of srvpb.PagedCrossReferences_Pages keyed by
	// their page keys.
	CrossReferencePages table.Proto

	// Documentation is a table of srvpb.Documents keyed by their node ticket.
	Documentation table.Proto

	// RewriteEdgeLabel is an optional callback to rewrite edge labels.
	// It will be called once per request; the function it returns will then be
	// called once per edge.
	RewriteEdgeLabel func(context.Context) func(string) string
}

SplitTable implements the xrefs Service interface using separate static lookup tables for each API component.

func (*SplitTable) Close added in v0.0.66

func (s *SplitTable) Close(ctx context.Context) (err error)

Close closes each underlying table.Proto.

type Table

type Table struct {

	// MakePatcher returns a patching client that targets a Workspace.
	MakePatcher func(context.Context, *xpb.Workspace) (MultiFilePatcher, error)

	// ResolvePath is used to resolve CorpusPaths for filtering.  If unset,
	// DefaultResolvePath will be used.
	ResolvePath PathResolver
	// contains filtered or unexported fields
}

Table implements the xrefs Service interface using static lookup tables.

func NewCombinedTable added in v0.0.9

func NewCombinedTable(t table.Proto) *Table

NewCombinedTable returns a table for the given combined xrefs lookup table. The table's keys are expected to be constructed using only the *Key functions.

func NewSplitTable added in v0.0.9

func NewSplitTable(c *SplitTable) *Table

NewSplitTable returns a table based on the given serving tables for each API component.

func (*Table) CrossReferences added in v0.0.25

func (t *Table) CrossReferences(ctx context.Context, req *xpb.CrossReferencesRequest) (*xpb.CrossReferencesReply, error)

CrossReferences implements part of the xrefs.Service interface.

func (*Table) Decorations

func (t *Table) Decorations(ctx context.Context, req *xpb.DecorationsRequest) (*xpb.DecorationsReply, error)

Decorations implements part of the xrefs Service interface.

func (*Table) Documentation added in v0.0.25

func (t *Table) Documentation(ctx context.Context, req *xpb.DocumentationRequest) (*xpb.DocumentationReply, error)

Documentation implements part of the xrefs Service interface.

Directories

Path Synopsis
Package assemble provides functions to build the various components (nodes, edges, and decorations) of an xrefs serving table.
Package assemble provides functions to build the various components (nodes, edges, and decorations) of an xrefs serving table.
Package columnar implements the columnar table format for a Kythe xrefs service.
Package columnar implements the columnar table format for a Kythe xrefs service.

Jump to

Keyboard shortcuts

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