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


Golang glog.Error函數代碼示例

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


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

示例1: Contains

func (it *Iterator) Contains(v graph.Value) bool {
	graph.ContainsLogIn(it, v)
	if it.isAll {
		// The result needs to be set, so when contains is called, the result can be retrieved
		it.result = v
		return graph.ContainsLogOut(it, v, true)
	}
	t := v.(*Token)
	if t == nil {
		glog.Error("Could not cast to token")
		return graph.ContainsLogOut(it, v, false)
	}
	if t.Kind == nodeKind {
		glog.Error("Contains does not work with node values")
		return graph.ContainsLogOut(it, v, false)
	}
	// Contains is for when you want to know that an iterator refers to a quad
	var offset int
	switch it.dir {
	case quad.Subject:
		offset = 0
	case quad.Predicate:
		offset = (hashSize * 2)
	case quad.Object:
		offset = (hashSize * 2) * 2
	case quad.Label:
		offset = (hashSize * 2) * 3
	}
	val := t.Hash[offset : offset+(hashSize*2)]
	if val == it.hash {
		return graph.ContainsLogOut(it, v, true)
	}
	return graph.ContainsLogOut(it, v, false)
}
開發者ID:e4x,項目名稱:cayley,代碼行數:34,代碼來源:iterator.go

示例2: NewAllIterator

