Documentation ¶
Index ¶
- Constants
- Variables
- func CloneEdge(fromInTarget, toInTarget *lpg.Node, sourceEdge *lpg.Edge, ...) *lpg.Edge
- func CloneNode(sourceNode *lpg.Node, targetGraph *lpg.Graph) *lpg.Node
- func CloneProperties(iterator interface{ ... }) map[string]interface{}
- func ClonePropertyValueFunc(key string, value interface{}) interface{}
- func CombineNodeTypes(nodes []*lpg.Node) lpg.StringSet
- func CompileTerms(layer *Layer) error
- func ComposeProperties(context *Context, target, source *lpg.Node) error
- func CopyGraph(target, source *lpg.Graph, nodeSelector func(*lpg.Node) bool, ...) map[*lpg.Node]*lpg.Node
- func CopyPropertyMap(m map[string]*PropertyValue) map[string]*PropertyValue
- func CopySchemaNodeIntoGraph(target *lpg.Graph, schemaNode *lpg.Node) *lpg.Node
- func DeepEqual(i1, i2 interface{}) error
- func DocumentNodesUnder(node ...*lpg.Node) []*lpg.Node
- func EnsurePath(rootDocNode, ancestorDocNode *lpg.Node, rootSchemaNode, schemaNode *lpg.Node, ...) (*lpg.Node, error)
- func FilterAttributeTypes(types []string) []string
- func FilterNonLayerTypes(types []string) []string
- func FindChildInstanceOf(parent *lpg.Node, childAttrID string) []*lpg.Node
- func FindDuplicatedEntities(ei map[*lpg.Node]EntityInfo) [][]*lpg.Node
- func FindNodeByID(g *lpg.Graph, ID string) []*lpg.Node
- func FollowEdgesToNodeWithType(typ string) func(*lpg.Edge) EdgeFuncResult
- func ForEachAttributeNode(root *lpg.Node, f func(node *lpg.Node, path []*lpg.Node) bool) bool
- func ForEachAttributeNodeOrdered(root *lpg.Node, f func(node *lpg.Node, path []*lpg.Node) bool) bool
- func FormatNodeValue(node *lpg.Node) (string, error)
- func GetArrayElementNode(arraySchemaNode *lpg.Node) *lpg.Node
- func GetAttributeID(node *lpg.Node) string
- func GetAttributePath(root, node *lpg.Node) []*lpg.Node
- func GetAttributeValidator(term string) (NodeValidator, ValueValidator)
- func GetEntityInfo(g *lpg.Graph) map[*lpg.Node]EntityInfo
- func GetEntityRoot(node *lpg.Node) *lpg.Node
- func GetEntityRootNode(aNode *lpg.Node) *lpg.Node
- func GetIngestAs(schemaNode *lpg.Node) string
- func GetIngestAsProperty(schemaNode *lpg.Node) (asPropertyOf, propertyName string)
- func GetLayerEntityRoot(node *lpg.Node) *lpg.Node
- func GetNSMap(in []string) ([][]string, error)
- func GetNodeID(node *lpg.Node) string
- func GetNodeIndex(node *lpg.Node) int
- func GetNodeSchemaNodeID(documentNode *lpg.Node) string
- func GetNodeValue(node *lpg.Node) (interface{}, error)
- func GetNodesInstanceOf(g *lpg.Graph, attrId string) []*lpg.Node
- func GetNodesWithValidators(root *lpg.Node) map[*lpg.Node]struct{}
- func GetObjectAttributeNodes(objectSchemaNode *lpg.Node) []*lpg.Node
- func GetObjectAttributeNodesBy(objectSchemaNode *lpg.Node, keyTerm string) (map[string][]*lpg.Node, error)
- func GetParentAttribute(node *lpg.Node) *lpg.Node
- func GetParentDocumentNodes(node *lpg.Node) []*lpg.Node
- func GetPathFromRoot(schemaNode *lpg.Node) []*lpg.Node
- func GetPolymorphicOptions(polymorphicSchemaNode *lpg.Node) []*lpg.Node
- func GetRawNodeValue(node *lpg.Node) (string, bool)
- func GetSchemaNodeIDMap(docRoot *lpg.Node) map[string][]*lpg.Node
- func GetSliceByTermsFunc(includeTerms []string, includeAttributeNodes bool) func(*Layer, *lpg.Node) *lpg.Node
- func GetTermMetadata(term string) interface{}
- func InstanceOf(node *lpg.Node) []*lpg.Node
- func InstantiateSchemaNode(targetGraph *lpg.Graph, schemaNode *lpg.Node, embedSchemaNodes bool, ...) *lpg.Node
- func InternSlice(interner Interner, slice []string) []string
- func IsAttributeNode(node *lpg.Node) bool
- func IsAttributeTreeEdge(edge *lpg.Edge) bool
- func IsAttributeType(typeName string) bool
- func IsCompilationArtifact(edge *lpg.Edge) bool
- func IsDocumentEdge(edge *lpg.Edge) bool
- func IsDocumentNode(node *lpg.Node) bool
- func IsEntityRoot(node *lpg.Node) bool
- func IsInstanceOf(n *lpg.Node, schemaNodeID string) bool
- func IsNodeEntityRoot(node *lpg.Node) bool
- func IsPropertiesEqual(p, q map[string]*PropertyValue) bool
- func IsTermRegistered(term string) bool
- func IterateAncestors(root *lpg.Node, nodeFunc func(*lpg.Node) bool, ...) bool
- func IterateDescendants(from *lpg.Node, nodeFunc func(*lpg.Node) bool, ...) bool
- func IterateDescendantsp(from *lpg.Node, nodeFunc func(*lpg.Node, []*lpg.Node) bool, ...) bool
- func LDDescendToListElements(in []interface{}) []interface{}
- func LDGetKeyValue(key string, node interface{}) (interface{}, bool)
- func LDGetListElements(node interface{}) []interface{}
- func LDGetNodeID(node interface{}) string
- func LDGetNodeTypes(node interface{}) []string
- func LDGetNodeValue(node interface{}) string
- func LDGetStringValue(key string, node interface{}) string
- func LDGetValueArr(in map[string]interface{}) []interface{}
- func MakeErrInvalidInput(id ...string) error
- func MarshalLayer(layer *Layer) (interface{}, error)
- func NewDocumentGraph() *lpg.Graph
- func NewEvalContext(g *lpg.Graph) *opencypher.EvalContext
- func NewLayerGraph() *lpg.Graph
- func NewTerm(ns, lname string, isID, isList bool, comp CompositionType, md interface{}, ...) string
- func ParseNSMap(in string) (string, string, error)
- func ProcessLabeledAs(graph *lpg.Graph)
- func PropertiesAsMap(iterator interface{ ... }) map[string]*PropertyValue
- func PropertyValueFromNative(key string, value interface{}) interface{}
- func RegisterNewDocGraphHook(f func(*lpg.Graph))
- func RegisterNewLayerGraphHook(f func(*lpg.Graph))
- func RegisterTerm(t TermSemantics)
- func RemoveDuplicateEntities(ei map[*lpg.Node]EntityInfo) bool
- func RemoveRawNodeValue(node *lpg.Node)
- func RunTestsFromFile(t *testing.T, file string, unmarshal func(json.RawMessage) (TestCase, error))
- func SameTerm(term1, term2 string) bool
- func SetAttributeID(node *lpg.Node, ID string)
- func SetEntityIDVectorElement(entityRootNode *lpg.Node, schemaNodeID, value string) error
- func SetEntityIDVectorElementFromNode(docNode *lpg.Node, value string) error
- func SetNodeID(node *lpg.Node, ID string)
- func SetNodeIndex(node *lpg.Node, index int)
- func SetNodeValue(node *lpg.Node, value interface{}) error
- func SetRawNodeValue(node *lpg.Node, value string)
- func SkipEdgesToNodeWithType(typ string) func(*lpg.Edge) EdgeFuncResult
- func SortEdges(edges []*lpg.Edge) []*lpg.Edge
- func SortEdgesItr(edges lpg.EdgeIterator) lpg.EdgeIterator
- func SortNodes(nodes []*lpg.Node)
- func StringSetIntersection(s1, s2 []string) []string
- func StringSetSubtract(s1, s2 []string) []string
- func StringSetToSlice(str map[string]struct{}) []string
- func StringSetUnion(s1, s2 []string) []string
- func ToMap(in interface{}) interface{}
- func UnmarshalJSONLDGraph(input interface{}, target *lpg.Graph, interner Interner) error
- func ValidateDocumentNode(node *lpg.Node) error
- func ValidateDocumentNodeBySchema(node, schemaNode *lpg.Node) error
- func ValidateValueBySchema(v *string, schemaNode *lpg.Node) error
- func WalkNodesInEntity(aNode *lpg.Node, f func(*lpg.Node) bool) bool
- type AttributeReference
- type CompilablePropertyContainer
- type CompileOCSemantics
- func (CompileOCSemantics) CompileTerm(target CompilablePropertyContainer, term string, value *PropertyValue) error
- func (CompileOCSemantics) Compiled(target CompilablePropertyContainer, term string) []opencypher.Evaluatable
- func (c CompileOCSemantics) Evaluate(target CompilablePropertyContainer, term string, ...) ([]opencypher.ResultSet, error)
- type CompiledGraph
- type CompiledProperties
- func (p *CompiledProperties) CopyCompiledToMap(target map[interface{}]interface{})
- func (p *CompiledProperties) CopyTo(target *CompiledProperties)
- func (p *CompiledProperties) GetCompiledProperty(key interface{}) (interface{}, bool)
- func (p *CompiledProperties) SetCompiledProperty(key, value interface{})
- type Compiler
- type Composer
- type CompositionType
- type Context
- type DefaultCompiledGraph
- type DefaultLogger
- type EdgeCompiler
- type EdgeFuncResult
- type EncodingIndex
- type EntityInfo
- type EntityInfoIndex
- type ErrCannotDetermineEdgeLabel
- type ErrCannotDeterminePropertyName
- type ErrCannotFindAncestor
- type ErrCannotInstantiateSchemaNode
- type ErrCannotResolveLink
- type ErrDataIngestion
- type ErrDuplicate
- type ErrDuplicateAttributeID
- type ErrInconsistentTypes
- type ErrInvalidEntityID
- type ErrInvalidForeignKeys
- type ErrInvalidInput
- type ErrInvalidLinkSpec
- type ErrInvalidNSMapExpression
- type ErrInvalidSchema
- type ErrInvalidValidator
- type ErrInvalidValue
- type ErrInvalidValuesetSpec
- type ErrMultipleParentNodes
- type ErrMultipleTargetsFound
- type ErrMultipleTypes
- type ErrNoParentNode
- type ErrNotFound
- type ErrPathInstantiation
- type ErrSchemaValidation
- type ErrTerm
- type ErrValidation
- type ErrValidatorCompile
- type ErrValueset
- type ForeignKeyInfo
- type GraphBuilder
- func (gb GraphBuilder) ArrayAsEdge(schemaNode, parentNode *lpg.Node, types ...string) (*lpg.Edge, error)
- func (gb GraphBuilder) ArrayAsNode(schemaNode, parentNode *lpg.Node, types ...string) (*lpg.Edge, *lpg.Node, error)
- func (gb GraphBuilder) CollectionAsEdge(schemaNode, parentNode *lpg.Node, typeTerm string, types ...string) (*lpg.Edge, error)
- func (gb GraphBuilder) CollectionAsNode(schemaNode, parentNode *lpg.Node, typeTerm string, types ...string) (*lpg.Edge, *lpg.Node, error)
- func (gb GraphBuilder) GetGraph() *lpg.Graph
- func (gb GraphBuilder) GetOptions() GraphBuilderOptions
- func (gb GraphBuilder) LinkNodes(ctx *Context, schema *Layer) error
- func (gb GraphBuilder) LinkNodesWithSpecs(ctx *Context, specs []*LinkSpec, eix EntityInfoIndex) error
- func (gb GraphBuilder) NativeValueAsEdge(schemaNode, parentDocumentNode *lpg.Node, value interface{}, types ...string) (*lpg.Edge, error)
- func (gb GraphBuilder) NativeValueAsNode(schemaNode, parentDocumentNode *lpg.Node, value interface{}, types ...string) (*lpg.Edge, *lpg.Node, error)
- func (gb GraphBuilder) NativeValueAsProperty(schemaNode *lpg.Node, graphPath []*lpg.Node, value interface{}) error
- func (gb GraphBuilder) NewNode(schemaNode *lpg.Node) *lpg.Node
- func (gb GraphBuilder) NewUniqueEdge(fromNode, toNode *lpg.Node, label string, properties map[string]interface{}) *lpg.Edge
- func (gb GraphBuilder) ObjectAsEdge(schemaNode, parentNode *lpg.Node, types ...string) (*lpg.Edge, error)
- func (gb GraphBuilder) ObjectAsNode(schemaNode, parentNode *lpg.Node, types ...string) (*lpg.Edge, *lpg.Node, error)
- func (gb GraphBuilder) PostIngest(schemaRootNode, docRootNode *lpg.Node) error
- func (gb GraphBuilder) PostIngestSchemaNode(schemaRootNode, schemaNode, docRootNode *lpg.Node, ...) error
- func (gp GraphBuilder) PostNodeIngest(schemaNode, docNode *lpg.Node) error
- func (gb GraphBuilder) RawValueAsEdge(schemaNode, parentDocumentNode *lpg.Node, value string, types ...string) (*lpg.Edge, error)
- func (gb GraphBuilder) RawValueAsNode(schemaNode, parentDocumentNode *lpg.Node, value string, types ...string) (*lpg.Edge, *lpg.Node, error)
- func (gb GraphBuilder) RawValueAsProperty(schemaNode *lpg.Node, graphPath []*lpg.Node, value string) error
- func (gb GraphBuilder) ValueAsEdge(schemaNode, parentDocumentNode *lpg.Node, setValue func(*lpg.Node) error, ...) (*lpg.Edge, error)
- func (gb GraphBuilder) ValueAsNode(schemaNode, parentDocumentNode *lpg.Node, setValue func(*lpg.Node) error, ...) (*lpg.Edge, *lpg.Node, error)
- func (gb GraphBuilder) ValueAsProperty(schemaNode *lpg.Node, graphPath []*lpg.Node, setValue func(*lpg.Node, string)) error
- func (gb GraphBuilder) ValueSetAsEdge(node, schemaNode, parentDocumentNode *lpg.Node)
- func (gb GraphBuilder) ValueSetAsNode(node, schemaNode, parentDocumentNode *lpg.Node)
- func (gb GraphBuilder) ValueSetAsProperty(schemaNode *lpg.Node, graphPath []*lpg.Node, value string)
- type GraphBuilderOptions
- type HasLabels
- type HasNativeValue
- type Ingester
- type Interner
- type JSONMarshaler
- type LDMarshaler
- type LDNode
- type Layer
- func (l *Layer) Clone() *Layer
- func (l *Layer) CloneInto(targetGraph *lpg.Graph) (*Layer, map[*lpg.Node]*lpg.Node)
- func (layer *Layer) Compose(context *Context, source *Layer) error
- func (l *Layer) FindAttributeByID(id string) (*lpg.Node, []*lpg.Node)
- func (l *Layer) FindFirstAttribute(predicate func(*lpg.Node) bool) (*lpg.Node, []*lpg.Node)
- func (l *Layer) ForEachAttribute(f func(*lpg.Node, []*lpg.Node) bool) bool
- func (l *Layer) ForEachAttributeOrdered(f func(*lpg.Node, []*lpg.Node) bool) bool
- func (l *Layer) GetAttributeByID(id string) *lpg.Node
- func (l *Layer) GetAttributePath(node *lpg.Node) []*lpg.Node
- func (l *Layer) GetAttributesByID(ids []string) []*lpg.Node
- func (l *Layer) GetEncoding() (encoding.Encoding, error)
- func (l *Layer) GetEntityIDNodes() []string
- func (l *Layer) GetID() string
- func (l *Layer) GetLayerRootNode() *lpg.Node
- func (l *Layer) GetLayerType() string
- func (l *Layer) GetLinkSpecs() ([]*LinkSpec, error)
- func (l *Layer) GetOverlayAttributes() []*lpg.Node
- func (l *Layer) GetSchemaRootNode() *lpg.Node
- func (l *Layer) GetValueType() string
- func (l *Layer) NodeSlice() []*lpg.Node
- func (l *Layer) SetID(ID string)
- func (l *Layer) SetLayerType(t string)
- func (l *Layer) SetValueType(t string)
- func (layer *Layer) Slice(layerType string, nodeFilter func(*Layer, *lpg.Node) *lpg.Node) *Layer
- type LinkSpec
- type LogLevel
- type Logger
- type NodeCompiler
- type NodePath
- type NodeValidator
- type NodeValueAccessor
- type ParsedDocNode
- type PostIngest
- type PostNodeIngest
- type PropertyContainer
- type PropertyValue
- func AsPropertyValue(in interface{}, exists bool) *PropertyValue
- func ComposeProperty(context *Context, key string, targetValue, sourceValue *PropertyValue) (*PropertyValue, error)
- func GetEntityIDFields(node *lpg.Node) *PropertyValue
- func GetNodeOrSchemaProperty(node *lpg.Node, key string) (*PropertyValue, bool)
- func IntPropertyValue(term string, i int) *PropertyValue
- func ListAppend(v1, v2 *PropertyValue) *PropertyValue
- func SetUnion(v1, v2 *PropertyValue) *PropertyValue
- func StringPropertyValue(term, s string) *PropertyValue
- func StringSlicePropertyValue(term string, s []string) *PropertyValue
- func (p *PropertyValue) AsInt() int
- func (p *PropertyValue) AsInterfaceSlice() []interface{}
- func (p *PropertyValue) AsString() string
- func (p *PropertyValue) AsStringSlice() []string
- func (p *PropertyValue) Clone() *PropertyValue
- func (p *PropertyValue) Equal(v *PropertyValue) bool
- func (p PropertyValue) GetNativeValue() interface{}
- func (pv *PropertyValue) GetSem() *TermSemantics
- func (pv *PropertyValue) GetTerm() string
- func (p *PropertyValue) Has(s string) bool
- func (p *PropertyValue) IsEqual(q *PropertyValue) bool
- func (p *PropertyValue) IsInt() bool
- func (p *PropertyValue) IsString() bool
- func (p *PropertyValue) IsStringSlice() bool
- func (p PropertyValue) MarshalJSON() ([]byte, error)
- func (p PropertyValue) MarshalYAML() (interface{}, error)
- func (p *PropertyValue) MustStringSlice() []string
- func (p *PropertyValue) Slice() []string
- func (p PropertyValue) String() string
- type SchemaLoader
- type SchemaLoaderFunc
- type StringInterner
- type TermCompiler
- type TermMarshaler
- type TermSemantics
- type TestCase
- type ValueAccessor
- type ValueValidator
- type ValuesetInfo
- func (vsi *ValuesetInfo) ApplyValuesetResponse(ctx *Context, builder GraphBuilder, layer *Layer, ...) error
- func (vsi *ValuesetInfo) GetContextNode(docNode *lpg.Node) (*lpg.Node, error)
- func (vsi *ValuesetInfo) GetDocNodes(g *lpg.Graph) []*lpg.Node
- func (vsi *ValuesetInfo) GetRequest(ctx *Context, contextDocumentNode, vsiDocumentNode *lpg.Node) (map[string]string, error)
- type ValuesetLookupRequest
- type ValuesetLookupResponse
- type ValuesetProcessor
- func (prc *ValuesetProcessor) Process(ctx *Context, builder GraphBuilder, ...) error
- func (prc *ValuesetProcessor) ProcessByContextNode(ctx *Context, builder GraphBuilder, ...) error
- func (prc *ValuesetProcessor) ProcessGraph(ctx *Context, builder GraphBuilder) error
- func (prc *ValuesetProcessor) ProcessGraphValueset(ctx *Context, builder GraphBuilder, vsi *ValuesetInfo) error
Constants ¶
const ( IngestAsNode = "node" IngestAsEdge = "edge" IngestAsProperty = "property" )
IngestAs constants
const LS = "https://lschema.org/"
Variables ¶
var ( ErrInvalidJsonLdGraph = errors.New("Invalid JsonLd graph") ErrInvalidJsonGraph = errors.New("Invalid JSON graph") ErrUnexpectedEOF = errors.New("Unexpected EOF") ErrAttributeWithoutID = errors.New("Attribute without id") ErrNotALayer = errors.New("Not a layer") ErrCompositionSourceNotOverlay = errors.New("Composition source is not an overlay") ErrIncompatibleComposition = errors.New("Incompatible composition of layers") ErrInvalidComposition = errors.New("Invalid composition") )
Error declarations for marshaling and composition
var ( // ReferenceFK specifies the foreign key value ReferenceFK = NewTerm(LS+"Reference/", "fkValue", false, false, OverrideComposition, nil) // ReferenceFKFor is used for value nodes that are foreign keys ReferenceFKFor = NewTerm(LS+"Reference/", "fkFor", false, false, OverrideComposition, nil) // ReferenceFKTerm specifies the foreign key attribute ID ReferenceFKTerm = NewTerm(LS+"Reference/", "fk", false, false, OverrideComposition, nil) // ReferenceLabelTerm specifies the edge label between the referenced nodes ReferenceLabelTerm = NewTerm(LS+"Reference/", "label", false, false, OverrideComposition, nil) // ReferenceDirectionTerm specifies the direction of the edge. If // "to" or "toTarget", the edge points to the target entity. // If "from" or "fromTarget", the edge points // to this entity. ReferenceDirectionTerm = NewTerm(LS+"Reference/", "dir", false, false, OverrideComposition, nil) // ReferenceLinkNodeTerm specifies the node in the current entity // that will be linked to the other entity. If the references are // defined in a Reference type node, then the node itself if the // link. Otherwise, this gives the node that must be linked to the // other entity. ReferenceLinkNodeTerm = NewTerm(LS+"Reference/", "linkNode", false, false, OverrideComposition, nil) // ReferenceMultiTerm specifies if there can be more than one link targets ReferenceMultiTerm = NewTerm(LS+"Reference/", "multi", false, false, OverrideComposition, nil) )
var ( // SchemaTerm is the layer type for schemas SchemaTerm = NewTerm(LS, "Schema", false, false, NoComposition, nil) // OverlayTerm is the layer type for overlays OverlayTerm = NewTerm(LS, "Overlay", false, false, NoComposition, nil) // ComposeTerm is used for overlays to redefine term compositions. One of CompositionType constants ComposeTerm = NewTerm(LS, "compose", false, false, OverrideComposition, nil) // AttributeOverlaysTerm lists the overlays for schema attributes // that are matched by ID, as opposed to matching by ID and their // place in the layer AttributeOverlaysTerm = NewTerm(LS, "attributeOverlays", false, true, OverrideComposition, nil) // NSMapTerm specifies a namespace map for an overlay. A Namespace // map includes one or more expressions of the form: // // from -> to // // where from and to are attribute id prefixes. All the prefixes of // attributes that match from are converted to to. // // This is necessary when a different variants of a schema is used in // a complex schema. Each variant gets its own namespace. NSMapTerm = NewTerm(LS, "nsMap", false, false, OverrideComposition, nil) // CharacterEncodingTerm is used to specify a character encoding for // the data processed with the layer CharacterEncodingTerm = NewTerm(LS, "characterEncoding", false, false, OverrideComposition, nil) // InstanceOfTerm is an edge term that is used to connect values with // their schema specifications InstanceOfTerm = NewTerm(LS, "instanceOf", false, false, ErrorComposition, nil) // SchemaNodeIDTerm denotes the schema node ID for ingested nodes SchemaNodeIDTerm = NewTerm(LS, "schemaNodeId", false, false, ErrorComposition, nil) // SchemaVariantTerm is the schema variant type SchemaVariantTerm = NewTerm(LS, "SchemaVariant", false, false, NoComposition, nil) // DescriptionTerm is used for comments/descriptions DescriptionTerm = NewTerm(LS, "description", false, false, SetComposition, nil) // AttributeNameTerm represents the name of an attribute AttributeNameTerm = NewTerm(LS, "attributeName", false, false, OverrideComposition, nil) // AttributeIndexTerm represents the index of an array element AttributeIndexTerm = NewTerm(LS, "attributeIndex", false, false, NoComposition, nil) // ConditionalTerm specifies conditions for ingestion ConditionalTerm = NewTerm(LS, "conditional", false, false, OverrideComposition, nil) // LayerRootTerm is an edge term that connects layer node to the root node of the schema LayerRootTerm = NewTerm(LS, "layer", false, false, ErrorComposition, nil) // DefaultValueTerm is the default value for an attribute if attribute is not present DefaultValueTerm = NewTerm(LS, "defaultValue", false, false, OverrideComposition, nil) // Format specifies a type-specific formatting directive, such as a date format FormatTerm = NewTerm(LS, "format", false, false, OverrideComposition, nil) // EntitySchemaTerm is inserted by the schema compilation to mark // entity roots. It records the schema ID containing the entity // definition. EntitySchemaTerm = NewTerm(LS, "entitySchema", false, false, ErrorComposition, nil) // NodeIDTerm keeps the node ID or the attribute ID NodeIDTerm = NewTerm(LS, "nodeId", false, false, ErrorComposition, nil) // IngestAsTerm ingests value as an edge, node, or property IngestAsTerm = NewTerm(LS, "ingestAs", false, false, OverrideComposition, nil) // AsPropertyOfTerm is optional. If specified, it gives the nearest // ancestor node that is an instance of the given type. If not, it // is the parent document node AsPropertyOfTerm = NewTerm(LS, "asPropertyOf", false, false, OverrideComposition, nil) // EdgeLabelTerm represents the value used as an edge label, when ingesting an edge EdgeLabelTerm = NewTerm(LS, "edgeLabel", false, false, OverrideComposition, nil) // PropertyNameTerm represents the value used as a property name when ingesting a property PropertyNameTerm = NewTerm(LS, "propertyName", false, false, OverrideComposition, nil) // DocumentNodeTerm is the type of document nodes DocumentNodeTerm = NewTerm(LS, "DocumentNode", false, false, ErrorComposition, nil) // NodeValueTerm is the property key used to keep node value NodeValueTerm = NewTerm(LS, "value", false, false, ErrorComposition, nil) // ValueTypeTerm defines the type of a value ValueTypeTerm = NewTerm(LS, "valueType", false, false, OverrideComposition, nil) // HasTerm is an edge term for linking document elements HasTerm = NewTerm(LS, "has", false, false, ErrorComposition, nil) // EntityIDFieldsTerm is a string or []string that lists the attribute IDs // for entity ID. It is defined at the root node of a layer. All // attribute IDs must refer to value nodes. EntityIDFieldsTerm = NewTerm(LS, "entityIdFields", false, false, OverrideComposition, nil) // EntityIDTerm is a string or []string that gives the unique ID of // an entity. This is a node property at the root node of an entity EntityIDTerm = NewTerm(LS, "entityId", false, false, OverrideComposition, nil) // LabeledAsTerm adds labels to JSON schemas LabeledAsTerm = NewTerm(LS, "labeledAs", false, false, OverrideComposition, nil) // TypeDiscriminatorTerm represents a set of schema field hints for defining polymorphic objects TypeDiscriminatorTerm = NewTerm(LS, "typeDiscriminator", false, false, NoComposition, nil) // IncludeSchemaTerm represents another schema to replace and copy its contents IncludeSchemaTerm = NewTerm(LS, "include", false, false, OverrideComposition, nil) // Namespace defines the namespace prefix NamespaceTerm = NewTerm(LS, "namespace", false, false, OverrideComposition, nil) )
var ( AttributeTypeValue = NewTerm(LS, "Value", false, false, OverrideComposition, nil) AttributeTypeObject = NewTerm(LS, "Object", false, false, OverrideComposition, nil) AttributeTypeArray = NewTerm(LS, "Array", false, false, OverrideComposition, nil) AttributeTypeReference = NewTerm(LS, "Reference", false, false, OverrideComposition, nil) AttributeTypeComposite = NewTerm(LS, "Composite", false, false, OverrideComposition, nil) AttributeTypePolymorphic = NewTerm(LS, "Polymorphic", false, false, OverrideComposition, nil) AttributeNodeTerm = NewTerm(LS, "Attribute", false, false, OverrideComposition, nil) )
Attribute types defines the terms describing attribute types. Each attribute must have one of the attribute types plus the Attribute type, marking the object as an attribute.
var ( // Unordered named attributes (json object) ObjectAttributesTerm = NewTerm(LS, "Object/attributes", false, false, ErrorComposition, nil) // Ordered named attributes (json object, xml elements) ObjectAttributeListTerm = NewTerm(LS, "Object/attributeList", false, true, ErrorComposition, nil) // Reference to another schema. This will be resolved to another // schema during compilation ReferenceTerm = NewTerm(LS, "Reference/ref", false, false, OverrideComposition, nil) // ArrayItems contains the definition for the items of the array ArrayItemsTerm = NewTerm(LS, "Array/elements", false, false, ErrorComposition, nil) // All components of a composite attribute AllOfTerm = NewTerm(LS, "Composite/allOf", false, true, ErrorComposition, nil) // All options of a polymorphic attribute OneOfTerm = NewTerm(LS, "Polymorphic/oneOf", false, true, ErrorComposition, nil) )
Layer terms includes type specific terms recognized by the schema compiler. These are terms used to define elements of an attribute.
var ( // ValuesetContextTerm specifies the context under which valueset related values are to be looked up. // // For instance, consider a row of data: // // root ----> item1 // ----> item2 // // If item1 and item2 are values that can be used as an input to // valueset lookup, then the context should be set to root // // A node must contain either the ValuesetContextTerm or the ValuesetTablesTerm to be used in lookup // // If context is empty, entity root is assumed ValuesetContextTerm = NewTerm(LS, "vs/context", false, false, OverrideComposition, nil) // ValuesetContextExprTerm is an opencyper expression that gives the context node using "this" as the current node ValuesetContextExprTerm = NewTerm(LS, "vs/contextExpr", false, false, OverrideComposition, nil) // ValuesetTablesTerm specifies the list of table IDs to // lookup. This is optional. A node must contain either the // ValuesetContextTerm or the ValuesetTablesTerm to be used in // lookup ValuesetTablesTerm = NewTerm(LS, "vs/valuesets", false, false, OverrideComposition, nil) // ValuesetRequestKeysTerm specifies the keys that will be used in // the valueset request. These keys are interpreted by the valueset // lookup. ValuesetRequestKeysTerm = NewTerm(LS, "vs/requestKeys", false, false, OverrideComposition, nil) // ValuesetRequestValuesTerm contains entries matching // ValuesetRequestKeysTerm. It specifies the schema node IDs of the // nodes containing values to lookup ValuesetRequestValuesTerm = NewTerm(LS, "vs/requestValues", false, false, OverrideComposition, nil) // ValuesetRequestTerm specifies one or more openCypher expressions // that builds up a valuest lookup request. The named results of // those expressions are added to the request key/value pairs ValuesetRequestTerm = NewTerm(LS, "vs/request", false, false, OverrideComposition, CompileOCSemantics{}) // ValuesetResultKeys term contains the keys that will be returned // from the valueset lookup. Values of these keys will be inserted under the context ValuesetResultKeysTerm = NewTerm(LS, "vs/resultKeys", false, false, OverrideComposition, nil) // ValuesetResultValuesTerm specifies the schema node IDs for the // nodes that will receive the matching key values. If there is only // one, resultKeys is optional The result value nodes must be a // direct descendant of one of the nodes from the document node up // to the context node. ValuesetResultValuesTerm = NewTerm(LS, "vs/resultValues", false, false, OverrideComposition, nil) // ValuesetResultContext determines the node under which the results // will be added. This is needed if the results will be added under // a different entity attached to the valueset context. ValuesetResultContextTerm = NewTerm(LS, "vs/resultContext", false, false, OverrideComposition, nil) )
var DefaultLogLevel = LogLevelError
var DefaultTermMarshaler defaultTermMarshaler
var ErrInvalidEncodingIndex = errors.New("Invalid encoding index")
ErrInvalidEncodingIndex is used to return error about an invalid or unrecognized character encoding
var HashSHA1Term = NewTerm(LS, "hash.sha1", false, false, OverrideComposition, hashSemantics{})
var HashSHA256Term = NewTerm(LS, "hash.sha256", false, false, OverrideComposition, hashSemantics{})
var HashSHA512Term = NewTerm(LS, "hash.sha512", false, false, OverrideComposition, hashSemantics{})
var HashTerm = NewTerm(LS, "hash", false, false, OverrideComposition, hashSemantics{})
var IncludeAllNodesInSliceFunc = func(layer *Layer, nd *lpg.Node) *lpg.Node { return CloneNode(nd, layer.Graph) }
IncludeAllNodesInSliceFunc includes all the nodes in the slice
var OnlyDocumentNodes = FollowEdgesToNodeWithType(DocumentNodeTerm)
OnlyDocumentNodes can be used in IterateDescendants edge func to follow edges that reach to document nodes
var SetValueTerm = NewTerm(LS, "setValue", false, false, OverrideComposition, setValueSemantics{})
var SkipDocumentNodes = SkipEdgesToNodeWithType(DocumentNodeTerm)
SkipDocumentNodes can be used in IterateDescendants edge func to skip all edges that go to a document node
var SkipSchemaNodes = SkipEdgesToNodeWithType(AttributeNodeTerm)
SkipSchemaNodes can be used in IterateDescendants edge func to skip all edges that go to a schema node
Functions ¶
func CloneProperties ¶
func CloneProperties(iterator interface { ForEachProperty(func(string, interface{}) bool) bool }) map[string]interface{}
CloneProperties can be used to clone edge and node properties
func ClonePropertyValueFunc ¶
func ClonePropertyValueFunc(key string, value interface{}) interface{}
ClonePropertyFunc can be used in graph copy functions
func CombineNodeTypes ¶
CombineNodeTypes returns a combination of the types of all the given nodes
func CompileTerms ¶
CompileTerms compiles all node and edge terms of the layer
func ComposeProperties ¶
ComposeProperties will combine the properties in source to target. The target properties will be modified directly
func CopyGraph ¶
func CopyGraph(target, source *lpg.Graph, nodeSelector func(*lpg.Node) bool, edgeSelector func(*lpg.Edge) bool) map[*lpg.Node]*lpg.Node
CopyGraph source to target using the optional node/edge selectors. Return a node map from the in to target nodes
func CopyPropertyMap ¶
func CopyPropertyMap(m map[string]*PropertyValue) map[string]*PropertyValue
CopyPropertyMap returns a copy of the property map
func CopySchemaNodeIntoGraph ¶
CopySchemaNodeIntoGraph copies a schema node and the subtree under it that does not belong the schema into the target graph
func DeepEqual ¶
func DeepEqual(i1, i2 interface{}) error
DeepEqual test equivalence between two JSON trees
func DocumentNodesUnder ¶
DocumentNodesUnder returns all document nodes under the given node(s)
func EnsurePath ¶
func EnsurePath(rootDocNode, ancestorDocNode *lpg.Node, rootSchemaNode, schemaNode *lpg.Node, instantiate func(parentDocNode, schemaNode *lpg.Node) (*lpg.Node, error)) (*lpg.Node, error)
EnsurePath finds or instantiates a path in the graph. The path will start at rootDocNode, which is an instance of rootSchemaNode, will pass through ancestorDocNode if ancestorDocNode is not nil, and will be an instance of schemaNode. Each node will be created using the instantiate func that takes the parent document node, and the schema node to instantiate.
func FilterAttributeTypes ¶
FilterAttributeTypes returns all recognized attribute types from the given types array. This is mainly used for validation, to ensure there is only one attribute type
func FilterNonLayerTypes ¶
FilterNonLayerTypes returns the types that are not attribute or layer related
func FindChildInstanceOf ¶
FindChildInstanceOf returns the childnodes of the parent that are instance of the given attribute id
func FindDuplicatedEntities ¶
func FindDuplicatedEntities(ei map[*lpg.Node]EntityInfo) [][]*lpg.Node
FindDuplicatedEntities returns all entity root nodes with nonempty ids that are duplicated
func FollowEdgesToNodeWithType ¶
func FollowEdgesToNodeWithType(typ string) func(*lpg.Edge) EdgeFuncResult
FollowEdgesToNodeWithType returns a function that only follows edges that go to a node with the given type
func ForEachAttributeNode ¶
ForEachAttributeNode calls f with each attribute node, depth first. Path contains all the nodes from root to the current node. If f returns false, iteration stops. This function visits each node only once
func ForEachAttributeNodeOrdered ¶
func ForEachAttributeNodeOrdered(root *lpg.Node, f func(node *lpg.Node, path []*lpg.Node) bool) bool
ForEachAttributeNodeOrdered calls f with each attribute node, depth first, preserving order. Path contains all the nodes from root to the current node. If f returns false, iteration stops. This function visits each node only once
func FormatNodeValue ¶
FormatNodeValue formats the node value as string
func GetArrayElementNode ¶
GetArrayElementNode returns the array element node from an array node
func GetAttributeID ¶
GetAttributeID returns the attributeID
func GetAttributePath ¶
GetAttributePath returns the path from root to node. There must exist exactly one path. If not, returns nil
func GetAttributeValidator ¶
func GetAttributeValidator(term string) (NodeValidator, ValueValidator)
GetAttributeValidator returns a validator implementation for the given validation term
func GetEntityInfo ¶
func GetEntityInfo(g *lpg.Graph) map[*lpg.Node]EntityInfo
GetEntityInfo returns all the nodes that are entity roots, i.e. nodes containing EntitySchemaTerm
func GetEntityRoot ¶
GetEntityRoot tries to find the entity containing this node by going backwards until a node with EntitySchemaTerm
func GetEntityRootNode ¶
GetEntityRootNode returns the entity root node containing this node
func GetIngestAs ¶
GetIngestAs returns "node", "edge", "property", or "none" based on IngestAsTerm
func GetIngestAsProperty ¶
func GetLayerEntityRoot ¶
GetLayerEntityRoot returns the layer entity root node containing the given schema node
func GetNodeIndex ¶
GetNodeIndex returns the value of attribute index term as int
func GetNodeSchemaNodeID ¶
GetNodeSchemaNodeID returns the schema node ID of a document node. Returns empty string if not found.
func GetNodeValue ¶
GetNodeValue returns the field value processed by the schema type information. The returned object is a Go native object based on the node type
func GetNodesInstanceOf ¶
GetNodesInstanceOf returns document nodes that are instance of the given attribute id
func GetNodesWithValidators ¶
GetNodesWithValidators returns all nodes under root that has validators
func GetObjectAttributeNodes ¶
GetObjectAttributeNodes returns the schema attribute nodes under a schema object.
func GetObjectAttributeNodesBy ¶
func GetObjectAttributeNodesBy(objectSchemaNode *lpg.Node, keyTerm string) (map[string][]*lpg.Node, error)
GetObjectAttributeNodesBy returns the schema attribute nodes under a schema object. The returned map is keyed by the keyTerm
func GetParentAttribute ¶
GetParentAttribute returns the parent attribute of the given node
func GetParentDocumentNodes ¶
GetParentDocumentNodes returns the document nodes that have incoming edges to this node
func GetPathFromRoot ¶
GetPathFromEntityRoot returns the path from the entity root node of the schema
func GetPolymorphicOptions ¶
GetPolymorphicOptions returns the polymorphic options of a schema node
func GetRawNodeValue ¶
GetRawNodeValue returns the unprocessed node value
func GetSchemaNodeIDMap ¶
GetSchemaNodeIDMap returns a map of schema node IDs to slices of nodes that are instances of those schema nodes
func GetSliceByTermsFunc ¶
func GetSliceByTermsFunc(includeTerms []string, includeAttributeNodes bool) func(*Layer, *lpg.Node) *lpg.Node
GetSliceByTermsFunc is used in the Slice function to select nodes by the properties it contains. If includeAttributeNodes is true, attributes nodes are included unconditionally even though the node does not contain any of the terms.
func GetTermMetadata ¶
func GetTermMetadata(term string) interface{}
GetTermMetadata returns metadata about a term
func InstanceOf ¶
InstanceOf returns the nodes that are connect to this node via instanceOf term,
func InstantiateSchemaNode ¶
func InstantiateSchemaNode(targetGraph *lpg.Graph, schemaNode *lpg.Node, embedSchemaNodes bool, schemaNodeMap map[*lpg.Node]*lpg.Node) *lpg.Node
InstantiateSchemaNode creates a new node in targetGraph that is an instance of the given schemaNode. If embedSchemaNodes is true, the properties of the schema node will be embedded into the new schema node. If embedSchemaNodes is false, schema nodes will be kept separate. The schemaNodeMap will be filled with the map of schema nodes copied into the target graph. The key will be the original schema node, and the value will be the copied schema node in targetGraph. Returns the new node.
func InternSlice ¶
InternSlice interns all elements of a slice
func IsAttributeNode ¶
IsAttributeNode returns true if the node has Attribute type
func IsAttributeTreeEdge ¶
IsAttributeTreeEdge returns true if the edge is an edge between two attribute nodes
func IsAttributeType ¶
IsAttributeType returns true if the term is one of the attribute types
func IsCompilationArtifact ¶
IsCompilationArtifact returns true if the edge is a compilation artifact
func IsDocumentEdge ¶
IsDocumentEdge returns true if the edge is not an attribute link term
func IsDocumentNode ¶
IsDocumentNode returns if the node has the DocumentNodeTerm as one of its labels
func IsEntityRoot ¶
IsEntityRoot returns true if the node is an entity root
func IsInstanceOf ¶
IsInstanceOf returns true if g is an instance of the schema node
func IsNodeEntityRoot ¶
IsNodeEntityRoot checks if node is an entity root
func IsPropertiesEqual ¶
func IsPropertiesEqual(p, q map[string]*PropertyValue) bool
IsPropertiesEqual compares two property maps and returns true if they are equal
func IsTermRegistered ¶
func IterateAncestors ¶
func IterateAncestors(root *lpg.Node, nodeFunc func(*lpg.Node) bool, edgeFunc func(*lpg.Edge) EdgeFuncResult) bool
IterateAncestors iterates the ancestors of the node, calling nodeFunc for each node, and edgeFunc for each edge. If nodeFunc returns false, stops iteration and returns. The behavior after calling edgefunc depends on the return value. The edgeFunc may skip the edge, follow it, or stop processing.
func IterateDescendants ¶
func IterateDescendants(from *lpg.Node, nodeFunc func(*lpg.Node) bool, edgeFunc func(*lpg.Edge) EdgeFuncResult, ordered bool) bool
IterateDescendants iterates the descendants of the node based on the results of nodeFunc and edgeFunc.
For each visited node, if nodeFunc is not nil, nodeFunc is called with the node and the path to the node. If nodeFunc returns false, processing stops.
For each outgoing edge, if edgeFunc is not nil, edgeFunc is called with the edge and the path to the source node. If edgeFunc returns FollowEdgeResult, the edge is followed. If edgeFunc returned DontFollowEdgeResult, edge is skipped. If edgeFunc returns StopEdgeResult, iteration stops.
func IterateDescendantsp ¶
func LDDescendToListElements ¶
func LDDescendToListElements(in []interface{}) []interface{}
If in is a @list, returns its elements
func LDGetKeyValue ¶
LDGetKeyValue returns the value of the key in the node. The node must be a map
func LDGetListElements ¶
func LDGetListElements(node interface{}) []interface{}
LDGetListElements returns the elements of a @list node. The input can be a [{"@list":elements}] or {@list:elements}. If the input cannot be interpreted as a list, returns nil
func LDGetNodeID ¶
func LDGetNodeID(node interface{}) string
LDGetNodeID returns the node @id. The argument must be a map
func LDGetNodeTypes ¶
func LDGetNodeTypes(node interface{}) []string
LDGetNodeTypes returns the node @type. The argument must be a map
func LDGetNodeValue ¶
func LDGetNodeValue(node interface{}) string
LDGetNodeValue returns the node @value. The argument must be a map
func LDGetStringValue ¶
LDGetStringValue returns a string value from the node with the key. The node must be a map
func LDGetValueArr ¶
func LDGetValueArr(in map[string]interface{}) []interface{}
LDGetValueArr returns the result of a "@value" as an array regardless of the number of items it contains
func MakeErrInvalidInput ¶
MakeErrInvalidInput creates an ErrInvalidInput error. If there is only one argument, it is used as the ID field of the error. If there are two, then the first is used as the ID, and the second as msg. Other arguments are ignored.
func MarshalLayer ¶
Marshals the layer into an expanded jsonld document
func NewDocumentGraph ¶
NewDocumentGraph creates a new graph with the correct indexes for document ingestion
func NewEvalContext ¶
func NewEvalContext(g *lpg.Graph) *opencypher.EvalContext
func NewLayerGraph ¶
NewLayerGraph creates a new graph indexes to store layers
func NewTerm ¶
func NewTerm(ns, lname string, isID, isList bool, comp CompositionType, md interface{}, aliases ...string) string
NewTerm registers a term with given semantics, and returns the term.
func ParseNSMap ¶
ParseNSMap parses a string pair of the form
string1 -> string2
This is used in nsMap expression to specify namespace (prefix) mapping for node ids.
func ProcessLabeledAs ¶
func PropertiesAsMap ¶
func PropertiesAsMap(iterator interface { ForEachProperty(func(string, interface{}) bool) bool }) map[string]*PropertyValue
func PropertyValueFromNative ¶
func PropertyValueFromNative(key string, value interface{}) interface{}
func RegisterNewDocGraphHook ¶
func RegisterTerm ¶
func RegisterTerm(t TermSemantics)
func RemoveDuplicateEntities ¶
func RemoveDuplicateEntities(ei map[*lpg.Node]EntityInfo) bool
RemoveDuplicateEntities will assume that if there are multiple entities with the same ID, their contents are also identical. It will keep one of the duplicate entity roots, and remove all others. Returns true if things changed.
func RemoveRawNodeValue ¶
func RunTestsFromFile ¶
func SetAttributeID ¶
SetAttrributeID sets the attribute ID
func SetEntityIDVectorElement ¶
SetEntityIDVectorElement sets the entity Id component of the entity root node if the schema node is part of an entity id
func SetEntityIDVectorElementFromNode ¶
SetEntityIDVectorElementFromNode sets the entity Id component of the entity root node if the schema node is part of an entity id. The schema node ID and entity root node are found based on the given node
func SetNodeIndex ¶
func SetNodeValue ¶
SetNodeValue sets the node value using the given native Go value. The value is expected to be interpreted by the node types and converted to string. If there are no value accessors specified for the node, the value will be fmt.Sprint(value)
func SetRawNodeValue ¶
SetRawNodeValue sets the unprocessed node value
func SkipEdgesToNodeWithType ¶
func SkipEdgesToNodeWithType(typ string) func(*lpg.Edge) EdgeFuncResult
SkipEdgesToNodeWithType returns a function that skips edges that go to a node with the given type
func SortEdgesItr ¶
func SortEdgesItr(edges lpg.EdgeIterator) lpg.EdgeIterator
SortEdgesItr sorts the edges by index
func StringSetIntersection ¶
StringSetIntersection returns the common elements of s1 and s2
func StringSetSubtract ¶
StringSetSubtract returns all elements that are in s1 but not in s2
func StringSetToSlice ¶
StringSetToSlice converts a string set to slice
func StringSetUnion ¶
StringSetUnion returns s1 setunion s2
func UnmarshalJSONLDGraph ¶
UnmarshalJSONLDGraph Unmarshals a graph in JSON-LD format
func ValidateDocumentNode ¶
ValidateDocumentNode runs the validators for the document node
func ValidateDocumentNodeBySchema ¶
ValidateDocumentNodeBySchema runs the validators for the document node
func ValidateValueBySchema ¶
ValidateValueBySchema runs the validators for the value
Types ¶
type AttributeReference ¶
AttributeReference points to an attribute in a document. The attribute can be a node, or a property of a node
func GetAttributeReferenceBySchemaNode ¶
func GetAttributeReferenceBySchemaNode(schemaRootNode, schemaNode *lpg.Node, docContextNode *lpg.Node) (AttributeReference, bool)
GetAttributeReferenceBySchemaNode returns the attribute reference whose instance is under docContextNode
func (AttributeReference) AsPropertyValue ¶
func (a AttributeReference) AsPropertyValue() *PropertyValue
func (AttributeReference) IsProperty ¶
func (a AttributeReference) IsProperty() bool
type CompilablePropertyContainer ¶
type CompilablePropertyContainer interface { GetProperty(string) (interface{}, bool) SetProperty(string, interface{}) }
CompilablePropertyContainer contains properties and a compiled data map
type CompileOCSemantics ¶
type CompileOCSemantics struct{}
CompileOCSemantics is a compilation implementation for terms containing a slice of opencypher expressions. It compiles one or more expressions of the term, and places them im $compiled_term property.
func (CompileOCSemantics) CompileTerm ¶
func (CompileOCSemantics) CompileTerm(target CompilablePropertyContainer, term string, value *PropertyValue) error
func (CompileOCSemantics) Compiled ¶
func (CompileOCSemantics) Compiled(target CompilablePropertyContainer, term string) []opencypher.Evaluatable
func (CompileOCSemantics) Evaluate ¶
func (c CompileOCSemantics) Evaluate(target CompilablePropertyContainer, term string, evalCtx *opencypher.EvalContext) ([]opencypher.ResultSet, error)
Evaluate all compiled expressions and return nonempty resultsets.
type CompiledGraph ¶
type CompiledGraph interface { GetCompiledSchema(string) *Layer PutCompiledSchema(*Context, string, *Layer) (*Layer, error) GetGraph() *lpg.Graph }
A CompiledGraph is a graph of compiled schemas
type CompiledProperties ¶
type CompiledProperties struct {
// contains filtered or unexported fields
}
CompiledProperties is a lazy-initialized map
func (*CompiledProperties) CopyCompiledToMap ¶
func (p *CompiledProperties) CopyCompiledToMap(target map[interface{}]interface{})
func (*CompiledProperties) CopyTo ¶
func (p *CompiledProperties) CopyTo(target *CompiledProperties)
func (*CompiledProperties) GetCompiledProperty ¶
func (p *CompiledProperties) GetCompiledProperty(key interface{}) (interface{}, bool)
func (*CompiledProperties) SetCompiledProperty ¶
func (p *CompiledProperties) SetCompiledProperty(key, value interface{})
type Compiler ¶
type Compiler struct { // Loader loads a layer using a strong reference. Loader SchemaLoader // CGraph keeps the compiled interlinked schemas. If this is // initialized before compilation, then it is used during compilation // and new schemas are added to it. If it is left uninitialized, // compilation initializes it to default compiled graph CGraph CompiledGraph }
type Composer ¶
type Composer interface {
Compose(v1, v2 *PropertyValue) (*PropertyValue, error)
}
Composer interface represents term composition algorithm. During layer composition, any term metadata that implements Composer interface will be composed using the customized implementation. If the term does not implement the Composer interface, Setcomposition will be used
func GetComposerForProperty ¶
func GetComposerForProperty(p *PropertyValue) Composer
GetComposerForProperty returns the composer for the given property. Never returns nil
func GetComposerForTerm ¶
GetComposerForTerm returns a term composer
type CompositionType ¶
type CompositionType string
CompositionType determines the composition semantics for the term
const ( // SetComposition means when two terms are composed, set-union of the values are taken SetComposition CompositionType = "set" // ListComposition means when two terms are composed, their values are appended ListComposition CompositionType = "list" // OverrideComposition means when two terms are composed, the new one replaces the old one OverrideComposition CompositionType = "override" // NoComposition means when two terms are composed, the original remains NoComposition CompositionType = "nocompose" // ErrorComposition means if two terms are composed and they are different, composition fails ErrorComposition CompositionType = "error" )
func (CompositionType) Compose ¶
func (c CompositionType) Compose(target, src *PropertyValue) (*PropertyValue, error)
Compose target and src based on the composition type
type Context ¶
func DefaultContext ¶
func DefaultContext() *Context
func NewContext ¶
func (*Context) GetInterner ¶
type DefaultCompiledGraph ¶
type DefaultCompiledGraph struct {
// contains filtered or unexported fields
}
DefaultCompiledGraph keeps compiled graphs in a map. Zero value of DefaultCompiledGraph is ready to use
func (DefaultCompiledGraph) GetCompiledSchema ¶
func (d DefaultCompiledGraph) GetCompiledSchema(ref string) *Layer
GetCompiledSchema returns a compiled schema for the reference if known
func (DefaultCompiledGraph) GetGraph ¶
func (d DefaultCompiledGraph) GetGraph() *lpg.Graph
func (*DefaultCompiledGraph) PutCompiledSchema ¶
func (d *DefaultCompiledGraph) PutCompiledSchema(context *Context, ref string, layer *Layer) (*Layer, error)
PutCompiledSchema adds the copy of the schema to the common graph
type DefaultLogger ¶
func NewDefaultLogger ¶
func NewDefaultLogger() *DefaultLogger
func (DefaultLogger) Debug ¶
func (l DefaultLogger) Debug(properties map[string]interface{})
func (DefaultLogger) Error ¶
func (l DefaultLogger) Error(properties map[string]interface{})
func (DefaultLogger) Info ¶
func (l DefaultLogger) Info(properties map[string]interface{})
type EdgeCompiler ¶
type EdgeCompiler interface { // CompileEdge gets an edge and compiles the associated term on that // edge. It should store the compiled state into edge.Compiled with // an opaque key CompileEdge(*Layer, *lpg.Edge) error }
EdgeCompiler interface represents term compilation algorithm when the term is an edge
During schema compilation, if the term metadata for the edge label implements EdgeCompiler, this method is called.
func GetEdgeCompiler ¶
func GetEdgeCompiler(term string) EdgeCompiler
GetEdgeCompiler return a compiler that will compile the term when the term is an edge label
type EdgeFuncResult ¶
type EdgeFuncResult int
const ( FollowEdgeResult EdgeFuncResult = iota SkipEdgeResult StopEdgeResult )
func FollowEdgesInEntity ¶
func FollowEdgesInEntity(edge *lpg.Edge) EdgeFuncResult
FollowEdgesInEntity follows only the document edges that do not cross entity boundaries
type EncodingIndex ¶
type EncodingIndex int
EncodingIndex determines the encoding name index
const ( UnknownEncodingIndex EncodingIndex = 0 MIMEEncodingIndex EncodingIndex = 1 IANAEncodingIndex EncodingIndex = 2 MIBEncodingIndex EncodingIndex = 3 )
Encoding indexes. If encoding name index is unknown, use UnknownEncodingIndex
type EntityInfo ¶
type EntityInfo struct {
// contains filtered or unexported fields
}
EntityInfo contains the entity information in the doc graph
func (EntityInfo) GetEntitySchema ¶
func (e EntityInfo) GetEntitySchema() string
func (EntityInfo) GetID ¶
func (e EntityInfo) GetID() []string
func (EntityInfo) GetRoot ¶
func (e EntityInfo) GetRoot() *lpg.Node
func (EntityInfo) GetValueType ¶
func (e EntityInfo) GetValueType() []string
type EntityInfoIndex ¶
type EntityInfoIndex struct {
// contains filtered or unexported fields
}
func GetEntityInfoIndex ¶
func GetEntityInfoIndex(g *lpg.Graph) EntityInfoIndex
GetEntityInfoIndex returns a fast-access entity info
func IndexEntityInfo ¶
func IndexEntityInfo(entityInfo map[*lpg.Node]EntityInfo) EntityInfoIndex
IndexEntityInfo returns a fast-access version of entity info
type ErrCannotDetermineEdgeLabel ¶
func (ErrCannotDetermineEdgeLabel) Error ¶
func (e ErrCannotDetermineEdgeLabel) Error() string
type ErrCannotDeterminePropertyName ¶
func (ErrCannotDeterminePropertyName) Error ¶
func (e ErrCannotDeterminePropertyName) Error() string
type ErrCannotFindAncestor ¶
func (ErrCannotFindAncestor) Error ¶
func (e ErrCannotFindAncestor) Error() string
type ErrCannotInstantiateSchemaNode ¶
func (ErrCannotInstantiateSchemaNode) Error ¶
func (e ErrCannotInstantiateSchemaNode) Error() string
type ErrCannotResolveLink ¶
type ErrCannotResolveLink LinkSpec
func (ErrCannotResolveLink) Error ¶
func (err ErrCannotResolveLink) Error() string
type ErrDataIngestion ¶
func (ErrDataIngestion) Error ¶
func (e ErrDataIngestion) Error() string
func (ErrDataIngestion) Unwrap ¶
func (e ErrDataIngestion) Unwrap() error
type ErrDuplicate ¶
type ErrDuplicate string
ErrDuplicate is used for duplicate errors
func (ErrDuplicate) Error ¶
func (e ErrDuplicate) Error() string
type ErrDuplicateAttributeID ¶
type ErrDuplicateAttributeID string
ErrDuplicateAttributeID is used to denote a duplicate attribute in a schema
func (ErrDuplicateAttributeID) Error ¶
func (e ErrDuplicateAttributeID) Error() string
type ErrInconsistentTypes ¶
ErrInconsistentTypes is returned if a node has multiple types that can interpret the value
func (ErrInconsistentTypes) Error ¶
func (e ErrInconsistentTypes) Error() string
type ErrInvalidEntityID ¶
type ErrInvalidEntityID struct {
Path NodePath
}
func (ErrInvalidEntityID) Error ¶
func (e ErrInvalidEntityID) Error() string
type ErrInvalidForeignKeys ¶
func (ErrInvalidForeignKeys) Error ¶
func (err ErrInvalidForeignKeys) Error() string
type ErrInvalidInput ¶
ErrInvalidInput is used for errors due to incorrect values, unexpected syntax, etc.
func (ErrInvalidInput) Error ¶
func (e ErrInvalidInput) Error() string
type ErrInvalidLinkSpec ¶
func (ErrInvalidLinkSpec) Error ¶
func (err ErrInvalidLinkSpec) Error() string
type ErrInvalidNSMapExpression ¶
type ErrInvalidNSMapExpression string
func (ErrInvalidNSMapExpression) Error ¶
func (e ErrInvalidNSMapExpression) Error() string
type ErrInvalidSchema ¶
type ErrInvalidSchema string
func (ErrInvalidSchema) Error ¶
func (e ErrInvalidSchema) Error() string
type ErrInvalidValidator ¶
ErrInvalidValidator is used to return validator compilation errors
func (ErrInvalidValidator) Error ¶
func (e ErrInvalidValidator) Error() string
func (ErrInvalidValidator) Unwrap ¶
func (e ErrInvalidValidator) Unwrap() error
type ErrInvalidValue ¶
func (ErrInvalidValue) Error ¶
func (e ErrInvalidValue) Error() string
type ErrInvalidValuesetSpec ¶
type ErrInvalidValuesetSpec struct {
Msg string
}
func (ErrInvalidValuesetSpec) Error ¶
func (e ErrInvalidValuesetSpec) Error() string
type ErrMultipleParentNodes ¶
type ErrMultipleParentNodes struct {
Of string
}
ErrMultipleParentNodes is used to denote multiple parentnodes detected during data ingestion
func (ErrMultipleParentNodes) Error ¶
func (e ErrMultipleParentNodes) Error() string
type ErrMultipleTargetsFound ¶
type ErrMultipleTargetsFound struct {
ID string
}
func (ErrMultipleTargetsFound) Error ¶
func (err ErrMultipleTargetsFound) Error() string
type ErrMultipleTypes ¶
type ErrMultipleTypes string
ErrMultipleTypes denotes multiple incompatible types declared for an attribute
func (ErrMultipleTypes) Error ¶
func (e ErrMultipleTypes) Error() string
type ErrNoParentNode ¶
type ErrNoParentNode struct {
Of string
}
ErrNoParentNode is used to denote no parent nodes for an ingested node
func (ErrNoParentNode) Error ¶
func (e ErrNoParentNode) Error() string
type ErrNotFound ¶
type ErrNotFound string
ErrNotFound is used for all not-found errors.
func (ErrNotFound) Error ¶
func (e ErrNotFound) Error() string
type ErrPathInstantiation ¶
func (ErrPathInstantiation) Error ¶
func (e ErrPathInstantiation) Error() string
type ErrSchemaValidation ¶
func (ErrSchemaValidation) Error ¶
func (e ErrSchemaValidation) Error() string
type ErrValidation ¶
ErrValidation is used to return validator errors
func (ErrValidation) Error ¶
func (e ErrValidation) Error() string
func (ErrValidation) Unwrap ¶
func (e ErrValidation) Unwrap() error
type ErrValidatorCompile ¶
ErrValidatorCompile is returned for validator compilation errors
func (ErrValidatorCompile) Error ¶
func (e ErrValidatorCompile) Error() string
func (ErrValidatorCompile) Unwrap ¶
func (e ErrValidatorCompile) Unwrap() error
type ErrValueset ¶
func (ErrValueset) Error ¶
func (e ErrValueset) Error() string
type ForeignKeyInfo ¶
type GraphBuilder ¶
type GraphBuilder struct {
// contains filtered or unexported fields
}
GraphBuilder contains the methods to ingest a graph
func NewGraphBuilder ¶
func NewGraphBuilder(g *lpg.Graph, options GraphBuilderOptions) GraphBuilder
NewGraphBuilder returns a new builder with an optional graph. If g is nil, a new graph is initialized
func (GraphBuilder) ArrayAsEdge ¶
func (GraphBuilder) ArrayAsNode ¶
func (GraphBuilder) CollectionAsEdge ¶
func (GraphBuilder) CollectionAsNode ¶
func (GraphBuilder) GetGraph ¶
func (gb GraphBuilder) GetGraph() *lpg.Graph
func (GraphBuilder) GetOptions ¶
func (gb GraphBuilder) GetOptions() GraphBuilderOptions
func (GraphBuilder) LinkNodesWithSpecs ¶
func (gb GraphBuilder) LinkNodesWithSpecs(ctx *Context, specs []*LinkSpec, eix EntityInfoIndex) error
func (GraphBuilder) NativeValueAsEdge ¶
func (GraphBuilder) NativeValueAsNode ¶
func (GraphBuilder) NativeValueAsProperty ¶
func (GraphBuilder) NewNode ¶
func (gb GraphBuilder) NewNode(schemaNode *lpg.Node) *lpg.Node
NewNode creates a new graph node as an instance of SchemaNode. Then it either merges schema properties into the new node, or creates an instanceOf edge to the schema node.
func (GraphBuilder) NewUniqueEdge ¶
func (gb GraphBuilder) NewUniqueEdge(fromNode, toNode *lpg.Node, label string, properties map[string]interface{}) *lpg.Edge
NewUniqueEdge create a new edge if one does not exist.
func (GraphBuilder) ObjectAsEdge ¶
func (gb GraphBuilder) ObjectAsEdge(schemaNode, parentNode *lpg.Node, types ...string) (*lpg.Edge, error)
ObjectAsEdge creates an object node as an edge using the following scheme:
parent --object--> _blankNode --...
func (GraphBuilder) ObjectAsNode ¶
func (gb GraphBuilder) ObjectAsNode(schemaNode, parentNode *lpg.Node, types ...string) (*lpg.Edge, *lpg.Node, error)
ObjectAsNode creates a new object node
func (GraphBuilder) PostIngest ¶
func (gb GraphBuilder) PostIngest(schemaRootNode, docRootNode *lpg.Node) error
PostIngest calls the post ingestion functions for properties that has one
func (GraphBuilder) PostIngestSchemaNode ¶
func (gb GraphBuilder) PostIngestSchemaNode(schemaRootNode, schemaNode, docRootNode *lpg.Node, nodeIDMap map[string][]*lpg.Node) error
PostIngestSchemaNode calls the post ingest functions for properties of the document nodes for the given schema node.
func (GraphBuilder) PostNodeIngest ¶
func (gp GraphBuilder) PostNodeIngest(schemaNode, docNode *lpg.Node) error
PostNodeIngest calls the post node ingestion functions for properties that has one
func (GraphBuilder) RawValueAsEdge ¶
func (gb GraphBuilder) RawValueAsEdge(schemaNode, parentDocumentNode *lpg.Node, value string, types ...string) (*lpg.Edge, error)
ValueAsEdge ingests a value using the following scheme: input: (name: value) output: --(label)-->(value:value, attributeName:name)
where label=attributeName (in this case "name") if edgeLabel is not specified in schema.
func (GraphBuilder) RawValueAsNode ¶
func (gb GraphBuilder) RawValueAsNode(schemaNode, parentDocumentNode *lpg.Node, value string, types ...string) (*lpg.Edge, *lpg.Node, error)
ValueAsNode creates a new value node. The new node has the given value and the types
func (GraphBuilder) RawValueAsProperty ¶
func (GraphBuilder) ValueAsEdge ¶
func (GraphBuilder) ValueAsNode ¶
func (GraphBuilder) ValueAsProperty ¶
func (gb GraphBuilder) ValueAsProperty(schemaNode *lpg.Node, graphPath []*lpg.Node, setValue func(*lpg.Node, string)) error
ValueAsProperty ingests a value as a property of an ancestor node. The ancestor
func (GraphBuilder) ValueSetAsEdge ¶
func (gb GraphBuilder) ValueSetAsEdge(node, schemaNode, parentDocumentNode *lpg.Node)
ValueSetAsEdge can be called to notify the graph builder that a value is set that was ingested as edge
func (GraphBuilder) ValueSetAsNode ¶
func (gb GraphBuilder) ValueSetAsNode(node, schemaNode, parentDocumentNode *lpg.Node)
ValueSetAsNode can be called to notif the graph builder that a node value is set
func (GraphBuilder) ValueSetAsProperty ¶
func (gb GraphBuilder) ValueSetAsProperty(schemaNode *lpg.Node, graphPath []*lpg.Node, value string)
ValueSetAsProperty can be called to notify the graph builder that a node value is set
type GraphBuilderOptions ¶
type GraphBuilderOptions struct { // If true, schema node properties are embedded into document // nodes. If false, schema nodes are preserved as separate nodes, // with an instanceOf edge between the document node to the schema // node. EmbedSchemaNodes bool // If OnlySchemaAttributes is true, only ingest data points if there is a schema for it. // If OnlySchemaAttributes is false, ingest whether or not there is a schema for it. OnlySchemaAttributes bool }
type HasNativeValue ¶
type HasNativeValue interface {
GetNativeValue() (interface{}, bool)
}
HasNativeValue is implemented by parsed doc nodes if the node knows its native value
type Ingester ¶
type Ingester struct { Schema *Layer // contains filtered or unexported fields }
func (*Ingester) GetPostIngestSchemaNodes ¶
func (*Ingester) Ingest ¶
func (ing *Ingester) Ingest(builder GraphBuilder, root ParsedDocNode) (*lpg.Node, error)
type Interner ¶
Interner interface is used to keep a string table to reduce memory footprint by eliminated repeated keys
type JSONMarshaler ¶
JSONMarshaler marshals/unmarshals a graph
func NewJSONMarshaler ¶
func NewJSONMarshaler(interner Interner) *JSONMarshaler
type LDMarshaler ¶
type LDMarshaler struct { // If set, generates node identifiers from the given node. It should // be able to generate blank node IDs if the node is to be // represented as an RDF blank node, or if the node does not have an // ID. // // If not set, the default generator function uses the string node // id, or _b:<n> if the node does not have an id. NodeIDGeneratorFunc func(*lpg.Node) string // If set, generates edge labels for the given edge. If it is not set, // the default is to use the edge label. If edge does not have a // label, EdgeLabelGeneratorFunc func(*lpg.Edge) string }
LDMarshaler renders a graph in JSON-LD flattened format
func (*LDMarshaler) Marshal ¶
func (rd *LDMarshaler) Marshal(input *lpg.Graph) interface{}
type Layer ¶
A Layer is either a schema or an overlay. It keeps the definition of a layer as a directed labeled property graph.
The root node of the layer keeps layer identifying information. The root node is connected to the schema node which contains the actual object defined by the layer.
func LayersFromGraph ¶
LayersFromGraph returns the layers from an existing graph. All Schema and Overlay nodes are returned as layers.
func NewLayerInGraph ¶
NewLayerInGraph creates a new layer in the given graph by creating a layerinfo root node for the layer. The graph may contain many other layers
func ReadLayerFromFile ¶
func UnmarshalLayer ¶
UnmarshalLayer unmarshals a schema ar overlay
func UnmarshalLayerFromSlice ¶
func (*Layer) Clone ¶
Clone returns a copy of the layer in a new graph. If the graph contains other layers, they are not copied.
func (*Layer) CloneInto ¶
CloneInto clones the layer into the targetgraph. If the source graph contains other layers, they are not copied.
func (*Layer) Compose ¶
Compose schema layers. Directly modifies the source and the target. The source must be an overlay.
func (*Layer) FindAttributeByID ¶
FindAttributeByID returns the attribute and the path to it
func (*Layer) FindFirstAttribute ¶
FindFirstAttribute returns the first attribute for which the predicate holds
func (*Layer) ForEachAttribute ¶
ForEachAttribute calls f with each attribute node, depth first. If f returns false, iteration stops
func (*Layer) ForEachAttributeOrdered ¶
ForEachAttributeOrdered calls f with each attribute node, depth first and in order. If f returns false, iteration stops
func (*Layer) GetAttributeByID ¶
GetAttributeByID returns the attribute node by its ID.
func (*Layer) GetAttributePath ¶
GetAttributePath returns the path to the given attribute node
func (*Layer) GetAttributesByID ¶
GetAttributesByID returns attribute nodes by ID
func (*Layer) GetEncoding ¶
GetEncoding returns the encoding that should be used to ingest/export data using this layer. The encoding information is taken from the schema root node characterEncoding annotation. If missing, the default encoding is used, which does not perform any character translation
func (*Layer) GetEntityIDNodes ¶
GetEntityIDNodes returns the entity id attribute IDs from the layer root node
func (*Layer) GetLayerRootNode ¶
GetLayerRootNode returns the root node of the schema
func (*Layer) GetLayerType ¶
GetLayerType returns the layer type, SchemaTerm or OverlayTerm.
func (*Layer) GetLinkSpecs ¶
GetLinkSpecs retrieves link specs for the layer
func (*Layer) GetOverlayAttributes ¶
Returns the overlay attribute nodes if there are any
func (*Layer) GetSchemaRootNode ¶
GetSchemaRootNode returns the root node of the object defined by the schema
func (*Layer) GetValueType ¶
GetValueType returns the value of the valueType field from the layer information node. This is the type of the entity defined by the schema
func (*Layer) SetLayerType ¶
SetLayerType sets if the layer is a schema or an overlay
func (*Layer) SetValueType ¶
SetValueType sets the value types of the layer
type LinkSpec ¶
type LinkSpec struct { SchemaNode *lpg.Node // The target schema/entity reference, populated from the // `reference` property of the node TargetEntity string // The foreign key field(s) FK []string // The label of the link Label string // If true, the link is from this entity to the target. If false, // the link is from the target to this. Forward bool // If the schema node is not a reference node, then this is the node // that should receive the link LinkNode string // If true, the reference can have more than one links Multi bool // IngestAs node or edge IngestAs string // Initialized when linkSpec is initialized ParentSchemaNode *lpg.Node }
LinkSpec contains the link field information
func GetLinkSpec ¶
GetLinkSpec returns a link spec from the node if there is one. The node is a schema node
func (*LinkSpec) FindReference ¶
FindReference finds the root nodes with entitySchema=spec.Schema, with entityId=fk
func (*LinkSpec) GetForeignKeys ¶
func (spec *LinkSpec) GetForeignKeys(entityRoot *lpg.Node) ([]ForeignKeyInfo, error)
GetForeignKeys returns the foreign keys for the link spec given the entity root node
type NodeCompiler ¶
type NodeCompiler interface { // CompileNode gets a node and compiles the associated term on that // node. It should store the compiled state into node.Compiled with // the an opaque key CompileNode(*Layer, *lpg.Node) error }
NodeCompiler interface represents term compilation algorithm when the term is a node.
During schema compilation, if a node is found to be a semantic annotation node (i.e. not an attribute node), and if the term metadata for the node label implements NodeCompiler, this function is called to compile the node.
func GetNodeCompiler ¶
func GetNodeCompiler(term string) NodeCompiler
GetNodeCompiler return a compiler that will compile the term when the term is a node label
type NodePath ¶
type NodePath []string
NodePath contains the name components identifying a node. For JSON, this is the components of a JSON pointer
func (NodePath) AppendString ¶
type NodeValidator ¶
A NodeValidator is used to validate document nodes based on their schema. The ValidateNode function is called with the document node that needs to be validated, and the associated schema node.
type NodeValueAccessor ¶
type NodeValueAccessor interface { GetNodeValue(*lpg.Node) (interface{}, error) SetNodeValue(interface{}, *lpg.Node) error }
NodeValueAccessor can optionally be implemented by ValueAccessors to get/set node values directly
type ParsedDocNode ¶
type PostIngest ¶
type PostIngest interface {
ProcessNodePostDocIngest(schemaRootNode, schemaNode *lpg.Node, term *PropertyValue, docNode *lpg.Node) error
}
PostIngest is called after the ingestion of a document.
type PostNodeIngest ¶
type PostNodeIngest interface {
ProcessNodePostIngest(term *PropertyValue, docNode, layerNode *lpg.Node) error
}
PostNodeIngest is called after the ingestion of a node. If the node is a container (object or array), this is called after all children of the node are ingested.
type PropertyContainer ¶
type PropertyContainer interface {
GetProperties() map[string]*PropertyValue
}
PropertyContainer is an object that contains properties. Node and Edge are property containers
type PropertyValue ¶
type PropertyValue struct {
// contains filtered or unexported fields
}
PropertyValue can be a string or []string. It is an immutable value object
func AsPropertyValue ¶
func AsPropertyValue(in interface{}, exists bool) *PropertyValue
func ComposeProperty ¶
func ComposeProperty(context *Context, key string, targetValue, sourceValue *PropertyValue) (*PropertyValue, error)
ComposeProperty composes targetValue and sourceValue for key
func GetEntityIDFields ¶
func GetEntityIDFields(node *lpg.Node) *PropertyValue
GetEntityIDFields returns the value of the entity ID fields from a document node.
func GetNodeOrSchemaProperty ¶
func GetNodeOrSchemaProperty(node *lpg.Node, key string) (*PropertyValue, bool)
GetNodeOrSchemaProperty gets the node property with the key from the node, or from the schema nodes it is attached to
func IntPropertyValue ¶
func IntPropertyValue(term string, i int) *PropertyValue
IntPropertyValue converts the int value to string, and returns a string value
func ListAppend ¶
func ListAppend(v1, v2 *PropertyValue) *PropertyValue
ListAppend appends v2 and v1
func SetUnion ¶
func SetUnion(v1, v2 *PropertyValue) *PropertyValue
SetUnion computes the set union of properties v1 and v2
func StringPropertyValue ¶
func StringPropertyValue(term, s string) *PropertyValue
StringPropertyValue creates a string value
func StringSlicePropertyValue ¶
func StringSlicePropertyValue(term string, s []string) *PropertyValue
StringSlicePropertyValue creates a []string value. If s is nil, it creates an empty slice
func (*PropertyValue) AsInt ¶
func (p *PropertyValue) AsInt() int
AsInt attempts to return the underlying string value as integer
func (*PropertyValue) AsInterfaceSlice ¶
func (p *PropertyValue) AsInterfaceSlice() []interface{}
AsInterfaceSlice returns an interface slice of the underlying value if it is a []string.
func (*PropertyValue) AsString ¶
func (p *PropertyValue) AsString() string
AsString returns the value as string
func (*PropertyValue) AsStringSlice ¶
func (p *PropertyValue) AsStringSlice() []string
AsStringSlice returns the value as string slice. If the underlying value is not a string slice, returns nil
func (*PropertyValue) Clone ¶
func (p *PropertyValue) Clone() *PropertyValue
func (*PropertyValue) Equal ¶
func (p *PropertyValue) Equal(v *PropertyValue) bool
Equal compares two property values, and returns true if they are equal
func (PropertyValue) GetNativeValue ¶
func (p PropertyValue) GetNativeValue() interface{}
GetNativeValue is used bythe expression evaluators to access the native value of the property
func (*PropertyValue) GetSem ¶
func (pv *PropertyValue) GetSem() *TermSemantics
func (*PropertyValue) GetTerm ¶
func (pv *PropertyValue) GetTerm() string
func (*PropertyValue) Has ¶
func (p *PropertyValue) Has(s string) bool
Has checks if p has the given string or is equal to it
func (*PropertyValue) IsEqual ¶
func (p *PropertyValue) IsEqual(q *PropertyValue) bool
IsEqual tests if two values are equal
func (*PropertyValue) IsInt ¶
func (p *PropertyValue) IsInt() bool
Returns true if the underlying value is a string, and that string can be converted to int
func (*PropertyValue) IsString ¶
func (p *PropertyValue) IsString() bool
IsString returns true if the underlying value is a string
func (*PropertyValue) IsStringSlice ¶
func (p *PropertyValue) IsStringSlice() bool
IsStringSlice returns true if the underlying value is a string slice
func (PropertyValue) MarshalJSON ¶
func (p PropertyValue) MarshalJSON() ([]byte, error)
func (PropertyValue) MarshalYAML ¶
func (p PropertyValue) MarshalYAML() (interface{}, error)
func (*PropertyValue) MustStringSlice ¶
func (p *PropertyValue) MustStringSlice() []string
MustStringSlice returns the value as a string slice. If the underlying value is not a string slice, returns a string slice containing one element. If p is nil, returns nil
func (*PropertyValue) Slice ¶
func (p *PropertyValue) Slice() []string
Slice returns the property value as a slice. If the property value is a string, returns a slice containing that value. If the property value is nil, returns an empty slice
func (PropertyValue) String ¶
func (p PropertyValue) String() string
type SchemaLoader ¶
SchemaLoader interface defines the LoadSchema method that loads schemas by reference
type SchemaLoaderFunc ¶
SchemaLoaderFunc is the function type that load schemas. It also implements SchemaLoader interface
func (SchemaLoaderFunc) LoadSchema ¶
func (s SchemaLoaderFunc) LoadSchema(ref string) (*Layer, error)
type StringInterner ¶
type StringInterner struct {
// contains filtered or unexported fields
}
StringInterner is used to intern strings so multiple identical copies of strings are minimized
func (StringInterner) Intern ¶
func (s StringInterner) Intern(key string) string
Intern a string and return the corresponding interned string
type TermCompiler ¶
type TermCompiler interface { // CompileTerm gets a node or edge, the term and its value, and // compiles it. It can store compilation data in the compiled data // map. CompileTerm(CompilablePropertyContainer, string, *PropertyValue) error }
TermCompiler interface represents term compilation algorithm. This is used to compile terms stored as node/edge properties. If the term metadata implements TermCompiler, this method is called, and the result is stored in the Compiled map of the node/edge with the term as the key.
func GetTermCompiler ¶
func GetTermCompiler(term string) TermCompiler
GetTermCompiler return a compiler that will compile the term when the term is a node/edge property
type TermMarshaler ¶
type TermMarshaler interface { // Unmarshal a flattened json-ld object. UnmarshalLd(target *Layer, key string, value interface{}, node *LDNode, allNodes map[string]*LDNode, interner Interner) error // Marshal a property of a node as expanded json-ld MarshalLd(source *Layer, sourceNode *lpg.Node, key string) (interface{}, error) UnmarshalJSON(target *Layer, key string, value interface{}, node *lpg.Node, interner Interner) error }
TermMarshaler interface defines JSON and JSONLD unmarshalers for a custom schema extension
func GetTermMarshaler ¶
func GetTermMarshaler(term string) TermMarshaler
GetTermMarshaler returns the custom marshaler for the term. If there is none, returns the default marshaler
type TermSemantics ¶
type TermSemantics struct { // The term Term string Namespace string LName string Aliases []string // If true, the term value is an @id (IRI). In JSON-LD, the values for // this term will be marshalled as @id IsID bool // If true, the term is a list. In JSON-LD, its elements will be // marshaled under @list IsList bool Composition CompositionType Metadata interface{} }
TermSemantics is used to describe how a term operates within the layered schemas framework.
func GetTermInfo ¶
func GetTermInfo(term string) *TermSemantics
func (TermSemantics) Compose ¶
func (t TermSemantics) Compose(target, src *PropertyValue) (*PropertyValue, error)
type ValueAccessor ¶
type ValueAccessor interface { // GetNativeValue returns the native value based on input GetNativeValue(string, *lpg.Node) (interface{}, error) FormatNativeValue(newValue, oldValue interface{}, schNode *lpg.Node) (string, error) }
A ValueAccessor gets node values in native type, and sets node values
func GetNodeValueAccessor ¶
func GetNodeValueAccessor(node *lpg.Node) (ValueAccessor, error)
GetNodeValueAccessor returns the value accessor for the node based on the node value type. If there is none, returns nil
func GetValueAccessor ¶
func GetValueAccessor(term string) ValueAccessor
GetValueAccessor returns the value accessor for the term. If the term has none, returns nil
type ValueValidator ¶
A ValueValidator is used to validate a value based on a schema. The ValidateValue function is called with the value that needs to be validated, and the associated schema node. If the node does not exist, the value is nil
type ValuesetInfo ¶
type ValuesetInfo struct { // If the valueset lookup requires a single value, the attribute id // of the source node. Otherwise, the root node containing all the // required values. If this is empty, then the entity root // node is the context node ContextID string ContextExpr opencypher.Evaluatable // Optional lookup table IDs. If omitted, all compatible tables are // looked up TableIDs []string // Ordered list of valueset keys. The request to the valueset // function will use these as the request keys RequestKeys []string // Ordered list of attribute ids containing valueset request // values. The elements of this match the keys array RequestValues []string // Request expressions RequestExprs []opencypher.Evaluatable // The keys of the valueset result ResultKeys []string // The attribute ids of the nodes under this node to receive values ResultValues []string // If empty, will be set to the ContextID. The results will be added under this node. ResultContext string // The schemanode containing the valueset info SchemaNode *lpg.Node // contains filtered or unexported fields }
ValuesetInfo describes value set information for a schema node.
A schema node containing valueset information requests the use of a dictionary or valueset to manipulate the graph. The results of valueset lookup can be placed under new nodes of the schema node.
The valueset or dictionary lookup is envisioned as an external service. This service is called with the list of valueset ids, and a set of key:value pairs as the request. The response is another set of key:value pairs. Valueset processing adds the response to the graph.
The valueset context node specifies a node that is either the current node or one of its ancestors. All the nodes for the valueset lookup are found under this context, and valueset lookup results are added under this context node.
The valueset info may specify one or mode valuesets to lookup (TableIDs). If none specified, all compatible valuesets should be looked up.
func ValuesetInfoFromNode ¶
func ValuesetInfoFromNode(layer *Layer, node *lpg.Node) (*ValuesetInfo, error)
ValueSetInfoFromNode parses the valueset information from a node. Returns nil if the node does not have valueset info
func (*ValuesetInfo) ApplyValuesetResponse ¶
func (vsi *ValuesetInfo) ApplyValuesetResponse(ctx *Context, builder GraphBuilder, layer *Layer, contextDocumentNode, contextSchemaNode, resultContextSchemaNode *lpg.Node, result ValuesetLookupResponse) error
func (*ValuesetInfo) GetContextNode ¶
GetContextNode returns the context node for the given document node. The context node must be the node itself, or an ancestor of the node
func (*ValuesetInfo) GetDocNodes ¶
func (vsi *ValuesetInfo) GetDocNodes(g *lpg.Graph) []*lpg.Node
GetDocNodes returns the document nodes that are instance of the vsi schema node
func (*ValuesetInfo) GetRequest ¶
func (vsi *ValuesetInfo) GetRequest(ctx *Context, contextDocumentNode, vsiDocumentNode *lpg.Node) (map[string]string, error)
GetRequest builds a valueset service request in the form of key:value pairs. All the request values are expected to be under the contextDocumentNode.
If ValuesetInfo contains no RequestValues, then the vsiDocumentNode is used as the request value. If there are RequestKeys specified, there must be only one, and that is used as the key. Otherwise, the request is prepared with empty key.
vsiDocumentNode can be nil
If ValuesetInfo contains RequestValues, the request values
type ValuesetLookupRequest ¶
ValuesetLookupRequest specifies an optional list of lookup tables and key-value pairs to lookup. If the lookup tables list is empty, the valueset lookup should check all compatible tables. The key-values may contain a single value with empty key for simple dictionay lookups
type ValuesetLookupResponse ¶
ValuesetLookupResponse returns the key-value pairs that should be inserted into the graph
type ValuesetProcessor ¶
type ValuesetProcessor struct {
// contains filtered or unexported fields
}
func NewValuesetProcessor ¶
func NewValuesetProcessor(layer *Layer, lookupFunc func(*Context, ValuesetLookupRequest) (ValuesetLookupResponse, error), tables []string) (ValuesetProcessor, error)
func (*ValuesetProcessor) Process ¶
func (prc *ValuesetProcessor) Process(ctx *Context, builder GraphBuilder, vsiDocNode, contextSchemaNode, resultContextSchemaNode *lpg.Node, vsi *ValuesetInfo) error
Process processes the value set of the given context document node and the schema node containing the vsi
func (*ValuesetProcessor) ProcessByContextNode ¶
func (prc *ValuesetProcessor) ProcessByContextNode(ctx *Context, builder GraphBuilder, contextDocNode, contextSchemaNode, resultContextSchemaNode, vsiDocNode *lpg.Node, vsi *ValuesetInfo) error
ProcessByContextNode processes the value set of the given context node and the schema node containing the vsi
func (*ValuesetProcessor) ProcessGraph ¶
func (prc *ValuesetProcessor) ProcessGraph(ctx *Context, builder GraphBuilder) error
func (*ValuesetProcessor) ProcessGraphValueset ¶
func (prc *ValuesetProcessor) ProcessGraphValueset(ctx *Context, builder GraphBuilder, vsi *ValuesetInfo) error
Source Files ¶
- compile.go
- compose.go
- context.go
- copy.go
- docgraph.go
- encoding.go
- equal.go
- errors.go
- evalcontext.go
- graph.go
- graphbuilder.go
- graphjson.go
- hash.go
- ingestdoc.go
- intern.go
- labels.go
- layer.go
- ld.go
- ldmarshaler.go
- link.go
- logger.go
- marshallayer.go
- path.go
- propertyvalue.go
- semcompilation.go
- semcomposition.go
- semingestion.go
- semtermmarshal.go
- semvalidation.go
- semvalue.go
- set.go
- setvalue.go
- slice.go
- terms.go
- termsemantics.go
- testutil.go
- valueset.go