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

Method idForAttr

query/outputnode.go:198–209  ·  view source on GitHub ↗
(attr string)

Source from the content-addressed store, hash-verified

196}
197
198func (enc *encoder) idForAttr(attr string) uint16 {
199 if attr == "uid" && enc.uidAttr > 0 {
200 return enc.uidAttr
201 }
202 if id, ok := enc.attrMap[attr]; ok {
203 return id
204 }
205
206 enc.idSlice = append(enc.idSlice, attr)
207 enc.attrMap[attr] = uint16(len(enc.idSlice) - 1) // TODO(Ashish): check for overflow.
208 return uint16(len(enc.idSlice) - 1)
209}
210
211func (enc *encoder) attrForID(id uint16) string {
212 // For now we are not returning error from here.

Callers 15

newEncoderFunction · 0.95
attachFacetsMethod · 0.95
newGraphQLEncoderFunction · 0.80
encodeMethod · 0.80
writeCustomFieldMethod · 0.80
initChildAttrIdMethod · 0.80
processCustomFieldsMethod · 0.80
resolveNestedFieldsMethod · 0.80
TestEncodeFunction · 0.80
addGroupbyMethod · 0.80
addAggregationsMethod · 0.80
handleCountUIDNodesMethod · 0.80

Calls

no outgoing calls

Tested by 5

TestEncodeFunction · 0.64
TestEncodeMemoryFunction · 0.64
TestNormalizeJSONLimitFunction · 0.64
buildTestTreeFunction · 0.64