本文整理匯總了Golang中github.com/google/cayley/graph.QuadWriter類的典型用法代碼示例。如果您正苦於以下問題:Golang QuadWriter類的具體用法?Golang QuadWriter怎麽用?Golang QuadWriter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了QuadWriter類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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
}
示例2: remove
func remove(qw graph.QuadWriter, cfg *config.Config, dec quad.Unmarshaler) error {
for {
t, err := dec.Unmarshal()
if err != nil {
if err == io.EOF {
break
}
return err
}
qw.RemoveQuad(t)
}
return nil
}
示例3: remove
func remove(qw graph.QuadWriter, cfg *config.Config, dec quad.Reader) error {
for {
t, err := dec.ReadQuad()
if err != nil {
if err == io.EOF {
break
}
return err
}
err = qw.RemoveQuad(t)
if err != nil {
return err
}
}
return nil
}
示例4: Load
func Load(qw graph.QuadWriter, cfg *config.Config, dec quad.Unmarshaler) error {
block := make([]quad.Quad, 0, cfg.LoadSize)
for {
t, err := dec.Unmarshal()
if err != nil {
if err == io.EOF {
break
}
return err
}
block = append(block, t)
if len(block) == cap(block) {
qw.AddQuadSet(block)
block = block[:0]
}
}
qw.AddQuadSet(block)
return nil
}