[英]Creating a new quad store with go(cayley)?
I'm new to go and I'm trying to create a Quad store using cayley/graph library(NewQuadStore()). 我是新手,我正在尝试使用cayley / graph库(NewQuadStore())创建一个Quad商店。 I'm trying to do it on testdata.nq file which is a sample data that comes with cayley. 我正在尝试在testdata.nq文件上执行此操作,这是cayley随附的示例数据。 Here is my code: 这是我的代码:
package main
import (
"fmt"
"github.com/google/cayley/graph"
"log"
)
func main() {
var register graph.QuadStoreRegistration
graph.RegisterQuadStore("testdata", register)
store, err := graph.NewQuadStore("testdata", "data/testdata.nq", nil)
if err != nil {
log.Fatalln(err)
}
defer store.Close()
store.Type()
iterator := store.NodesAllIterator()
for iterator.NextPath() {
fmt.Println(store.NameOf(iterator.Result()))
}
}
It compiles with no error but generates a panic when I run it. 它编译没有错误,但是在运行时会产生紧急情况。 It looks like this :- 它看起来像这样:-
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x47045e]
goroutine 1 [running]:
panic(0x5dbfa0, 0xc82000a120)
/usr/local/go/src/runtime/panic.go:464 +0x3e6
github.com/google/cayley/graph.NewQuadStore(0x625c60, 0x8, 0x642500, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0)
/home/himanshi/dev/go/src/github.com/google/cayley/graph/quadstore.go:179 +0x23e
main.main()
/home/himanshi/dev/go/src/cayley/main.go:14 +0xcd
I tried to look inside the quadstore.go to look for the problem but I couldn't figure it out and I can't find anything on godoc as well. 我试图在quadstore.go内查找问题,但无法解决,在godoc上也找不到任何内容。 Please Help. 请帮忙。 Thank You! 谢谢!
var register graph.QuadStoreRegistration
This creates a struct with zero values. 这将创建一个零值的结构。 register.NewFunc
is nil. register.NewFunc
为零。 graph.NewQuadStore
tries to call it. graph.NewQuadStore
尝试调用它。
You have to initialize register
with some kind of NewFunc
, eg https://github.com/google/cayley/blob/master/graph/mongo/quadstore.go#L37 您必须使用某种NewFunc
初始化register
,例如https://github.com/google/cayley/blob/master/graph/mongo/quadstore.go#L37
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.