ReadInto reads contents in simplecolumn format into a fact store.
(r io.Reader, store FactStore)
| 413 | |
| 414 | // ReadInto reads contents in simplecolumn format into a fact store. |
| 415 | func (sc SimpleColumn) ReadInto(r io.Reader, store FactStore) error { |
| 416 | scanner := bufio.NewScanner(r) |
| 417 | |
| 418 | preds, predNumFacts, err := readHeader(scanner) |
| 419 | if err != nil { |
| 420 | return err |
| 421 | } |
| 422 | for i, p := range preds { |
| 423 | if p.Arity == 0 { |
| 424 | store.Add(ast.Atom{p, nil}) |
| 425 | continue |
| 426 | } |
| 427 | numFacts := predNumFacts[i] |
| 428 | if err = sc.readPred(scanner, p, numFacts, nil, func(args []ast.BaseTerm) error { |
| 429 | store.Add(ast.Atom{p, args}) |
| 430 | return nil |
| 431 | }); err != nil { |
| 432 | return err |
| 433 | } |
| 434 | } |
| 435 | return nil |
| 436 | } |
| 437 | |
| 438 | // percentEscape escapes a string following RFC 3986. |
| 439 | func percentEscape(s string) string { |