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

Golang iterator.NextUID函数代码示例

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

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



在下文中一共展示了NextUID函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: NewIterator

func NewIterator(prefix string, d quad.Direction, value graph.Value, qs *QuadStore) *Iterator {
	vb := value.(Token)
	p := make([]byte, 0, 2+quad.HashSize)
	p = append(p, []byte(prefix)...)
	p = append(p, []byte(vb[1:])...)

	opts := &opt.ReadOptions{
		DontFillCache: true,
	}

	it := Iterator{
		uid:            iterator.NextUID(),
		nextPrefix:     p,
		checkID:        vb,
		dir:            d,
		originalPrefix: prefix,
		ro:             opts,
		iter:           qs.db.NewIterator(nil, opts),
		open:           true,
		qs:             qs,
	}

	ok := it.iter.Seek(it.nextPrefix)
	if !ok {
		it.open = false
		it.iter.Release()
		clog.Errorf("Opening LevelDB iterator couldn't seek to location %v", it.nextPrefix)
	}

	return &it
}
开发者ID:rlugojr,项目名称:cayley,代码行数:31,代码来源:iterator.go


示例2: NewAllIterator

func NewAllIterator(prefix string, d quad.Direction, qs *QuadStore) *AllIterator {
	opts := &opt.ReadOptions{
		DontFillCache: true,
	}

	it := AllIterator{
		nodes:  prefix == "z",
		uid:    iterator.NextUID(),
		ro:     opts,
		iter:   qs.db.NewIterator(nil, opts),
		prefix: []byte(prefix),
		dir:    d,
		open:   true,
		qs:     qs,
	}

	it.iter.Seek(it.prefix)
	if !it.iter.Valid() {
		// FIXME(kortschak) What are the semantics here? Is this iterator usable?
		// If not, we should return nil *Iterator and an error.
		it.open = false
		it.iter.Release()
	}

	return &it
}
开发者ID:rlugojr,项目名称:cayley,代码行数:26,代码来源:all_iterator.go


示例3: NewAllIterator

func NewAllIterator(qs *QuadStore, kind string) *Iterator {
	if kind != nodeKind && kind != quadKind {
		clog.Errorf("Cannot create iterator for an unknown kind")
		return &Iterator{done: true}
	}
	if qs.context == nil {
		clog.Errorf("Cannot create iterator without a valid context")
		return &Iterator{done: true}
	}

	var size int64
	if kind == nodeKind {
		size = qs.NodeSize()
	} else {
		size = qs.Size()
	}

	return &Iterator{
		uid:   iterator.NextUID(),
		qs:    qs,
		size:  size,
		dir:   quad.Any,
		isAll: true,
		kind:  kind,
		done:  false,
	}
}
开发者ID:oren,项目名称:cayley,代码行数:27,代码来源:iterator.go


示例4: Clone

func (it *Iterator) Clone() graph.Iterator {
	var iter *b.Enumerator
	if it.result != nil {
		var ok bool
		iter, ok = it.tree.Seek(it.result.(int64))
		if !ok {
			panic("value unexpectedly missing")
		}
	} else {
		var err error
		iter, err = it.tree.SeekFirst()
		if err != nil {
			iter = nil
		}
	}

	m := &Iterator{
		uid:   iterator.NextUID(),
		qs:    it.qs,
		tree:  it.tree,
		iter:  iter,
		d:     it.d,
		value: it.value,
	}
	m.tags.CopyFrom(it)

	return m
}
开发者ID:RamboWANG,项目名称:cayley,代码行数:28,代码来源:iterator.go


示例5: TestSQLNodeIteration

func TestSQLNodeIteration(t *testing.T) {
	if *postgres_path == "" {
		t.SkipNow()
	}
	db, err := newQuadStore(*postgres_path, nil)
	if err != nil {
		t.Fatal(err)
	}
	link := NewSQLLinkIterator(db.(*QuadStore), quad.Object, quad.Raw("/en/humphrey_bogart"))
	it := &SQLIterator{
		uid: iterator.NextUID(),
		qs:  db.(*QuadStore),
		sql: &SQLNodeIterator{
			tableName: newTableName(),
			linkIt: sqlItDir{
				it:  link.sql,
				dir: quad.Subject,
			},
		},
	}
	s, v := it.sql.buildSQL(true, nil)
	t.Log(s, v)
	c := 0
	for it.Next() {
		t.Log(it.Result())
		c += 1
	}
	if c != 56 {
		t.Errorf("Not enough results, got %d expected 56", c)
	}

}
开发者ID:rlugojr,项目名称:cayley,代码行数:32,代码来源:sql_link_iterator_test.go


