本文整理汇总了Golang中github.com/google/cayley/graph.NewQuadStore函数的典型用法代码示例。如果您正苦于以下问题:Golang NewQuadStore函数的具体用法?Golang NewQuadStore怎么用?Golang NewQuadStore使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewQuadStore函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestMultipleConstraintParse
func TestMultipleConstraintParse(t *testing.T) {
qs, _ := graph.NewQuadStore("memstore", "", nil)
w, _ := graph.NewQuadWriter("single", qs, nil)
for _, tv := range []quad.Quad{
{"i", "like", "food", ""},
{"i", "like", "beer", ""},
{"you", "like", "beer", ""},
} {
w.AddQuad(tv)
}
query := `(
$a
(:like :beer)
(:like "food")
)`
it := BuildIteratorTreeForQuery(qs, query)
if it.Type() != graph.And {
t.Errorf("Odd iterator tree. Got: %#v", it.Describe())
}
if !graph.Next(it) {
t.Error("Got no results")
}
out := it.Result()
if out != qs.ValueOf("i") {
t.Errorf("Got %d, expected %d", out, qs.ValueOf("i"))
}
if graph.Next(it) {
t.Error("Too many results")
}
}
开发者ID:ericcapricorn,项目名称:cayley,代码行数:30,代码来源:parser_test.go
示例2: init
func init() {
glog.SetToStderr(true)
cfg := config.ParseConfigFromFile("cayley_appengine.cfg")
qs, _ := graph.NewQuadStore("memstore", "", nil)
glog.Errorln(cfg)
db.Load(qs, cfg, cfg.DatabasePath)
http.SetupRoutes(qs, cfg)
}
开发者ID:JesseLivingston,项目名称:cayley,代码行数:8,代码来源:appengine.go
示例3: makeTestSession
func makeTestSession(data []quad.Quad) *Session {
qs, _ := graph.NewQuadStore("memstore", "", nil)
w, _ := graph.NewQuadWriter("single", qs, nil)
for _, t := range data {
w.WriteQuad(t)
}
return NewSession(qs)
}
开发者ID:dennwc,项目名称:cayley,代码行数:8,代码来源:mql_test.go
示例4: makeTestStore
func makeTestStore(data []quad.Quad) graph.QuadStore {
qs, _ := graph.NewQuadStore("memstore", "", nil)
w, _ := graph.NewQuadWriter("single", qs, nil)
for _, t := range data {
w.AddQuad(t)
}
return qs
}
开发者ID:oliverp19,项目名称:cayley,代码行数:8,代码来源:path_test.go
示例5: OpenQuadStore
func OpenQuadStore(cfg *config.Config) (graph.QuadStore, error) {
glog.Infof("Opening quad store %q at %s", cfg.DatabaseType, cfg.DatabasePath)
qs, err := graph.NewQuadStore(cfg.DatabaseType, cfg.DatabasePath, cfg.DatabaseOptions)
if err != nil {
return nil, err
}
return qs, nil
}
开发者ID:oliverp19,项目名称:cayley,代码行数:9,代码来源:db.go
示例6: makeTestStore
func makeTestStore(t testing.TB) graph.QuadStore {
simpleGraph := loadGraph("../../data/testdata.nq", t)
qs, _ := graph.NewQuadStore("memstore", "", nil)
w, _ := graph.NewQuadWriter("single", qs, nil)
for _, t := range simpleGraph {
w.AddQuad(t)
}
return qs
}
开发者ID:e4x,项目名称:cayley,代码行数:9,代码来源:path_test.go
示例7: NewGraph
func NewGraph(name, dbpath string, opts graph.Options) (*Handle, error) {
qs, err := graph.NewQuadStore(name, dbpath, opts)
if err != nil {
return nil, err
}
qw, err := graph.NewQuadWriter("single", qs, nil)
if err != nil {
return nil, err
}
return &Handle{qs, qw}, nil
}
开发者ID:e4x,项目名称:cayley,代码行数:11,代码来源:imports.go
示例8: Setup
// Setup call NewArgs and creates a graph.QuadStore from the result using the call
// graph.NewQuadStore(impl.Name, path, opt)
func (impl *QuadStoreImpl) Setup(ctx context.Context, name string) (err error) {
path, opt, err := impl.NewArgs(ctx, name)
if err != nil {
return fmt.Errorf("initializing %s: %v", name, err)
}
qs, err := graph.NewQuadStore(impl.Name, path, opt)
if err != nil {
impl.Teardown(ctx, name)
return err
}
vars := testrunner.ContextVars(ctx)
setQuadStore(vars, qs)
return nil
}
开发者ID:bmatsuo,项目名称:cayley,代码行数:19,代码来源:qstest.go
示例9: TestTreeConstraintTagParse
func TestTreeConstraintTagParse(t *testing.T) {
qs, _ := graph.NewQuadStore("memstore", "", nil)
w, _ := graph.NewQuadWriter("single", qs, nil)
w.AddQuad(quad.Quad{"i", "like", "food", ""})
w.AddQuad(quad.Quad{"food", "is", "good", ""})
query := "(\"i\"\n" +
"(:like\n" +
"($a (:is :good))))"
it := BuildIteratorTreeForQuery(qs, query)
if !graph.Next(it) {
t.Error("Got no results")
}
tags := make(map[string]graph.Value)
it.TagResults(tags)
if qs.NameOf(tags["$a"]) != "food" {
t.Errorf("Got %s, expected food", qs.NameOf(tags["$a"]))
}
}
开发者ID:ericcapricorn,项目名称:cayley,代码行数:19,代码来源:parser_test.go
示例10: TestTreeConstraintParse
func TestTreeConstraintParse(t *testing.T) {
qs, _ := graph.NewQuadStore("memstore", "", nil)
w, _ := graph.NewQuadWriter("single", qs, nil)
w.AddQuad(quad.Quad{"i", "like", "food", ""})
w.AddQuad(quad.Quad{"food", "is", "good", ""})
query := "(\"i\"\n" +
"(:like\n" +
"($a (:is :good))))"
it := BuildIteratorTreeForQuery(qs, query)
if it.Type() != graph.And {
t.Errorf("Odd iterator tree. Got: %#v", it.Describe())
}
if !graph.Next(it) {
t.Error("Got no results")
}
out := it.Result()
if out != qs.ValueOf("i") {
t.Errorf("Got %d, expected %d", out, qs.ValueOf("i"))
}
}
开发者ID:ericcapricorn,项目名称:cayley,代码行数:20,代码来源:parser_test.go
示例11: TestMemstoreBackedSexp
func TestMemstoreBackedSexp(t *testing.T) {
qs, _ := graph.NewQuadStore("memstore", "", nil)
w, _ := graph.NewQuadWriter("single", qs, nil)
it := BuildIteratorTreeForQuery(qs, "()")
if it.Type() != graph.Null {
t.Errorf(`Incorrect type for empty query, got:%q expect: "null"`, it.Type())
}
for _, test := range testQueries {
if test.add.IsValid() {
w.AddQuad(test.add)
}
it := BuildIteratorTreeForQuery(qs, test.query)
if it.Type() != test.typ {
t.Errorf("Incorrect type for %s, got:%q expect %q", test.message, it.Type(), test.expect)
}
if !graph.Next(it) {
t.Errorf("Failed to %s", test.message)
}
got := it.Result()
if expect := qs.ValueOf(test.expect); got != expect {
t.Errorf("Incorrect result for %s, got:%v expect %v", test.message, got, expect)
}
}
}
开发者ID:ericcapricorn,项目名称:cayley,代码行数:24,代码来源:parser_test.go
注:本文中的github.com/google/cayley/graph.NewQuadStore函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论