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


Golang glog.V函數代碼示例

本文整理匯總了Golang中github.com/barakmich/glog.V函數的典型用法代碼示例。如果您正苦於以下問題:Golang V函數的具體用法?Golang V怎麽用?Golang V使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: optimizeAndIterator

func (qs *QuadStore) optimizeAndIterator(it *iterator.And) (graph.Iterator, bool) {
	// Fail fast if nothing can happen
	glog.V(4).Infoln("Entering optimizeAndIterator", it.UID())
	found := false
	for _, it := range it.SubIterators() {
		glog.V(4).Infoln(it.Type())
		if it.Type() == mongoType {
			found = true
		}
	}
	if !found {
		glog.V(4).Infoln("Aborting optimizeAndIterator")
		return it, false
	}

	newAnd := iterator.NewAnd(qs)
	var mongoIt *Iterator
	for _, it := range it.SubIterators() {
		switch it.Type() {
		case mongoType:
			if mongoIt == nil {
				mongoIt = it.(*Iterator)
			} else {
				newAnd.AddSubIterator(it)
			}
		case graph.LinksTo:
			continue
		default:
			newAnd.AddSubIterator(it)
		}
	}
	stats := mongoIt.Stats()

	lset := []graph.Linkage{
		{
			Dir:   mongoIt.dir,
			Value: qs.ValueOf(mongoIt.name),
		},
	}

	n := 0
	for _, it := range it.SubIterators() {
		if it.Type() == graph.LinksTo {
			lto := it.(*iterator.LinksTo)
			// Is it more effective to do the replacement, or let the mongo check the linksto?
			ltostats := lto.Stats()
			if (ltostats.ContainsCost+stats.NextCost)*stats.Size > (ltostats.NextCost+stats.ContainsCost)*ltostats.Size {
				continue
			}
			newLto := NewLinksTo(qs, lto.SubIterators()[0], "quads", lto.Direction(), lset)
			newAnd.AddSubIterator(newLto)
			n++
		}
	}
	if n == 0 {
		return it, false
	}

	return newAnd.Optimize()
}
開發者ID:lytics,項目名稱:cayley,代碼行數:60,代碼來源:quadstore_iterator_optimize.go

示例2: makeCursor

func (it *AllIterator) makeCursor() {
	var cursor *sql.Rows
	var err error
	if it.cursor != nil {
		it.cursor.Close()
	}
	if it.table == "quads" {
		cursor, err = it.qs.db.Query(`SELECT subject, predicate, object, label FROM quads;`)
		if err != nil {
			glog.Errorln("Couldn't get cursor from SQL database: %v", err)
			cursor = nil
		}
	} else {
		glog.V(4).Infoln("sql: getting node query")
		cursor, err = it.qs.db.Query(`SELECT node FROM
			(
				SELECT subject FROM quads
				UNION
				SELECT predicate FROM quads
				UNION
				SELECT object FROM quads
				UNION
				SELECT label FROM quads
			) AS DistinctNodes (node) WHERE node IS NOT NULL;`)
		if err != nil {
			glog.Errorln("Couldn't get cursor from SQL database: %v", err)
			cursor = nil
		}
		glog.V(4).Infoln("sql: got node query")
	}
	it.cursor = cursor
}
開發者ID:e4x,項目名稱:cayley,代碼行數:32,代碼來源:all_iterator.go

示例3: ExecInput

func (m *MqlSession) ExecInput(input string, c chan interface{}, limit int) {
	defer close(c)
	var mqlQuery interface{}
	err := json.Unmarshal([]byte(input), &mqlQuery)
	if err != nil {
		return
	}
	m.currentQuery = NewMqlQuery(m)
	m.currentQuery.BuildIteratorTree(mqlQuery)
	if m.currentQuery.isError {
		return
	}
	it, _ := m.currentQuery.it.Optimize()
	if glog.V(2) {
		glog.V(2).Infoln(it.DebugString(0))
	}
	for {
		_, ok := it.Next()
		if !ok {
			break
		}
		tags := make(map[string]graph.TSVal)
		it.TagResults(&tags)
		c <- &tags
		for it.NextResult() == true {
			tags := make(map[string]graph.TSVal)
			it.TagResults(&tags)
			c <- &tags
		}
	}
}
開發者ID:JIVS,項目名稱:cayley,代碼行數:31,代碼來源:mql-session.go

示例4: ExecInput

