You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: internal/knowledge/query_graph.go
+25-13Lines changed: 25 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -8,28 +8,30 @@ import (
8
8
"github.com/clems4ever/go-graphkb/internal/utils"
9
9
)
10
10
11
+
// ErrVariableNotFound error thrown when a variable does not exist
11
12
varErrVariableNotFound=errors.New("Unable to find variable")
12
13
13
-
// QueryNode represent a node and its constraints
14
-
typeQueryNodestruct {
15
-
Labels []string
16
-
// Constraint expressions
17
-
ConstraintsAndOrExpression
18
-
}
19
-
14
+
// RelationDirection the direction of a relation
20
15
typeRelationDirectionint
21
16
22
17
const (
23
18
// Left relation
24
19
LeftRelationDirection=iota
25
20
// Right relation
26
21
RightRelationDirection=iota
27
-
// There is a relation but we don't know in which direction
22
+
// Either there is a relation but we don't know in which direction
28
23
EitherRelationDirection=iota
29
-
// There is a relation in both directions
24
+
// Both there is a relation in both directions
30
25
BothRelationDirection=iota
31
26
)
32
27
28
+
// QueryNode represent a node and its constraints
29
+
typeQueryNodestruct {
30
+
Labels []string
31
+
// Constraint expressions
32
+
ConstraintsAndOrExpression
33
+
}
34
+
33
35
// QueryRelation represent a relation and its constraints
34
36
typeQueryRelationstruct {
35
37
Labels []string
@@ -41,25 +43,31 @@ type QueryRelation struct {
41
43
DirectionRelationDirection
42
44
}
43
45
46
+
// VariableType represent the type of a variable in the cypher query.
44
47
typeVariableTypeint
45
48
46
49
const (
47
-
NodeTypeVariableType=iota
50
+
// NodeType variable of type node
51
+
NodeTypeVariableType=iota
52
+
// RelationType variable of type relation
48
53
RelationTypeVariableType=iota
49
54
)
50
55
56
+
// TypeAndIndex type and index of a variable from the cypher query
51
57
typeTypeAndIndexstruct {
52
58
TypeVariableType
53
59
Indexint
54
60
}
55
61
62
+
// QueryGraph the representation of a query graph. This structure helps create the relations between nodes to facilitate SQL translation and projections
56
63
typeQueryGraphstruct {
57
64
Nodes []QueryNode
58
65
Relations []QueryRelation
59
66
60
67
VariablesIndexmap[string]TypeAndIndex
61
68
}
62
69
70
+
// NewQueryGraph create an instance of a query graph
0 commit comments