transform

package
v1.0.0-beta11 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JoinMethodJoin  = "join"
	JoinMethodError = "error"
)
View Source
const RS = ls.LS + "reshape/"

Variables

View Source
var (
	ErrInvalidSource      = errors.New("Invalid source")
	ErrInvalidSourceValue = errors.New("Invalid source value")
	ErrSourceMustBeString = errors.New("source term value must be a string")
	ErrMultipleValues     = errors.New("Multiple values/result columns found")
)
View Source
var ErrInvalidConditional = errors.New("Invalid conditional")
View Source
var ErrInvalidVariables = errors.New("Invalid vars section")
View Source
var ErrJoinFailure = errors.New("Join failure")
View Source
var ReshapeTerms = struct {
	// If given, the If term specifies a predicate that should be true to reshape the node
	If string
	// Export defines a list of symbols that will be exported from the
	// opencypher expressions run in this node
	Export string
	// Expressions specify one or more expression to evaluate
	Expressions string
	// ValueExpr specifies the query to be used to generate the target value
	ValueExpr string
	// IfEmpty determines whether to reshape the node even if it has no value
	IfEmpty string
	// JoinMethod determines how to join multiple values to generate a single value
	JoinMethod string
	// JoinDelimiter specifies the join delimiter if there are multiple values to be combined
	JoinDelimiter string
}{
	If: ls.NewTerm(RS, "if", false, false, ls.OverrideComposition, struct {
		ifSemantics
	}{}),
	Export: ls.NewTerm(RS, "export", false, true, ls.OverrideComposition, struct {
		exportSemantics
	}{}),
	Expressions: ls.NewTerm(RS, "expr", false, true, ls.OverrideComposition, struct {
		exprSemantics
	}{}),
	ValueExpr: ls.NewTerm(RS, "valueExpr", false, false, ls.OverrideComposition, struct {
		valueExprSemantics
	}{}),
	IfEmpty:       ls.NewTerm(RS, "ifEmpty", false, false, ls.OverrideComposition, nil),
	JoinMethod:    ls.NewTerm(RS, "joinMethod", false, false, ls.OverrideComposition, nil),
	JoinDelimiter: ls.NewTerm(RS, "joinDelimiter", false, false, ls.OverrideComposition, nil),
}

ReshapeTerms defines the terms used to specify reshaping layers

Functions

func JoinValues

func JoinValues(values []interface{}, method, delimiter string) (string, error)

Types

type ErrInvalidSchemaNodeType

type ErrInvalidSchemaNodeType []string

ErrInvalidSchemaNodeType is returned if the schema node type cannot be projected (such as a reference, which cannot happen after compilation)

func (ErrInvalidSchemaNodeType) Error

func (e ErrInvalidSchemaNodeType) Error() string

type Mapper

type Mapper struct {
	ls.Ingester

	// PropertyName specifies the property to lookup in the source
	// graph. The property values give the target schema attribute IDs
	PropertyName string
}

Mapper reads nodes from a source graph and creates a target graph based on a schema. This is used for mapping data across terminologies.

The nodes are selected based on a given node term. The node term in the source graph gives the target schema attributes IDs. For example, if the source graph nodes has properties

term: id

then, the mapper reads the node with `term`, finds the target schema attribute using `id`, and copies the value.

func (*Mapper) Map

func (mapper *Mapper) Map(lsContext *ls.Context, sourceGraph graph.Graph) error

Map builds a new graph conforming to the target schema. The values for the target schema nodes are taken from the source graph nodes that match the mapper.PropertyName

type ReshapeContext

type ReshapeContext struct {
	*ls.Context
	// contains filtered or unexported fields
}

func (*ReshapeContext) SetSymbolValue

func (p *ReshapeContext) SetSymbolValue(name string, value opencypher.Value)

type Reshaper

type Reshaper struct {
	ls.Ingester
}

func (*Reshaper) Reshape

func (reshaper *Reshaper) Reshape(lsContext *ls.Context, sourceGraph graph.Graph) error

Reshape builds a new graph in a shape that conforms to a target schema using the source graph

Jump to

Keyboard shortcuts

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