func (s *Session) ExecInput(input string, c chan interface{}, _ int) {
	defer close(c)
	var mqlQuery interface{}
	err := json.Unmarshal([]byte(input), &mqlQuery)
	if err != nil {
		return
	}
	s.currentQuery = NewQuery(s)
	s.currentQuery.BuildIteratorTree(mqlQuery)
	if s.currentQuery.isError() {
		return
	}
	it, _ := s.currentQuery.it.Optimize()
	if glog.V(2) {
		glog.V(2).Infoln(it.DebugString(0))
	}
	for graph.Next(it) {
		tags := make(map[string]graph.Value)
		it.TagResults(tags)
		c <- tags
		for it.NextPath() == true {
			tags := make(map[string]graph.Value)
			it.TagResults(tags)
			c <- tags
		}
	}
}
開發者ID:JesseLivingston,項目名稱:cayley,代碼行數:27,代碼來源:session.go

示例5: Load

func Load(qw graph.QuadWriter, cfg *config.Config, dec quad.Unmarshaler) error {
	block := make([]quad.Quad, 0, cfg.LoadSize)
	count := 0
	for {
		t, err := dec.Unmarshal()
		if err != nil {
			if err == io.EOF {
				break
			}
			return err
		}
		block = append(block, t)
		if len(block) == cap(block) {
			count += len(block)
			err := qw.AddQuadSet(block)
			if err != nil {
				return fmt.Errorf("db: failed to load data: %v", err)
			}
			block = block[:0]
			if glog.V(2) {
				glog.V(2).Infof("Wrote %d quads.", count)
			}
		}
	}
	count += len(block)
	err := qw.AddQuadSet(block)
	if err != nil {
		return fmt.Errorf("db: failed to load data: %v", err)
	}
	if glog.V(2) {
		glog.V(2).Infof("Wrote %d quads.", count)
	}

	return nil
}
開發者ID:oliverp19,項目名稱:cayley,代碼行數:35,代碼來源:db.go

示例6: Size

// Size is the number of values stored, if we've got them all.
// Otherwise, guess based on the size of the subiterator.
func (it *Materialize) Size() (int64, bool) {
	if it.hasRun && !it.aborted {
		glog.V(2).Infoln("returning size", it.actualSize)
		return it.actualSize, true
	}
	glog.V(2).Infoln("bailing size", it.actualSize)
	return it.subIt.Size()
}
開發者ID:lytics,項目名稱:cayley,代碼行數:10,代碼來源:materialize_iterator.go

示例7: buildSQL

func (l *SQLLinkIterator) buildSQL(next bool, val graph.Value) (string, []string) {
	query := "SELECT "
	t := []string{
		fmt.Sprintf("%s.subject", l.tableName),
		fmt.Sprintf("%s.predicate", l.tableName),
		fmt.Sprintf("%s.object", l.tableName),
		fmt.Sprintf("%s.label", l.tableName),
	}
	for _, v := range l.getTags() {
		t = append(t, v.String())
	}
	query += strings.Join(t, ", ")
	query += " FROM "
	t = []string{}
	var values []string
	for _, k := range l.getTables() {
		values = append(values, k.values...)
		t = append(t, fmt.Sprintf("%s as %s", k.table, k.name))
	}
	query += strings.Join(t, ", ")
	constraint, wherevalues := l.buildWhere()
	if constraint != "" {
		query += " WHERE "
	}

	values = append(values, wherevalues...)
	if !next {
		v := val.(quad.Quad)
		if constraint != "" {
			constraint += " AND "
		} else {
			constraint += " WHERE "
		}
		t = []string{
			fmt.Sprintf("%s.subject_hash = ?", l.tableName),
			fmt.Sprintf("%s.predicate_hash = ?", l.tableName),
			fmt.Sprintf("%s.object_hash = ?", l.tableName),
			fmt.Sprintf("%s.label_hash = ?", l.tableName),
		}
		constraint += strings.Join(t, " AND ")
		values = append(values, hashOf(v.Subject))
		values = append(values, hashOf(v.Predicate))
		values = append(values, hashOf(v.Object))
		values = append(values, hashOf(v.Label))
	}
	query += constraint
	query += ";"

	if glog.V(4) {
		dstr := query
		for i := 1; i <= len(values); i++ {
			dstr = strings.Replace(dstr, "?", fmt.Sprintf("'%s'", values[i-1]), 1)
		}
		glog.V(4).Infoln(dstr)
	}
	return query, values
}
開發者ID:e4x,項目名稱:cayley,代碼行數:57,代碼來源:sql_link_iterator.go

示例8: ContainsLogOut

func ContainsLogOut(it Iterator, val Value, good bool) bool {
	if glog.V(4) {
		if good {
			glog.V(4).Infof("%s %d CHECK CONTAINS %d GOOD", strings.ToUpper(it.Type().String()), it.UID(), val)
		} else {
			glog.V(4).Infof("%s %d CHECK CONTAINS %d BAD", strings.ToUpper(it.Type().String()), it.UID(), val)
		}
	}
	return good
}
開發者ID:neevor,項目名稱:cayley,代碼行數:10,代碼來源:iterator.go

