graph

package
v0.0.0-...-ca9423e Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package graph defines a storage format for a simple package dependency graph. Nodes in the graph are named packages, and edges record direct forward dependencies between nodes.

Index

Constants

This section is empty.

Variables

View Source
var (
	Row_Type_name = map[int32]string{
		0: "UNKNOWN",
		1: "STDLIB",
		2: "LIBRARY",
		3: "PROGRAM",
	}
	Row_Type_value = map[string]int32{
		"UNKNOWN": 0,
		"STDLIB":  1,
		"LIBRARY": 2,
		"PROGRAM": 3,
	}
)

Enum value maps for Row_Type.

View Source
var File_graph_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Graph

type Graph struct {
	// contains filtered or unexported fields
}

A Graph is an interface to a package dependency graph.

func New

func New(st storage.Interface) *Graph

New constructs a graph handle for the given storage.

func (*Graph) Add

func (g *Graph) Add(ctx context.Context, repo *deps.Repo, pkg *deps.Package) error

Add adds the specified package to the graph. If an entry already exists for the specified package, it is replaced.

func (*Graph) AddAll

func (g *Graph) AddAll(ctx context.Context, repo *deps.Repo) error

AddAll calls Add for each package defined in the specified repo.

func (*Graph) EncodeToQuads

func (g *Graph) EncodeToQuads(ctx context.Context, f func(quad.Quad) error) (err error)

EncodeToQuads converts g to RDF 1.1 N-quads and calls f for each. If f reports an error the conversion is terminated and the error is returned to the caller of EncodeToQuads.

func (*Graph) List

func (g *Graph) List(ctx context.Context, start string, f func(string) error) error

List calls f with each key in the graph lexicographically greater than or equal to start. If f reports an error, scanning terminates. If the error is storage.ErrStopScan, List returns nil. Otherwise, List returns the error from f.

func (*Graph) MatchImporters

func (g *Graph) MatchImporters(ctx context.Context, match func(string) bool, f func(tpkg, ipkg string)) error

MatchImporters calls f(q, p) for each package p that directly depends on any package q for which match(q) is true. The order of results is unspecified.

func (*Graph) Remove

func (g *Graph) Remove(ctx context.Context, pkg string) error

Remove removes the row for pkg from g.

func (*Graph) Row

func (g *Graph) Row(ctx context.Context, pkg string) (*Row, error)

Row loads the complete row for the specified import path.

func (*Graph) Scan

func (g *Graph) Scan(ctx context.Context, start string, f func(*Row) error) error

Scan calls f with each row in the graph whose key is lexicographically greater than or equal to start If f reports an error, scanning terminates. If the error is storage.ErrStopScan, Scan returns nil. Otherwise Scan returns the error from f.

func (*Graph) ScanUpdate

func (g *Graph) ScanUpdate(ctx context.Context, prefix string, f func(*Row) bool) error

ScanUpdate calls f with each row in the graph having the specified prefix. If f reports true, the modified value of the row is updated; otherwise no action is taken for the row.

func (*Graph) WriteQuads

func (g *Graph) WriteQuads(ctx context.Context, w io.Writer) error

WriteQuads converts g to RDF 1.1 N-quads and writes them to w.

type Row

type Row struct {

	// The simple name and import path of the package whose row this is.
	Name       string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	ImportPath string `protobuf:"bytes,2,opt,name=import_path,json=importPath,proto3" json:"import_path,omitempty"`
	// The repository where the package was defined.
	Repository string `protobuf:"bytes,3,opt,name=repository,proto3" json:"repository,omitempty"`
	// The import paths of the direct dependencies of source.
	Directs []string `protobuf:"bytes,4,rep,name=directs,proto3" json:"directs,omitempty"`
	// The names and content digests of source files in this package.
	SourceFiles []*Row_File `protobuf:"bytes,5,rep,name=source_files,json=sourceFiles,proto3" json:"source_files,omitempty"`
	// Classify the package type according to its role, if known.
	Type Row_Type `protobuf:"varint,6,opt,name=type,proto3,enum=graph.Row_Type" json:"type,omitempty"`
	// Ranking weight; 0 represents an unranked value.
	Ranking float64 `protobuf:"fixed64,7,opt,name=ranking,proto3" json:"ranking,omitempty"`
	// contains filtered or unexported fields
}

A Row is a single row of the dependency graph adjacency list.

func (*Row) Descriptor deprecated

func (*Row) Descriptor() ([]byte, []int)

Deprecated: Use Row.ProtoReflect.Descriptor instead.

func (*Row) GetDirects

func (x *Row) GetDirects() []string

func (*Row) GetImportPath

func (x *Row) GetImportPath() string

func (*Row) GetName

func (x *Row) GetName() string

func (*Row) GetRanking

func (x *Row) GetRanking() float64

func (*Row) GetRepository

func (x *Row) GetRepository() string

func (*Row) GetSourceFiles

func (x *Row) GetSourceFiles() []*Row_File

func (*Row) GetType

func (x *Row) GetType() Row_Type

func (*Row) MarshalJSON

func (r *Row) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for a Row by delegating to protojson.

func (*Row) ProtoMessage

func (*Row) ProtoMessage()

func (*Row) ProtoReflect

func (x *Row) ProtoReflect() protoreflect.Message

func (*Row) Reset

func (x *Row) Reset()

func (*Row) String

func (x *Row) String() string

func (*Row) UnmarshalJSON

func (r *Row) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler for a Row by delegating to jsonpb.

type Row_File

type Row_File struct {
	RepoPath string `protobuf:"bytes,1,opt,name=repo_path,json=repoPath,proto3" json:"repo_path,omitempty"` // file path relative to the repository root
	Digest   []byte `protobuf:"bytes,2,opt,name=digest,proto3" json:"digest,omitempty"`                     // content digest (sha256)
	// contains filtered or unexported fields
}

func (*Row_File) Descriptor deprecated

func (*Row_File) Descriptor() ([]byte, []int)

Deprecated: Use Row_File.ProtoReflect.Descriptor instead.

func (*Row_File) GetDigest

func (x *Row_File) GetDigest() []byte

func (*Row_File) GetRepoPath

func (x *Row_File) GetRepoPath() string

func (*Row_File) ProtoMessage

func (*Row_File) ProtoMessage()

func (*Row_File) ProtoReflect

func (x *Row_File) ProtoReflect() protoreflect.Message

func (*Row_File) Reset

func (x *Row_File) Reset()

func (*Row_File) String

func (x *Row_File) String() string

type Row_Type

type Row_Type int32
const (
	Row_UNKNOWN Row_Type = 0 // the package type is not known
	Row_STDLIB  Row_Type = 1 // this is a standard library package
	Row_LIBRARY Row_Type = 2 // this is a library package
	Row_PROGRAM Row_Type = 3 // this is an executable
)

func (Row_Type) Descriptor

func (Row_Type) Descriptor() protoreflect.EnumDescriptor

func (Row_Type) Enum

func (x Row_Type) Enum() *Row_Type

func (Row_Type) EnumDescriptor deprecated

func (Row_Type) EnumDescriptor() ([]byte, []int)

Deprecated: Use Row_Type.Descriptor instead.

func (Row_Type) Number

func (x Row_Type) Number() protoreflect.EnumNumber

func (Row_Type) String

func (x Row_Type) String() string

func (Row_Type) Type

Jump to

Keyboard shortcuts

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