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

Method Tokenizer

schema/schema.go:335–363  ·  view source on GitHub ↗

Tokenizer returns the tokenizer for given predicate

(ctx context.Context, pred string)

Source from the content-addressed store, hash-verified

333
334// Tokenizer returns the tokenizer for given predicate
335func (s *state) Tokenizer(ctx context.Context, pred string) []tok.Tokenizer {
336 isWrite, _ := ctx.Value(IsWrite).(bool)
337 s.RLock()
338 defer s.RUnlock()
339 var su *pb.SchemaUpdate
340 if isWrite {
341 if schema, ok := s.mutSchema[pred]; ok {
342 su = schema
343 }
344 }
345 if su == nil {
346 if schema, ok := s.predicate[pred]; ok {
347 su = schema
348 }
349 }
350 if su == nil {
351 // This may happen when some query that needs indexing over this predicate is executing
352 // while the predicate is dropped from the state (using drop operation).
353 glog.Errorf("Schema state not found for %s.", pred)
354 return nil
355 }
356 tokenizers := make([]tok.Tokenizer, 0, len(su.Tokenizer))
357 for _, it := range su.Tokenizer {
358 t, found := tok.GetTokenizer(it)
359 x.AssertTruef(found, "Invalid tokenizer %s", it)
360 tokenizers = append(tokenizers, t)
361 }
362 return tokenizers
363}
364
365// FactoryCreateSpec(ctx, pred) returns the list of versioned
366// FactoryCreateSpec instances for given predicate.

Callers 12

TokenizerNamesMethod · 0.95
HasTokenizerMethod · 0.95
validateMutationFunction · 0.80
sortWithIndexFunction · 0.80
verifyStringIndexFunction · 0.80
verifyCustomIndexFunction · 0.80
pickTokenizerFunction · 0.80
addIndexMutationsMethod · 0.80
handleDeleteAllMethod · 0.80
AddMutationWithIndexMethod · 0.80
indexTokensForTestFunction · 0.80
TestSchemaIndexCustomFunction · 0.80

Calls 6

GetTokenizerFunction · 0.92
AssertTruefFunction · 0.92
RLockMethod · 0.80
RUnlockMethod · 0.80
ValueMethod · 0.45
ErrorfMethod · 0.45

Tested by 2

indexTokensForTestFunction · 0.64
TestSchemaIndexCustomFunction · 0.64