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


Golang proto.LogDelta類代碼示例

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


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

示例1: Quad

func (qs *QuadStore) Quad(k graph.Value) quad.Quad {
	var d proto.LogDelta
	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 proto.HistoryEntry
		err := in.Unmarshal(data)
		if err != nil {
			return err
		}
		if len(in.History) == 0 {
			return nil
		}
		b = tx.Bucket(logBucket)
		data = b.Get(qs.createDeltaKeyFor(int64(in.History[len(in.History)-1])))
		if data == nil {
			// No harm, no foul.
			return nil
		}
		return d.Unmarshal(data)
	})
	if err != nil {
		clog.Errorf("Error getting quad: %v", err)
		return quad.Quad{}
	}
	return d.Quad.ToNative()
}
開發者ID:rlugojr,項目名稱:cayley,代碼行數:31,代碼來源:quadstore.go

示例2: deltaToProto

func deltaToProto(delta graph.Delta) proto.LogDelta {
	var newd proto.LogDelta
	newd.ID = uint64(delta.ID.Int())
	newd.Action = int32(delta.Action)
	newd.Timestamp = delta.Timestamp.UnixNano()
	newd.Quad = proto.MakeQuad(delta.Quad)
	return newd
}
開發者ID:rlugojr,項目名稱:cayley,代碼行數:8,代碼來源:quadstore.go

示例3: upgrade2To3

func upgrade2To3(db *bolt.DB) error {
	fmt.Println("Upgrading v2 to v3...")
	tx, err := db.Begin(true)
	if err != nil {
		return err
	}
	defer tx.Rollback()
	fmt.Println("Upgrading bucket", string(logBucket))
	lb := tx.Bucket(logBucket)
	c := lb.Cursor()
	for k, v := c.First(); k != nil; k, v = c.Next() {
		var delta proto.LogDelta
		err := delta.Unmarshal(v)
		if err != nil {
			return err
		}
		delta.Quad.Upgrade()
		data, err := delta.Marshal()
		if err != nil {
			return err
		}
		lb.Put(k, data)
	}
	if err := tx.Commit(); err != nil {
		return err
	}
	tx, err = db.Begin(true)
	if err != nil {
		return err
	}
	defer tx.Rollback()
	fmt.Println("Upgrading bucket", string(nodeBucket))
	nb := tx.Bucket(nodeBucket)
	c = nb.Cursor()
	for k, v := c.First(); k != nil; k, v = c.Next() {
		var vd proto.NodeData
		err := vd.Unmarshal(v)
		if err != nil {
			return err
		}
		vd.Upgrade()
		data, err := vd.Marshal()
		if err != nil {
			return err
		}
		nb.Put(k, data)
	}
	if err := tx.Commit(); err != nil {
		return err
	}
	return nil
}
開發者ID:rlugojr,項目名稱:cayley,代碼行數:52,代碼來源:migrate.go

示例4: deltaToProto

func deltaToProto(delta graph.Delta) proto.LogDelta {
	var newd proto.LogDelta
	newd.ID = uint64(delta.ID.Int())
	newd.Action = int32(delta.Action)
	newd.Timestamp = delta.Timestamp.UnixNano()
	newd.Quad = &proto.Quad{
		Subject:   delta.Quad.Subject,
		Predicate: delta.Quad.Predicate,
		Object:    delta.Quad.Object,
		Label:     delta.Quad.Label,
	}
	return newd
}
開發者ID:RamboWANG,項目名稱:cayley,代碼行數:13,代碼來源:quadstore.go


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