func NewAllIterator(qs *QuadStore, kind string) *Iterator {
	if kind != nodeKind && kind != quadKind {
		glog.Error("Cannot create iterator for an unknown kind")
		return &Iterator{done: true}
	}
	if qs.context == nil {
		glog.Error("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:e4x,項目名稱:cayley,代碼行數:27,代碼來源:iterator.go

示例3: WriteHorizonAndSize

// WriteHorizonAndSize ??
func (qs *QuadStore) WriteHorizonAndSize(tx *lmdb.Txn) error {
	buf := new(bytes.Buffer)
	err := binary.Write(buf, binary.LittleEndian, qs.size)
	if err != nil {
		glog.Errorf("Couldn't convert size!")
		return err
	}
	werr := tx.Put(qs.metaDBI, []byte("size"), buf.Bytes(), 0)
	if werr != nil {
		glog.Error("Couldn't write size!")
		return werr
	}
	buf.Reset()
	err = binary.Write(buf, binary.LittleEndian, qs.horizon)

	if err != nil {
		glog.Errorf("Couldn't convert horizon!")
	}

	werr = tx.Put(qs.metaDBI, []byte("horizon"), buf.Bytes(), 0)

	if werr != nil {
		glog.Error("Couldn't write horizon!")
		return werr
	}
	return err
}
開發者ID:bmatsuo,項目名稱:cayley,代碼行數:28,代碼來源:quadstore.go

示例4: WriteHorizonAndSize

func (qs *QuadStore) WriteHorizonAndSize(tx *bolt.Tx) error {
	buf := new(bytes.Buffer)
	err := binary.Write(buf, binary.LittleEndian, qs.size)
	if err != nil {
		glog.Errorf("Couldn't convert size!")
		return err
	}
	b := tx.Bucket(metaBucket)
	b.FillPercent = localFillPercent
	werr := b.Put([]byte("size"), buf.Bytes())
	if werr != nil {
		glog.Error("Couldn't write size!")
		return werr
	}
	buf.Reset()
	err = binary.Write(buf, binary.LittleEndian, qs.horizon)

	if err != nil {
		glog.Errorf("Couldn't convert horizon!")
	}

	werr = b.Put([]byte("horizon"), buf.Bytes())

	if werr != nil {
		glog.Error("Couldn't write horizon!")
		return werr
	}
	return err
}
開發者ID:oliverp19,項目名稱:cayley,代碼行數:29,代碼來源:quadstore.go

示例5: Quad

func (qs *QuadStore) Quad(k graph.Value) quad.Quad {
	var d graph.Delta
	tok := k.(*Token)
	err := qs.db.View(func(tx *bolt.Tx) error {
		b := tx.Bucket(tok.bucket)
		data := b.Get(tok.key)
		if data == nil {
			return nil
		}
		var in IndexEntry
		err := json.Unmarshal(data, &in)
		if err != nil {
			return err
		}
		if len(in.History) == 0 {
			return nil
		}
		b = tx.Bucket(logBucket)
		data = b.Get(qs.createDeltaKeyFor(in.History[len(in.History)-1]))
		if data == nil {
			// No harm, no foul.
			return nil
		}
		return json.Unmarshal(data, &d)
	})
	if err != nil {
		glog.Error("Error getting quad: ", err)
		return quad.Quad{}
	}
	return d.Quad
}
開發者ID:oliverp19,項目名稱:cayley,代碼行數:31,代碼來源:quadstore.go

示例6: toArrayFunc

func toArrayFunc(env *otto.Otto, ses *Session, obj *otto.Object, withTags bool) func(otto.FunctionCall) otto.Value {
	return func(call otto.FunctionCall) otto.Value {
		it := buildIteratorTree(obj, ses.ts)
		it.Tagger().Add(TopResultTag)
		limit := -1
		if len(call.ArgumentList) > 0 {
			limitParsed, _ := call.Argument(0).ToInteger()
			limit = int(limitParsed)
		}
		var val otto.Value
		var err error
		if !withTags {
			array := runIteratorToArrayNoTags(it, ses, limit)
			val, err = call.Otto.ToValue(array)
		} else {
			array := runIteratorToArray(it, ses, limit)
			val, err = call.Otto.ToValue(array)
		}

		if err != nil {
			glog.Error(err)
			return otto.NullValue()
		}
		return val
	}
}
開發者ID:jacqui,項目名稱:cayley,代碼行數:26,代碼來源:finals.go

示例7: RemoveTriple

func (qs *TripleStore) RemoveTriple(t quad.Quad) {
	_, err := qs.db.Get(qs.createKeyFor(spo, t), qs.readopts)
	if err != nil && err != leveldb.ErrNotFound {
		glog.Error("Couldn't access DB to confirm deletion")
		return
	}
	if err == leveldb.ErrNotFound {
		// No such triple in the database, forget about it.
		return
	}
	batch := &leveldb.Batch{}
	batch.Delete(qs.createKeyFor(spo, t))
	batch.Delete(qs.createKeyFor(osp, t))
	batch.Delete(qs.createKeyFor(pos, t))
	qs.UpdateValueKeyBy(t.Get(quad.Subject), -1, batch)
	qs.UpdateValueKeyBy(t.Get(quad.Predicate), -1, batch)
	qs.UpdateValueKeyBy(t.Get(quad.Object), -1, batch)
	if t.Get(quad.Label) != "" {
		batch.Delete(qs.createProvKeyFor(pso, t))
		qs.UpdateValueKeyBy(t.Get(quad.Label), -1, batch)
	}
	err = qs.db.Write(batch, nil)
	if err != nil {
		glog.Errorf("Couldn't delete triple %s.", t)
		return
	}
	qs.size--
}
開發者ID:jacqui,項目名稱:cayley,代碼行數:28,代碼來源:triplestore.go

示例8: toValueFunc

func toValueFunc(env *otto.Otto, ses *Session, obj *otto.Object, withTags bool) func(otto.FunctionCall) otto.Value {
	return func(call otto.FunctionCall) otto.Value {
		it := buildIteratorTree(obj, ses.ts)
		it.Tagger().Add(TopResultTag)
		limit := 1
		var val otto.Value
		var err error
		if !withTags {
			array := runIteratorToArrayNoTags(it, ses, limit)
			if len(array) < 1 {
				return otto.NullValue()
			}
			val, err = call.Otto.ToValue(array[0])
		} else {
			array := runIteratorToArray(it, ses, limit)
			if len(array) < 1 {
				return otto.NullValue()
			}
			val, err = call.Otto.ToValue(array[0])
		}
		if err != nil {
			glog.Error(err)
			return otto.NullValue()
		} else {
			return val
		}

	}
}
開發者ID:jacqui,項目名稱:cayley,代碼行數:29,代碼來源:finals.go

示例9: NewIterator

func NewIterator(prefix string, d quad.Direction, value graph.Value, qs *QuadStore) *Iterator {
	vb := value.(Token)
	p := make([]byte, 0, 2+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()
		glog.Error("Opening LevelDB iterator couldn't seek to location ", it.nextPrefix)
	}

	return &it
}
開發者ID:lytics,項目名稱:cayley,代碼行數:31,代碼來源:iterator.go

示例10: Size

func (ts *TripleStore) Size() int64 {
	count, err := ts.db.C("triples").Count()
	if err != nil {
		glog.Error("Error: ", err)
		return 0
	}
	return int64(count)
}
開發者ID:henfee,項目名稱:cayley,代碼行數:8,代碼來源:triplestore.go

示例11: Quad

func (qs *QuadStore) Quad(k graph.Value) quad.Quad {
	var q quad.Quad
	b, err := qs.db.Get(k.(Token), qs.readopts)
	if err != nil && err != leveldb.ErrNotFound {
		glog.Error("Error: could not get quad from DB.")
		return quad.Quad{}
	}
	if err == leveldb.ErrNotFound {
		// No harm, no foul.
		return quad.Quad{}
	}
	err = json.Unmarshal(b, &q)
	if err != nil {
		glog.Error("Error: could not reconstruct quad.")
		return quad.Quad{}
	}
	return q
}
開發者ID:e4x,項目名稱:cayley,代碼行數:18,代碼來源:quadstore.go

示例12: Quad

func (qs *TripleStore) Quad(k graph.Value) quad.Quad {
	var triple quad.Quad
	b, err := qs.db.Get(k.(Token), qs.readopts)
	if err != nil && err != leveldb.ErrNotFound {
		glog.Error("Error: couldn't get triple from DB.")
		return quad.Quad{}
	}
	if err == leveldb.ErrNotFound {
		// No harm, no foul.
		return quad.Quad{}
	}
	err = json.Unmarshal(b, &triple)
	if err != nil {
		glog.Error("Error: couldn't reconstruct triple.")
		return quad.Quad{}
	}
	return triple
}
開發者ID:Joeento,項目名稱:cayley,代碼行數:18,代碼來源:triplestore.go

示例13: Next

func (it *AllIterator) Next() bool {
	if it.done {
		return false
	}
	if len(it.buffer) <= it.offset+1 {
		it.offset = 0
		var last []byte
		if it.buffer != nil {
			last = it.buffer[len(it.buffer)-1]
		}
		it.buffer = make([][]byte, 0, bufferSize)
		err := it.qs.db.View(func(tx *bolt.Tx) error {
			i := 0
			b := tx.Bucket(it.bucket)
			cur := b.Cursor()
			if last == nil {
				k, _ := cur.First()
				var out []byte
				out = make([]byte, len(k))
				copy(out, k)
				it.buffer = append(it.buffer, out)
				i++
			} else {
				k, _ := cur.Seek(last)
				if !bytes.Equal(k, last) {
					return fmt.Errorf("could not pick up after %v", k)
				}
			}
			for i < bufferSize {
				k, _ := cur.Next()
				if k == nil {
					it.buffer = append(it.buffer, k)
					break
				}
				var out []byte
				out = make([]byte, len(k))
				copy(out, k)
				it.buffer = append(it.buffer, out)
				i++
			}
			return nil
		})
		if err != nil {
			glog.Error("Error nexting in database: ", err)
			it.err = err
			it.done = true
			return false
		}
	} else {
		it.offset++
	}
	if it.Result() == nil {
		it.done = true
		return false
	}
	return true
}
開發者ID:e4x,項目名稱:cayley,代碼行數:57,代碼來源:all_iterator.go

示例14: ApplyDeltas

func (qs *QuadStore) ApplyDeltas(deltas []graph.Delta) error {
	oldSize := qs.size
	oldHorizon := qs.horizon
	err := qs.db.Update(func(tx *bolt.Tx) error {
		b := tx.Bucket(logBucket)
		b.FillPercent = localFillPercent
		resizeMap := make(map[string]int64)
		sizeChange := int64(0)
		for _, d := range deltas {
			bytes, err := json.Marshal(d)
			if err != nil {
				return err
			}
			err = b.Put(qs.createDeltaKeyFor(d.ID), bytes)
			if err != nil {
				return err
			}
		}
		for _, d := range deltas {
			err := qs.buildQuadWrite(tx, d.Quad, d.ID, d.Action == graph.Add)
			if err != nil {
				return err
			}
			delta := int64(1)
			if d.Action == graph.Delete {
				delta = int64(-1)
			}
			resizeMap[d.Quad.Subject] += delta
			resizeMap[d.Quad.Predicate] += delta
			resizeMap[d.Quad.Object] += delta
			if d.Quad.Label != "" {
				resizeMap[d.Quad.Label] += delta
			}
			sizeChange += delta
			qs.horizon = d.ID
		}
		for k, v := range resizeMap {
			if v != 0 {
				err := qs.UpdateValueKeyBy(k, v, tx)
				if err != nil {
					return err
				}
			}
		}
		qs.size += sizeChange
		return qs.WriteHorizonAndSize(tx)
	})

	if err != nil {
		glog.Error("Couldn't write to DB for Delta set. Error: ", err)
		qs.horizon = oldHorizon
		qs.size = oldSize
		return err
	}
	return nil
}
開發者ID:ericcapricorn,項目名稱:cayley,代碼行數:56,代碼來源:quadstore.go

示例15: buildQuadWrite

func (qs *QuadStore) buildQuadWrite(tx *bolt.Tx, q quad.Quad, id int64, isAdd bool) error {
	var entry IndexEntry
	b := tx.Bucket(spoBucket)
	b.FillPercent = localFillPercent
	data := b.Get(qs.createKeyFor(spo, q))
	if data != nil {
		// We got something.
		err := json.Unmarshal(data, &entry)
		if err != nil {
			return err
		}
	}

	if isAdd && len(entry.History)%2 == 1 {
		glog.Error("Adding a valid quad ", entry)
		return graph.ErrQuadExists
	}
	if !isAdd && len(entry.History)%2 == 0 {
		glog.Error("Deleting an invalid quad ", entry)
		return graph.ErrQuadNotExist
	}

	entry.History = append(entry.History, id)

	jsonbytes, err := json.Marshal(entry)
	if err != nil {
		glog.Errorf("Couldn't write to buffer for entry %#v: %s", entry, err)
		return err
	}
	for _, index := range [][4]quad.Direction{spo, osp, pos, cps} {
		if index == cps && q.Get(quad.Label) == "" {
			continue
		}
		b := tx.Bucket(bucketFor(index))
		b.FillPercent = localFillPercent
		err = b.Put(qs.createKeyFor(index, q), jsonbytes)
		if err != nil {
			return err
		}
	}
	return nil
}
開發者ID:ericcapricorn,項目名稱:cayley,代碼行數:42,代碼來源:quadstore.go


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