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 }
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 } err = qw.RemoveQuad(t) if err != nil { return err } } return nil }