-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added path support #20
Conversation
Codecov Report
@@ Coverage Diff @@
## master #20 +/- ##
==========================================
- Coverage 67.75% 67.57% -0.18%
==========================================
Files 6 7 +1
Lines 428 475 +47
==========================================
+ Hits 290 321 +31
- Misses 124 140 +16
Partials 14 14
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
path.go
Outdated
Nodes []interface{} | ||
Edges []interface{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nodes []Node
Edges []Edge
we've got both an Edge and Node structs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to []*Node
and []*Edge
Edges []interface{} | ||
} | ||
|
||
func PathNew(nodes []interface{}, edges []interface{}) Path { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func PathNew(nodes []Node, edges []Edge) Path {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the constructor will convert from array of interface to array of node/edge
path.go
Outdated
} | ||
} | ||
|
||
func (p Path) GetNodes() []interface{} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func (p Path) GetNodes() []Node {
path.go
Outdated
return p.Nodes | ||
} | ||
|
||
func (p Path) GetEdges() []interface{} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func (p Path) GetEdges() []Edge {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[]*Edge
} | ||
|
||
func (p Path) FirstNode() *Node { | ||
return p.GetNode(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the Path is empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
execption
path.go
Outdated
} | ||
|
||
func (p Path) GetNode(index int) *Node { | ||
return p.Nodes[index].(*Node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Index validations?
index >=0 && index < Path length ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exception
} | ||
|
||
func (p Path) LastNode() *Node { | ||
return p.GetNode(p.NodesCount() - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if NodeCount is 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exception
path.go
Outdated
return len(p.Edges) | ||
} | ||
|
||
func (p Path) Encode() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://play.golang.org/p/Azql7_pDAA
func (p Path) String() string {...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
README.md
Outdated
res.Next() | ||
r := res.Record() | ||
p, ok := r.GetByIndex(0).(Path) | ||
fmt.Printf("%v", p.Encode()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Printf("%s", p)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
arrays := cell.([]interface{}) | ||
nodes := qr.parseScalar(arrays[0].([]interface{})) | ||
edges := qr.parseScalar(arrays[1].([]interface{})) | ||
return PathNew(nodes.([]interface{}), edges.([]interface{})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return PathNew(nodes, edges)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be an array
No description provided.