示例6: Clone

func (it *SQLIterator) Clone() graph.Iterator {
	m := &SQLIterator{
		uid: iterator.NextUID(),
		qs:  it.qs,
		sql: it.sql.sqlClone(),
	}
	return m
}
开发者ID:RamboWANG,项目名称:cayley,代码行数:8,代码来源:sql_iterator.go


示例7: NewSQLIterator

func NewSQLIterator(qs *QuadStore, sql sqlIterator) *SQLIterator {
	l := &SQLIterator{
		uid: iterator.NextUID(),
		qs:  qs,
		sql: sql,
	}
	return l
}
开发者ID:RamboWANG,项目名称:cayley,代码行数:8,代码来源:sql_iterator.go


示例8: NewAllIterator

func NewAllIterator(bucket []byte, d quad.Direction, qs *QuadStore) *AllIterator {
	return &AllIterator{
		uid:    iterator.NextUID(),
		bucket: bucket,
		dir:    d,
		qs:     qs,
	}
}
开发者ID:RamboWANG,项目名称:cayley,代码行数:8,代码来源:all_iterator.go


示例9: NewLinksTo

// NewLinksTo constructs a new indexed LinksTo iterator for Mongo around a direction
// and a subiterator of nodes.
func NewLinksTo(qs *QuadStore, it graph.Iterator, collection string, d quad.Direction, lset []graph.Linkage) *LinksTo {
	return &LinksTo{
		uid:        iterator.NextUID(),
		qs:         qs,
		primaryIt:  it,
		dir:        d,
		nextIt:     nil,
		lset:       lset,
		collection: collection,
	}
}
开发者ID:RamboWANG,项目名称:cayley,代码行数:13,代码来源:indexed_linksto.go


示例10: NewIteratorWithConstraints

func NewIteratorWithConstraints(qs *QuadStore, collection string, constraint bson.M) *Iterator {
	return &Iterator{
		uid:        iterator.NextUID(),
		qs:         qs,
		dir:        quad.Any,
		constraint: constraint,
		collection: collection,
		iter:       nil,
		size:       -1,
		hash:       "",
		isAll:      false,
	}
}
开发者ID:coralproject,项目名称:xenia,代码行数:13,代码来源:iterator.go


示例11: NewAllIterator

func NewAllIterator(qs *QuadStore, collection string) *Iterator {
	return &Iterator{
		uid:        iterator.NextUID(),
		qs:         qs,
		dir:        quad.Any,
		constraint: nil,
		collection: collection,
		iter:       nil,
		size:       -1,
		hash:       "",
		isAll:      true,
	}
}
开发者ID:coralproject,项目名称:xenia,代码行数:13,代码来源:iterator.go


示例12: NewIterator

func NewIterator(tree *b.Tree, qs *QuadStore, d quad.Direction, value graph.Value) *Iterator {
	iter, err := tree.SeekFirst()
	if err != nil {
		iter = nil
	}
	return &Iterator{
		uid:   iterator.NextUID(),
		qs:    qs,
		tree:  tree,
		iter:  iter,
		d:     d,
		value: value,
	}
}
开发者ID:RamboWANG,项目名称:cayley,代码行数:14,代码来源:iterator.go


示例13: NewSQLLinkIterator

func NewSQLLinkIterator(qs *QuadStore, d quad.Direction, val string) *SQLIterator {
	l := &SQLIterator{
		uid: iterator.NextUID(),
		qs:  qs,
		sql: &SQLLinkIterator{
			constraints: []constraint{
				constraint{
					dir:  d,
					vals: []string{val},
				},
			},
			tableName: newTableName(),
			size:      0,
		},
	}
	return l
}
开发者ID:RamboWANG,项目名称:cayley,代码行数:17,代码来源:sql_iterator.go


示例14: NewIterator

func NewIterator(qs *QuadStore, collection string, d quad.Direction, val graph.Value) *Iterator {
	h := val.(NodeHash)

	constraint := bson.M{d.String(): string(h)}

	return &Iterator{
		uid:        iterator.NextUID(),
		constraint: constraint,
		collection: collection,
		qs:         qs,
		dir:        d,
		iter:       nil,
		size:       -1,
		hash:       h,
		isAll:      false,
	}
}
开发者ID:coralproject,项目名称:xenia,代码行数:17,代码来源:iterator.go


示例15: newSQLLinkIterator

