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

Function parseTokenOption

schema/parse.go:379–404  ·  view source on GitHub ↗

parseTokenOption(it, factory) constructs OptionPair instances and validates that the options are okay via the factory. TokenOption ::= OptionName ':' OptionValue OptionName ::= {itemText from Lexer} OptionValue ::= {itemQuotedText from Lexer}

(it *lex.ItemIterator, factory tok.IndexFactory)

Source from the content-addressed store, hash-verified

377// OptionName ::= {itemText from Lexer}
378// OptionValue ::= {itemQuotedText from Lexer}
379func parseTokenOption(it *lex.ItemIterator, factory tok.IndexFactory) (*pb.OptionPair, error) {
380 it.Next()
381 nextItem := it.Item()
382 if nextItem.Typ != itemText {
383 return nil, nextItem.Errorf(
384 "unexpected '%s' found when expecting option name",
385 nextItem.Val)
386 }
387 optName := nextItem.Val
388 it.Next()
389 nextItem = it.Item()
390 if nextItem.Typ != itemColon {
391 return nil, nextItem.Errorf(
392 "unexpected '%s' found when expecting ':'",
393 nextItem.Val)
394 }
395 it.Next()
396 nextItem = it.Item()
397 if nextItem.Typ != itemQuotedText {
398 return nil, nextItem.Errorf(
399 "unexpected '%s' found when expecting quoted text",
400 nextItem.Val)
401 }
402 optVal := nextItem.Val[1 : len(nextItem.Val)-1]
403 return &pb.OptionPair{Key: optName, Value: optVal}, nil
404}
405
406func HasTokenizerOrVectorIndexSpec(update *pb.SchemaUpdate) bool {
407 if update == nil {

Callers 1

parseTokenOptionsFunction · 0.85

Calls 3

ItemMethod · 0.80
NextMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected