MCPcopy
hub / github.com/dgraph-io/dgraph / FactoryCreateSpec

Method FactoryCreateSpec

schema/schema.go:369–399  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

367// The FactoryCreateSpec type defines the IndexFactory instance(s)
368// for given predicate along with their options, if specified.
369func (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
402func (s *state) VectorIndexes(ctx context.Context, pred string) []string {

Callers 4

VectorIndexesMethod · 0.95
pickFactoryCreateSpecFunction · 0.80
addIndexMutationsMethod · 0.80
handleDeleteAllMethod · 0.80

Calls 5

RLockMethod · 0.80
RUnlockMethod · 0.80
ValueMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected