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

Function pickFactoryCreateSpec

worker/tokens.go:128–145  ·  view source on GitHub ↗

pickFactoryCreateSpec(ctx, attr) will find the FactoryCreateSpec (i.e., index name + options) for the given attribute "attr". Note that unlike pickTokenizer(ctx, attr, f), we do not include the parameter "f" (for function name), as we do not take action with it. This is otherwise similar to pickToke

(ctx context.Context, attr string)

Source from the content-addressed store, hash-verified

126// parameter "f" (for function name), as we do not take action with it.
127// This is otherwise similar to pickTokenizer.
128func pickFactoryCreateSpec(ctx context.Context, attr string) (*tok.FactoryCreateSpec, error) {
129 // Get the tokenizers and choose the corresponding one.
130 if !schema.State().IsIndexed(ctx, attr) {
131 return nil, errors.Errorf("Attribute %s is not indexed.", attr)
132 }
133
134 cspecs, err := schema.State().FactoryCreateSpec(ctx, attr)
135 if err != nil {
136 return nil, err
137 }
138 if len(cspecs) == 0 {
139 return nil, errors.Errorf("Schema state not found for %s.", attr)
140 }
141
142 // At the moment, it would only be relevant to consider the first one.
143 // This is similar to pickTokenizer in behavior.
144 return cspecs[0], nil
145}
146
147// getInequalityTokens gets tokens ge/le/between compared to given tokens using the first sortable
148// index that is found for the predicate.

Callers 1

handleValuePostingsMethod · 0.85

Calls 4

StateFunction · 0.92
IsIndexedMethod · 0.80
FactoryCreateSpecMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected