MCPcopy Index your code
hub / github.com/google/mangle / ReadInto

Method ReadInto

factstore/simplecolumn.go:415–436  ·  view source on GitHub ↗

ReadInto reads contents in simplecolumn format into a fact store.

(r io.Reader, store FactStore)

Source from the content-addressed store, hash-verified

413
414// ReadInto reads contents in simplecolumn format into a fact store.
415func (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.
439func percentEscape(s string) string {

Callers 1

TestRoundTripFunction · 0.95

Calls 3

readPredMethod · 0.95
readHeaderFunction · 0.85
AddMethod · 0.65

Tested by 1

TestRoundTripFunction · 0.76