Documentation ¶
Overview ¶
Package neo4j is the graph storage driver using Neo4J database.
The input graph node IDs are stored in `neo4j_id` property. All other properties and labels are stored verbatim.
Index ¶
- Constants
- Variables
- func AddLinksToThisEntity(ctx *ls.Context, tx neo4j.ExplicitTransaction, session *Session, config Config, ...) error
- func BuildNodePropertiesAfterLoad(node *lpg.Node, input map[string]interface{}, cfg Config)
- func Close(closer CloseWithContext, ctx context.Context, resourceName string)
- func Compact(g *lpg.Graph) (*lpg.Graph, error)
- func CreateEdgesBatch(ctx *ls.Context, tx neo4j.ExplicitTransaction, session *Session, ...) error
- func CreateEdgesUnwind(ctx *ls.Context, session *Session, edges []*lpg.Edge, dbGraph *DBGraph, ...) func(neo4j.ExplicitTransaction) error
- func CreateNodesBatch(ctx *ls.Context, tx neo4j.ExplicitTransaction, createNodes []*lpg.Node, ...) error
- func CreateNodesUnwind(ctx *ls.Context, nodes []*lpg.Node, dbGraph *DBGraph, cfg Config) func(neo4j.ExplicitTransaction) error
- func Execute(ctx *ls.Context, tx neo4j.ExplicitTransaction, cfg Config, ...) error
- func Insert(ctx *ls.Context, session *Session, tx neo4j.ExplicitTransaction, ...) ([]string, error)
- func LinkEntitiesByForeignKeys(ctx *ls.Context, tx neo4j.ExplicitTransaction, session *Session, config Config, ...) error
- func LinkMergedEntities(ctx *ls.Context, tx neo4j.ExplicitTransaction, cfg Config, delta []Delta, ...) error
- func LinkNodesForNewEntity(ctx *ls.Context, tx neo4j.ExplicitTransaction, session *Session, config Config, ...) error
- func Neo4jValueToNativeValue(val interface{}) interface{}
- func NodesetDiff(oldNodeset, newNodeset Nodeset) (rootOp rootOpType, insertions []NodesetData, deletions []NodesetData, ...)
- func ParseNodesetData(cfg Config, input NodesetInput) (map[string]Nodeset, error)
- func SetNodeValueAfterLoad(cfg Config, node *lpg.Node, input map[string]interface{}) interface{}
- func WriteableType(value any) bool
- type CloseWithContext
- type Config
- func (cfg *Config) Expand(short string) string
- func (cfg Config) GetNeo4jPropertyValue(expandedPropertyKey string, val string) (interface{}, error)
- func (cfg Config) IsMergeEntity(name string) bool
- func (cfg Config) MakeLabels(types []string) string
- func (cfg Config) MakeProperties(x withProperty, txVars map[string]any) string
- func (cfg Config) MakePropertiesObj(x withProperty) map[string]any
- func (cfg Config) Shorten(fullName string) string
- func (cfg Config) ShortenProperties(props map[string]any) map[string]any
- type CreateEdgeDelta
- type CreateEntity
- type CreateNodeDelta
- type DBGraph
- type DeleteEntity
- type Delta
- type DeltaQuery
- type Driver
- type EntityMergeAction
- type ErrMultipleFound
- type JobQueue
- type Neo4jCache
- type Nodeset
- type NodesetData
- type NodesetInput
- type Session
- func (s *Session) Close(ctx context.Context)
- func (s *Session) CollectEntityDBIds(ctx *ls.Context, tx neo4j.ExplicitTransaction, config Config, grph *lpg.Graph, ...) (entityRootNodes []*lpg.Node, entityRootDBIds []string, ...)
- func (s *Session) LoadDBGraph(ctx *ls.Context, tx neo4j.ExplicitTransaction, memGraph *lpg.Graph, ...) (*DBGraph, error)
- func (s *Session) LoadEntityNodes(ctx *ls.Context, tx neo4j.ExplicitTransaction, grph *lpg.Graph, ...) error
- func (s *Session) LoadEntityNodesByEntityId(ctx *ls.Context, tx neo4j.ExplicitTransaction, grph *lpg.Graph, ...) error
- func (s *Session) Logf(format string, a ...interface{})
- type Trie
- type TrieNode
- type UpdateEdgeDelta
- type UpdateNodeDelta
Constants ¶
const (
PropNodeID = "neo4j_id"
)
Variables ¶
var DEFAULT_BATCH_SIZE = 1000
Functions ¶
func AddLinksToThisEntity ¶
func AddLinksToThisEntity(ctx *ls.Context, tx neo4j.ExplicitTransaction, session *Session, config Config, entityRoot *lpg.Node, nodeMap map[*lpg.Node]string) error
ID is entity id of entity root
func BuildNodePropertiesAfterLoad ¶
BuildNodePropertiesAfterLoad is during the loading of nodes from database. This function sets all node properties to PropertyValues, excluding properties that are assigned to NodeValueTerm
func Compact ¶
func Compact(g *lpg.Graph) (*lpg.Graph, error)
Compact a graph for storing in the database. This will remove all nodes that do not have an id, and collapse all value nodes to properties
func CreateEdgesBatch ¶
func CreateEdgesUnwind ¶
func CreateNodesBatch ¶
func CreateNodesUnwind ¶
func Execute ¶
func Execute(ctx *ls.Context, tx neo4j.ExplicitTransaction, cfg Config, oldNodeset, newNodeset Nodeset, rootOp rootOpType, inserts, updates, deletes []NodesetData) error
func Insert ¶
func Insert(ctx *ls.Context, session *Session, tx neo4j.ExplicitTransaction, grph *lpg.Graph, selectEntity func(*lpg.Node) bool, config Config, batch int) ([]string, error)
Insert creates or adds to a graph on a database; does not check existing nodes
func LinkMergedEntities ¶
func LinkMergedEntities(ctx *ls.Context, tx neo4j.ExplicitTransaction, cfg Config, delta []Delta, nodeMap map[*lpg.Node]string) error
LinkMergedEntities will find the new entities from the delta and link them
func LinkNodesForNewEntity ¶
func Neo4jValueToNativeValue ¶
func Neo4jValueToNativeValue(val interface{}) interface{}
neo4jValueToNativeValue converts a neo4j value to a native go value
func NodesetDiff ¶
func NodesetDiff(oldNodeset, newNodeset Nodeset) (rootOp rootOpType, insertions []NodesetData, deletions []NodesetData, updates []NodesetData)
oldNodeset is nodeset pulled from DB
func ParseNodesetData ¶
func ParseNodesetData(cfg Config, input NodesetInput) (map[string]Nodeset, error)
func SetNodeValueAfterLoad ¶
Called before SetNodeValue, input contains neo4j native values
Types ¶
type CloseWithContext ¶
type Config ¶
type Config struct { TermMappings map[string]string `json:"termMappings" yaml:"termMappings"` NamespaceMappings map[string]string `json:"namespaceMappings" yaml:"namespaceMappings"` PropertyTypes map[string]string `json:"propertyTypes" yaml:"propertyTypes"` EntityMergeActions map[string]EntityMergeAction `json:"entityMergeActions" yaml:"entityMergeActions"` // contains filtered or unexported fields }
func (Config) GetNeo4jPropertyValue ¶
func (cfg Config) GetNeo4jPropertyValue(expandedPropertyKey string, val string) (interface{}, error)
GetNativePropertyValue is called during building properties for save and when the expanded property key exists in the config.
func (Config) IsMergeEntity ¶
IsMergeEntity returns if the entity has a merge config
func (Config) MakeLabels ¶
func (Config) MakeProperties ¶
func (Config) MakePropertiesObj ¶
type CreateEdgeDelta ¶
type CreateEdgeDelta struct { DBEdge *lpg.Edge // contains filtered or unexported fields }
func (CreateEdgeDelta) Run ¶
func (ce CreateEdgeDelta) Run(ctx *ls.Context, tx neo4j.ExplicitTransaction, session *Session, dbNodeIds map[*lpg.Node]string, dbEdgeIds map[*lpg.Edge]string, c Config) error
func (CreateEdgeDelta) WriteQuery ¶
func (ce CreateEdgeDelta) WriteQuery(session *Session, dbNodeIds map[*lpg.Node]string, dbEdgeIds map[*lpg.Edge]string, c Config) DeltaQuery
type CreateEntity ¶
type CreateEntity struct { Config *lpg.Graph *lpg.Node }
func (*CreateEntity) Queue ¶
func (c *CreateEntity) Queue(ctx *ls.Context, tx neo4j.ExplicitTransaction, q *JobQueue) error
CreateEntity.Queue will find all connected nodes to the given entity and create, stopping at different entity boundaries
type CreateNodeDelta ¶
type CreateNodeDelta struct { DBNode *lpg.Node MemNode *lpg.Node }
func (CreateNodeDelta) Run ¶
func (cn CreateNodeDelta) Run(ctx *ls.Context, tx neo4j.ExplicitTransaction, session *Session, dbNodeIds map[*lpg.Node]string, dbEdgeIds map[*lpg.Edge]string, c Config) error
func (CreateNodeDelta) WriteQuery ¶
func (cn CreateNodeDelta) WriteQuery(session *Session, dbNodeIds map[*lpg.Node]string, dbEdgeIds map[*lpg.Edge]string, c Config) DeltaQuery
type DBGraph ¶
type DBGraph struct { G *lpg.Graph NodeIds map[*lpg.Node]string Nodes map[string]*lpg.Node EdgeIds map[*lpg.Edge]string Edges map[string]*lpg.Edge }
func NewDBGraph ¶
func NewDBGraph(g *lpg.Graph) *DBGraph
type DeleteEntity ¶
type DeleteEntity struct { Config *lpg.Graph // contains filtered or unexported fields }
type Delta ¶
type DeltaQuery ¶
func (DeltaQuery) String ¶
func (d DeltaQuery) String() string
type Driver ¶
type Driver struct { // ID(objectName)=id. IDEqValueFunc func(objectName, id string) string // ID(objectName)=varname. IDEqVarFunc func(objectName, varname string) string // ID(objectName) IDFunc func(objectName string) string // IDValue returns the actual ID value as a string or int64 IDValue func(string) interface{} // contains filtered or unexported fields }
type EntityMergeAction ¶
type EntityMergeAction struct { Merge *bool `json:"merge" yaml:"merge"` Create *bool `json:"create" yaml:"create"` }
func (EntityMergeAction) GetCreate ¶
func (e EntityMergeAction) GetCreate() bool
func (EntityMergeAction) GetMerge ¶
func (e EntityMergeAction) GetMerge() bool
type ErrMultipleFound ¶
type ErrMultipleFound string
func (ErrMultipleFound) Error ¶
func (e ErrMultipleFound) Error() string
type Neo4jCache ¶
type Neo4jCache struct {
// contains filtered or unexported fields
}
type Nodeset ¶
type Nodeset struct { ID string Labels []string Properties map[string]interface{} // Data[x] gives NodesetData with Nodeset.ID = x Data map[string]NodesetData }
func LoadNodeset ¶
type NodesetData ¶
type NodesetInput ¶
type Session ¶
type Session struct { neo4j.SessionWithContext *Driver }
func (*Session) CollectEntityDBIds ¶
func (s *Session) CollectEntityDBIds(ctx *ls.Context, tx neo4j.ExplicitTransaction, config Config, grph *lpg.Graph, cache *Neo4jCache) (entityRootNodes []*lpg.Node, entityRootDBIds []string, entityInfo map[*lpg.Node]ls.EntityInfo, err error)
func (*Session) LoadDBGraph ¶
func (s *Session) LoadDBGraph(ctx *ls.Context, tx neo4j.ExplicitTransaction, memGraph *lpg.Graph, config Config, cache *Neo4jCache) (*DBGraph, error)
LoadDBGraph loads a graph from the DB. The entity root nodes are matched based on the config entityMergeActions. If there is an entityMergeAction defined in the config for an entity, then this function will look up for a node that contains that entity name. If not, it will look for exact label match.
For instance, if there is entityMergeAction defined for X, then a memory node :X:Y will be looked up as :X. If X does not have entityMergeAction, then a memory node :X:Y will look for :X:Y
func (*Session) LoadEntityNodes ¶
func (*Session) LoadEntityNodesByEntityId ¶
type Trie ¶
type Trie struct {
// contains filtered or unexported fields
}
Trie represents a trie and has a pointer to the root node
func InitNamespaceTrie ¶
type TrieNode ¶
type TrieNode struct {
// contains filtered or unexported fields
}
Node represents each node in the trie
type UpdateEdgeDelta ¶
type UpdateEdgeDelta struct {
// contains filtered or unexported fields
}
func (UpdateEdgeDelta) Run ¶
func (ue UpdateEdgeDelta) Run(ctx *ls.Context, tx neo4j.ExplicitTransaction, session *Session, dbNodeIds map[*lpg.Node]string, dbEdgeIds map[*lpg.Edge]string, c Config) error
func (UpdateEdgeDelta) WriteQuery ¶
func (ue UpdateEdgeDelta) WriteQuery(session *Session, dbNodeIds map[*lpg.Node]string, dbEdgeIds map[*lpg.Edge]string, c Config) DeltaQuery
type UpdateNodeDelta ¶
type UpdateNodeDelta struct {
// contains filtered or unexported fields
}
func (UpdateNodeDelta) Run ¶
func (un UpdateNodeDelta) Run(ctx *ls.Context, tx neo4j.ExplicitTransaction, session *Session, dbNodeIds map[*lpg.Node]string, dbEdgeIds map[*lpg.Edge]string, c Config) error
func (UpdateNodeDelta) WriteQuery ¶
func (un UpdateNodeDelta) WriteQuery(session *Session, dbNodeIds map[*lpg.Node]string, dbEdgeIds map[*lpg.Edge]string, c Config) DeltaQuery