nodes

package
v0.0.66 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: Apache-2.0, NCSA Imports: 12 Imported by: 1

Documentation

Overview

Package nodes provides Beam transformations over *scpb.Nodes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromEntries

func FromEntries(s beam.Scope, entries beam.PCollection) beam.PCollection

FromEntries transforms a PCollection of *ppb.Entry protos into *scpb.Nodes.

Types

type Filter added in v0.0.28

type Filter struct {
	// FilterByKind, if non-nil, configures the filter to only pass through nodes
	// that match one of the given kinds.
	FilterByKind []string
	// FilterBySubkind, if non-nil, configures the filter to only pass through
	// nodes that match one of the given subkinds.
	FilterBySubkind []string

	// IncludeFacts, if non-nil, configures the filter to remove all facts not
	// explicitly contained with the slice.
	IncludeFacts []string
	// IncludeEdges, if non-nil, configures the filter to remove all edges with a
	// kind not explicitly contained with the slice.
	IncludeEdges []string
}

Filter is a beam DoFn that emits *scpb.Nodes matching a set of kinds/subkinds. Optionally, each processed node's facts/edges will also be filtered to the desired set.

The semantics of the Filter are such that a "zero"-value Filter will pass all Nodes through unaltered. Each part of the filter only applies if set to a non-nil value and all parts are applied independently.

Examples:

Emit only "record" nodes with the "class" subkind with all their facts/edges:
  &Filter {
    FilterByKind:    []string{"record"},
    FilterBySubkind: []string{"class"},
  }

Emit only "anchor" nodes (any subkind) with all their facts/edges:
  &Filter {FilterByKind: []string{"anchor"}}

Emit only "anchor" nodes with only the loc/{start,end} facts and no edges:
  &Filter {
    FilterByKind: []string{"anchor"},
    IncludeFacts: []string{"/kythe/loc/start", "/kythe/loc/end"},
    IncludeEdges: []string{},
  }

Emit only "anchor" nodes with their "childof" edges (but all their facts):
  &Filter {
    FilterByKind: []string{"anchor"},
    IncludeEdges: []string{"/kythe/edge/childof"},
  }

Emit all nodes without any of their edges (but all their facts):
  &Filter {IncludeEdges: []string{}}

func (*Filter) ProcessElement added in v0.0.28

func (f *Filter) ProcessElement(n *scpb.Node, emit func(*scpb.Node)) error

ProcessElement emits the given Node if it matches the given Filter.

Jump to

Keyboard shortcuts

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