MCPcopy Create free account
hub / github.com/brimdata/super / LookupTypeMap

Method LookupTypeMap

context.go:221–240  ·  view source on GitHub ↗
(keyType, valType Type)

Source from the content-addressed store, hash-verified

219}
220
221func (c *Context) LookupTypeMap(keyType, valType Type) *TypeMap {
222 key := keyPool.Get().(*[]byte)
223 bytes := (*key)[:0]
224 bytes = binary.LittleEndian.AppendUint32(bytes, uint32(TypeID(keyType)))
225 bytes = binary.LittleEndian.AppendUint32(bytes, uint32(TypeID(valType)))
226 *key = bytes
227 c.mu.Lock()
228 defer c.mu.Unlock()
229 if c.maps == nil {
230 c.maps = make(map[string]*TypeMap)
231 }
232 if typ, ok := c.maps[string(bytes)]; ok {
233 keyPool.Put(key)
234 return typ
235 }
236 typ := NewTypeMap(c.nextIDWithLock(), keyType, valType)
237 c.enterWithLock(typ)
238 c.maps[string(bytes)] = typ
239 return typ
240}
241
242func (c *Context) LookupTypeUnion(types []Type) *TypeUnion {
243 sort.SliceStable(types, func(i, j int) bool {

Callers 15

DecodeTypeValueMethod · 0.95
exprMethod · 0.80
exprMethod · 0.80
convertMapMethod · 0.80
convertTypeMapMethod · 0.80
encodeMapMethod · 0.80
lookupTypeMethod · 0.80
projectMethod · 0.80
EvalMethod · 0.80
evalMethod · 0.80
EvalMethod · 0.80
evalMethod · 0.80

Calls 6

nextIDWithLockMethod · 0.95
enterWithLockMethod · 0.95
TypeIDFunction · 0.85
NewTypeMapFunction · 0.85
GetMethod · 0.65
PutMethod · 0.65

Tested by

no test coverage detected