-
Notifications
You must be signed in to change notification settings - Fork 1
/
parseNeo4jPath.go
62 lines (60 loc) · 1.75 KB
/
parseNeo4jPath.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package common
import (
"github.com/johnnadratowski/golang-neo4j-bolt-driver/structures/graph"
"fmt"
)
// 解析Path
func ParsePath(data *[][]interface{}) {
var paths = [][]string{}
if len(*data) == 0{
return
}
for _, d := range *data{
// 记录路径
var aPath = []string{}
if len(d) == 0 {
continue
}
dPath := d[0].(graph.Path)
// 解析点
dNodes := dPath.Nodes
if len(dNodes) == 0{
continue
}
for _, v := range dNodes{
if len(v.Labels) == 0{
continue
}
vProperties := v.Properties
fmt.Println("vProperties ", vProperties)
// todo something
}
paths = append(paths, aPath)
// 解析关系
dRelationships := dPath.Relationships
dSequence := dPath.Sequence
dSequenceFlag := append([]int{0}, dSequence...)
for sIdx := 0; sIdx < len(dSequenceFlag) / 2; sIdx++ {
rIdx := dSequenceFlag[2*sIdx+1]
rIdxAbs := 0
linkId, target, source := "", "", ""
fmt.Println("linkId", linkId)
// todo something
if rIdx > 0 {
rIdxAbs = rIdx
source = aPath[dSequenceFlag[2*sIdx]]
target = aPath[dSequenceFlag[2*(sIdx+1)]]
} else if rIdx < 0 {
rIdxAbs = rIdx * -1
source = aPath[dSequenceFlag[2*(sIdx+1)]]
target = aPath[dSequenceFlag[2*sIdx]]
} else {
continue
}
v := dRelationships[rIdxAbs-1]
fmt.Println("v ", v)
// todo something
linkId = source + target
}
}
}