示例9: NextLogOut

func NextLogOut(it Iterator, val TSVal, ok bool) (TSVal, bool) {
	if glog.V(4) {
		if ok {
			glog.V(4).Infof("%s %d NEXT IS %d", strings.ToUpper(it.Type()), it.GetUid(), val)
		} else {
			glog.V(4).Infof("%s %d NEXT DONE", strings.ToUpper(it.Type()), it.GetUid())
		}
	}
	return val, ok
}
開發者ID:JIVS,項目名稱:cayley,代碼行數:10,代碼來源:iterator.go

示例10: NextLogOut

func NextLogOut(it Iterator, val Value, ok bool) (Value, bool) {
	if glog.V(4) {
		if ok {
			glog.V(4).Infof("%s %d NEXT IS %d", strings.ToUpper(it.Type().String()), it.UID(), val)
		} else {
			glog.V(4).Infof("%s %d NEXT DONE", strings.ToUpper(it.Type().String()), it.UID())
		}
	}
	return val, ok
}
開發者ID:neevor,項目名稱:cayley,代碼行數:10,代碼來源:iterator.go

示例11: CheckLogOut

func CheckLogOut(it Iterator, val TSVal, good bool) bool {
	if glog.V(4) {
		if good {
			glog.V(4).Infof("%s %d CHECK %d GOOD", strings.ToUpper(it.Type()), it.GetUid(), val)
		} else {
			glog.V(4).Infof("%s %d CHECK %d BAD", strings.ToUpper(it.Type()), it.GetUid(), val)
		}
	}
	return good
}
開發者ID:JIVS,項目名稱:cayley,代碼行數:10,代碼來源:iterator.go

示例12: Check

// Check a value against our internal iterator. In order to do this, we must first open a new
// iterator of "triples that have `val` in our direction", given to us by the triple store,
// and then Next() values out of that iterator and Check() them against our subiterator.
func (it *HasA) Check(val graph.TSVal) bool {
	graph.CheckLogIn(it, val)
	if glog.V(4) {
		glog.V(4).Infoln("Id is", it.ts.GetNameFor(val))
	}
	// TODO(barakmich): Optimize this
	if it.resultIt != nil {
		it.resultIt.Close()
	}
	it.resultIt = it.ts.GetTripleIterator(it.dir, val)
	return graph.CheckLogOut(it, val, it.GetCheckResult())
}
開發者ID:heshizhu,項目名稱:cayley,代碼行數:15,代碼來源:hasa_iterator.go

示例13: Contains

// Check a value against our internal iterator. In order to do this, we must first open a new
// iterator of "triples that have `val` in our direction", given to us by the triple store,
// and then Next() values out of that iterator and Contains() them against our subiterator.
func (it *HasA) Contains(val graph.Value) bool {
	graph.ContainsLogIn(it, val)
	if glog.V(4) {
		glog.V(4).Infoln("Id is", it.ts.NameOf(val))
	}
	// TODO(barakmich): Optimize this
	if it.resultIt != nil {
		it.resultIt.Close()
	}
	it.resultIt = it.ts.TripleIterator(it.dir, val)
	return graph.ContainsLogOut(it, val, it.NextContains())
}
開發者ID:uriencedric,項目名稱:cayley,代碼行數:15,代碼來源:hasa_iterator.go

示例14: Check

// Check a value against our internal iterator. In order to do this, we must first open a new
// iterator of "triples that have `val` in our direction", given to us by the triple store,
// and then Next() values out of that iterator and Check() them against our subiterator.
func (h *HasaIterator) Check(val TSVal) bool {
	CheckLogIn(h, val)
	if glog.V(4) {
		glog.V(4).Infoln("Id is", h.ts.GetNameFor(val))
	}
	// TODO(barakmich): Optimize this
	if h.resultIt != nil {
		h.resultIt.Close()
	}
	h.resultIt = h.ts.GetTripleIterator(h.direction, val)
	return CheckLogOut(h, val, h.GetCheckResult())
}
開發者ID:JIVS,項目名稱:cayley,代碼行數:15,代碼來源:hasa-iterator.go

示例15: NextContains

// NextContains() is shared code between Contains() and GetNextResult() -- calls next on the
// result iterator (a triple iterator based on the last checked value) and returns true if
// another match is made.
func (it *HasA) NextContains() bool {
	for graph.Next(it.resultIt) {
		link := it.resultIt.Result()
		if glog.V(4) {
			glog.V(4).Infoln("Quad is", it.ts.Quad(link))
		}
		if it.primaryIt.Contains(link) {
			it.result = it.ts.TripleDirection(link, it.dir)
			return true
		}
	}
	return false
}
開發者ID:uriencedric,項目名稱:cayley,代碼行數:16,代碼來源:hasa_iterator.go


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