MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / parseNamespace

Function parseNamespace

schema/parse.go:581–600  ·  view source on GitHub ↗
(it *lex.ItemIterator)

Source from the content-addressed store, hash-verified

579}
580
581func parseNamespace(it *lex.ItemIterator) (uint64, error) {
582 nextItems, err := it.Peek(2)
583 if err != nil {
584 return 0, errors.Errorf("Unable to peek: %v", err)
585 }
586 if nextItems[0].Typ != itemNumber || nextItems[1].Typ != itemRightSquare {
587 return 0, errors.Errorf("Typed oes not match the expected")
588 }
589 ns, err := strconv.ParseUint(nextItems[0].Val, 0, 64)
590 if err != nil {
591 return 0, err
592 }
593 it.Next()
594 it.Next()
595 // We have parsed the namespace. Now move to the next item.
596 if !it.Next() {
597 return 0, errors.Errorf("No schema found after namespace. Got: %v", nextItems[0])
598 }
599 return ns, nil
600}
601
602// ParsedSchema represents the parsed schema and type updates.
603type ParsedSchema struct {

Callers 1

parseFunction · 0.85

Calls 3

PeekMethod · 0.45
ErrorfMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected