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

Function generateKey

x/keys.go:154–165  ·  view source on GitHub ↗

genKey creates the key and writes the initial bytes (type byte, length of attribute, and the attribute itself). It leaves the rest of the key empty for further processing if necessary. It also returns next index from where further processing should be done.

(typeByte byte, attr string, extra int)

Source from the content-addressed store, hash-verified

152// and the attribute itself). It leaves the rest of the key empty for further processing
153// if necessary. It also returns next index from where further processing should be done.
154func generateKey(typeByte byte, attr string, extra int) ([]byte, int) {
155 // Separate namespace and attribute from attr and write namespace in the first 8 bytes of key.
156 namespace, attr := ParseNamespaceBytes(attr)
157 prefixLen := 1 + 8 + 2 + len(attr) // byteType + ns + len(pred) + pred
158 buf := make([]byte, prefixLen+extra)
159 buf[0] = typeByte
160 AssertTrue(copy(buf[1:], namespace) == 8)
161 rest := buf[9:]
162
163 writeAttr(rest, attr)
164 return buf, prefixLen
165}
166
167// SchemaKey returns schema key for given attribute. Schema keys are stored
168// separately with unique prefix, since we need to iterate over all schema keys.

Callers 13

SchemaKeyFunction · 0.70
TypeKeyFunction · 0.70
DataKeyFunction · 0.70
ReverseKeyFunction · 0.70
IndexKeyAfterAllTermsFunction · 0.70
IndexKeyFunction · 0.70
CountKeyFunction · 0.70
SkipPredicateMethod · 0.70
DataPrefixMethod · 0.70
IndexPrefixMethod · 0.70
ReversePrefixMethod · 0.70
CountPrefixMethod · 0.70

Calls 4

copyFunction · 0.85
ParseNamespaceBytesFunction · 0.70
AssertTrueFunction · 0.70
writeAttrFunction · 0.70

Tested by

no test coverage detected