當前位置: 首頁>>代碼示例>>Golang>>正文


Golang graph.NewQuadWriter函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。