parseTokenOptions(it, factory) will parse "TokenOptions" according to the following grammar: TokenOptions ::= ['(' TokenOptionList ')'] TokenOptionList ::= TokenOption [',' TokenOptionList ] TODO: TokenOptionList could be made optional so that "hnsw()" is treated as an hnsw index with default se
(it *lex.ItemIterator, factory tok.IndexFactory)
| 337 | // a VectorIndex. The factory is used to validate that any option name given |
| 338 | // is specified as an AllowedOption. |
| 339 | func parseTokenOptions(it *lex.ItemIterator, factory tok.IndexFactory) ([]*pb.OptionPair, error) { |
| 340 | retVal := []*pb.OptionPair{} |
| 341 | nextItem, found := it.PeekOne() |
| 342 | if !found { |
| 343 | return nil, nextItem.Errorf( |
| 344 | "unexpected end of stream when looking for IndexFactory options") |
| 345 | } |
| 346 | if nextItem.Typ == itemComma || nextItem.Typ == itemRightRound { |
| 347 | return []*pb.OptionPair{}, nil |
| 348 | } |
| 349 | if nextItem.Typ != itemLeftRound { |
| 350 | return nil, nextItem.Errorf( |
| 351 | "unexpected '%s' found when expecting '('", nextItem.Val) |
| 352 | } |
| 353 | it.Next() // Reads initial '(' |
| 354 | for { |
| 355 | optPair, err := parseTokenOption(it, factory) |
| 356 | if err != nil { |
| 357 | return retVal, err |
| 358 | } |
| 359 | retVal = append(retVal, optPair) |
| 360 | it.Next() |
| 361 | nextItem = it.Item() |
| 362 | if nextItem.Typ == itemRightRound { |
| 363 | return retVal, nil |
| 364 | } |
| 365 | if nextItem.Typ != itemComma { |
| 366 | return nil, nextItem.Errorf( |
| 367 | "unexpected '%s' found when expecting ',' or ')'", |
| 368 | nextItem.Val) |
| 369 | } |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | // parseTokenOption(it, factory) constructs OptionPair instances |
| 374 | // and validates that the options are okay via the factory. |
no test coverage detected