本文整理汇总了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;未经允许,请勿转载。 |
请发表评论