• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang graph.NewQuadWriter函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/google/cayley/graph.NewQuadWriter函数的典型用法代码示例。如果您正苦于以下问题:Golang NewQuadWriter函数的具体用法?Golang NewQuadWriter怎么用?Golang NewQuadWriter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewQuadWriter函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: makeTestSession

func makeTestSession(data []quad.Quad) *Session {
	ts, _ := graph.NewTripleStore("memstore", "", nil)
	w, _ := graph.NewQuadWriter("single", ts, nil)
	for _, t := range data {
		w.AddQuad(t)
	}
	return NewSession(ts, -1, false)
}
开发者ID:kris-lab,项目名称:cayley,代码行数:8,代码来源:gremlin_test.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: OpenQuadWriter

func OpenQuadWriter(qs graph.QuadStore, cfg *config.Config) (graph.QuadWriter, error) {
	glog.Infof("Opening replication method %q", cfg.ReplicationType)
	w, err := graph.NewQuadWriter(cfg.ReplicationType, qs, cfg.ReplicationOptions)
	if err != nil {
		return nil, err
	}

	return w, 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: 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


示例9: 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


示例10: 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.NewQuadWriter函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang graph.NewResultTree函数代码示例发布时间:2022-05-23
下一篇:
Golang graph.NewQuadStore函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap