FactoryCreateSpec(ctx, pred) returns the list of versioned FactoryCreateSpec instances for given predicate. The FactoryCreateSpec type defines the IndexFactory instance(s) for given predicate along with their options, if specified.
(ctx context.Context, pred string)
| 367 | // The FactoryCreateSpec type defines the IndexFactory instance(s) |
| 368 | // for given predicate along with their options, if specified. |
| 369 | func (s *state) FactoryCreateSpec(ctx context.Context, pred string) ([]*tok.FactoryCreateSpec, error) { |
| 370 | isWrite, _ := ctx.Value(IsWrite).(bool) |
| 371 | s.RLock() |
| 372 | defer s.RUnlock() |
| 373 | var su *pb.SchemaUpdate |
| 374 | if isWrite { |
| 375 | if schema, ok := s.mutSchema[pred]; ok { |
| 376 | su = schema |
| 377 | } |
| 378 | } |
| 379 | if su == nil { |
| 380 | if schema, ok := s.predicate[pred]; ok { |
| 381 | su = schema |
| 382 | } |
| 383 | } |
| 384 | if su == nil { |
| 385 | // This may happen when some query that needs indexing over this predicate is executing |
| 386 | // while the predicate is dropped from the state (using drop operation). |
| 387 | glog.Errorf("Schema state not found for %s.", pred) |
| 388 | return nil, errors.Errorf("Schema state not found for %s.", pred) |
| 389 | } |
| 390 | creates := make([]*tok.FactoryCreateSpec, 0, len(su.IndexSpecs)) |
| 391 | for _, vs := range su.IndexSpecs { |
| 392 | c, err := tok.GetFactoryCreateSpecFromSpec(vs) |
| 393 | if err != nil { |
| 394 | return nil, err |
| 395 | } |
| 396 | creates = append(creates, c) |
| 397 | } |
| 398 | return creates, nil |
| 399 | } |
| 400 | |
| 401 | // VectorIndexNames returns the indexes for given predicate |
| 402 | func (s *state) VectorIndexes(ctx context.Context, pred string) []string { |
no test coverage detected