func newSQLLinkIterator(qs *QuadStore, d quad.Direction, hash NodeHash) *SQLIterator {
	l := &SQLIterator{
		uid: iterator.NextUID(),
		qs:  qs,
		sql: &SQLLinkIterator{
			constraints: []constraint{
				constraint{
					dir:    d,
					hashes: []NodeHash{hash},
				},
			},
			tableName: newTableName(),
			size:      0,
		},
	}
	return l
}
开发者ID:rlugojr,项目名称:cayley,代码行数:17,代码来源:sql_iterator.go


示例16: NewIterator

func NewIterator(qs *QuadStore, k string, d quad.Direction, val graph.Value) *Iterator {
	t := val.(*Token)
	if t == nil {
		clog.Errorf("Token == nil")
	}
	if t.Kind != nodeKind {
		clog.Errorf("Cannot create an iterator from a non-node value")
		return &Iterator{done: true}
	}
	if k != nodeKind && k != quadKind {
		clog.Errorf("Cannot create iterator for unknown kind")
		return &Iterator{done: true}
	}
	if qs.context == nil {
		clog.Errorf("Cannot create iterator without a valid context")
		return &Iterator{done: true}
	}
	name := quad.StringOf(qs.NameOf(t))

	// The number of references to this node is held in the nodes entity
	key := qs.createKeyFromToken(t)
	foundNode := new(NodeEntry)
	err := datastore.Get(qs.context, key, foundNode)
	if err != nil && err != datastore.ErrNoSuchEntity {
		clog.Errorf("Error: %v", err)
		return &Iterator{done: true}
	}
	size := foundNode.Size

	return &Iterator{
		uid:   iterator.NextUID(),
		name:  name,
		dir:   d,
		qs:    qs,
		size:  size,
		isAll: false,
		kind:  k,
		hash:  t.Hash,
		done:  false,
	}
}
开发者ID:oren,项目名称:cayley,代码行数:41,代码来源:iterator.go


示例17: optimizeLinksTo

func (qs *QuadStore) optimizeLinksTo(it *iterator.LinksTo) (graph.Iterator, bool) {
	subs := it.SubIterators()
	if len(subs) != 1 {
		return it, false
	}
	primary := subs[0]
	switch primary.Type() {
	case graph.Fixed:
		size, _ := primary.Size()
		if size == 0 {
			return iterator.NewNull(), true
		}
		if size == 1 {
			if !primary.Next() {
				panic("sql: unexpected size during optimize")
			}
			val := primary.Result()
			newIt := qs.QuadIterator(it.Direction(), val)
			nt := newIt.Tagger()
			nt.CopyFrom(it)
			for _, tag := range primary.Tagger().Tags() {
				nt.AddFixed(tag, val)
			}
			it.Close()
			return newIt, true
		} else if size > 1 {
			var vals []NodeHash
			for primary.Next() {
				vals = append(vals, primary.Result().(NodeHash))
			}
			lsql := &SQLLinkIterator{
				constraints: []constraint{
					constraint{
						dir:    it.Direction(),
						hashes: vals,
					},
				},
				tableName: newTableName(),
				size:      0,
			}
			l := &SQLIterator{
				uid: iterator.NextUID(),
				qs:  qs,
				sql: lsql,
			}
			nt := l.Tagger()
			nt.CopyFrom(it)
			for _, t := range primary.Tagger().Tags() {
				lsql.tagdirs = append(lsql.tagdirs, tagDir{
					dir: it.Direction(),
					tag: t,
				})
			}
			it.Close()
			return l, true
		}
	case sqlType:
		p := primary.(*SQLIterator)
		newit, err := linksto(p.sql, it.Direction(), qs)
		if err != nil {
			clog.Errorf("%v", err)
			return it, false
		}
		newit.Tagger().CopyFrom(it)
		return newit, true
	case graph.All:
		linkit := &SQLLinkIterator{
			tableName: newTableName(),
			size:      qs.Size(),
		}
		for _, t := range primary.Tagger().Tags() {
			linkit.tagdirs = append(linkit.tagdirs, tagDir{
				dir: it.Direction(),
				tag: t,
			})
		}
		for k, v := range primary.Tagger().Fixed() {
			linkit.tagger.AddFixed(k, v)
		}
		linkit.tagger.CopyFrom(it)
		newit := NewSQLIterator(qs, linkit)
		return newit, true
	}
	return it, false
}
开发者ID:rlugojr,项目名称:cayley,代码行数:85,代码来源:optimizers.go



注:本文中的github.com/cayleygraph/cayley/graph/iterator.NextUID函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang iterator.LinksTo类代码示例发布时间:2022-05-23
下一篇:
Golang iterator.NewLinksTo函数代码示例发布时间: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