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


Golang Direction.String方法代碼示例

本文整理匯總了Golang中github.com/google/cayley/quad.Direction.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang Direction.String方法的具體用法?Golang Direction.String怎麽用?Golang Direction.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/google/cayley/quad.Direction的用法示例。


在下文中一共展示了Direction.String方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: NewIterator

func NewIterator(qs *TripleStore, collection string, d quad.Direction, val graph.Value) *Iterator {
	name := qs.NameOf(val)

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

	size, err := qs.db.C(collection).Find(constraint).Count()
	if err != nil {
		// FIXME(kortschak) This should be passed back rather than just logging.
		glog.Errorln("Trouble getting size for iterator! ", err)
		return nil
	}

	return &Iterator{
		uid:        iterator.NextUID(),
		name:       name,
		constraint: constraint,
		collection: collection,
		qs:         qs,
		dir:        d,
		iter:       qs.db.C(collection).Find(constraint).Iter(),
		size:       int64(size),
		hash:       val.(string),
		isAll:      false,
	}
}
開發者ID:kris-lab,項目名稱:cayley,代碼行數:25,代碼來源:iterator.go

示例2: sizeForIterator

func (qs *QuadStore) sizeForIterator(isAll bool, dir quad.Direction, val string) int64 {
	var err error
	if isAll {
		return qs.Size()
	}
	if qs.noSizes {
		if dir == quad.Predicate {
			return (qs.Size() / 100) + 1
		}
		return (qs.Size() / 1000) + 1
	}
	if val, ok := qs.lru.Get(val + string(dir.Prefix())); ok {
		return val
	}
	var size int64
	glog.V(4).Infoln("sql: getting size for select %s, %s", dir.String(), val)
	err = qs.db.QueryRow(
		fmt.Sprintf("SELECT count(*) FROM quads WHERE %s_hash = $1;", dir.String()), hashOf(val)).Scan(&size)
	if err != nil {
		glog.Errorln("Error getting size from SQL database: %v", err)
		return 0
	}
	qs.lru.Put(val+string(dir.Prefix()), size)
	return size
}
開發者ID:WeiZhang555,項目名稱:clair,代碼行數:25,代碼來源:quadstore.go

示例3: TripleIterator

func (qs *TripleStore) TripleIterator(d quad.Direction, val graph.Value) graph.Iterator {
	var prefix string
	switch d {
	case quad.Subject:
		prefix = "sp"
	case quad.Predicate:
		prefix = "po"
	case quad.Object:
		prefix = "os"
	case quad.Label:
		prefix = "cp"
	default:
		panic("unreachable " + d.String())
	}
	return NewIterator(prefix, d, val, qs)
}
開發者ID:Joeento,項目名稱:cayley,代碼行數:16,代碼來源:triplestore.go

示例4: QuadIterator

func (qs *QuadStore) QuadIterator(d quad.Direction, val graph.Value) graph.Iterator {
	var bucket []byte
	switch d {
	case quad.Subject:
		bucket = spoBucket
	case quad.Predicate:
		bucket = posBucket
	case quad.Object:
		bucket = ospBucket
	case quad.Label:
		bucket = cpsBucket
	default:
		panic("unreachable " + d.String())
	}
	return NewIterator(bucket, d, val, qs)
}
開發者ID:dennwc,項目名稱:cayley,代碼行數:16,代碼來源:quadstore.go

示例5: QuadIterator

// QuadIterator ??
func (qs *QuadStore) QuadIterator(d quad.Direction, val graph.Value) graph.Iterator {
	var db string
	switch d {
	case quad.Subject:
		db = spoDB
	case quad.Predicate:
		db = posDB
	case quad.Object:
		db = ospDB
	case quad.Label:
		db = cpsDB
	default:
		panic("unreachable " + d.String())
	}
	return NewIterator(db, d, val, qs)
}
開發者ID:bmatsuo,項目名稱:cayley,代碼行數:17,代碼來源:quadstore.go

示例6: 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:dennwc,項目名稱:cayley,代碼行數:17,代碼來源:iterator.go

示例7: NewIterator

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

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

	return &Iterator{
		uid:        iterator.NextUID(),
		name:       name,
		constraint: constraint,
		collection: collection,
		qs:         qs,
		dir:        d,
		iter:       nil,
		size:       -1,
		hash:       val.(string),
		isAll:      false,
	}
}
開發者ID:e4x,項目名稱:cayley,代碼行數:18,代碼來源:iterator.go

示例8: buildIteratorFor

func (it *LinksTo) buildIteratorFor(d quad.Direction, val graph.Value) *mgo.Iter {
	name := it.qs.NameOf(val)
	constraint := it.buildConstraint()
	constraint[d.String()] = name
	return it.qs.db.C(it.collection).Find(constraint).Iter()
}
開發者ID:e4x,項目名稱:cayley,代碼行數:6,代碼來源:indexed_linksto.go

示例9: buildIteratorFor

func (it *LinksTo) buildIteratorFor(d quad.Direction, val graph.Value) *mgo.Iter {
	constraint := it.buildConstraint()
	constraint[d.String()] = string(val.(NodeHash))
	return it.qs.db.C(it.collection).Find(constraint).Iter()
}
開發者ID:dennwc,項目名稱:cayley,代碼行數:5,代碼來源:indexed_linksto.go


注:本文中的github.com/google/cayley/quad.Direction.String方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。