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

Method LookupTypeUnion

context.go:242–265  ·  view source on GitHub ↗
(types []Type)

Source from the content-addressed store, hash-verified

240}
241
242func (c *Context) LookupTypeUnion(types []Type) *TypeUnion {
243 sort.SliceStable(types, func(i, j int) bool {
244 return CompareTypes(types[i], types[j]) < 0
245 })
246 key := keyPool.Get().(*[]byte)
247 bytes := (*key)[:0]
248 for _, typ := range types {
249 bytes = binary.LittleEndian.AppendUint32(bytes, uint32(TypeID(typ)))
250 }
251 *key = bytes
252 c.mu.Lock()
253 defer c.mu.Unlock()
254 if c.unions == nil {
255 c.unions = make(map[string]*TypeUnion)
256 }
257 if typ, ok := c.unions[string(bytes)]; ok {
258 keyPool.Put(key)
259 return typ
260 }
261 typ := NewTypeUnion(c.nextIDWithLock(), slices.Clone(types))
262 c.enterWithLock(typ)
263 c.unions[string(bytes)] = typ
264 return typ
265}
266
267func (c *Context) LookupTypeEnum(symbols []string) *TypeEnum {
268 key := keyPool.Get().(*[]byte)

Callers 15

DecodeTypeValueMethod · 0.95
NullableMethod · 0.95
NewUnionFromDynamicFunction · 0.80
dropPathMethod · 0.80
normalizeElemsMethod · 0.80
convertTypeUnionMethod · 0.80
encodeArrayMethod · 0.80
projectMethod · 0.80
buildMethod · 0.80
evalMethod · 0.80
buildListFunction · 0.80
dequietMethod · 0.80

Calls 8

nextIDWithLockMethod · 0.95
enterWithLockMethod · 0.95
CompareTypesFunction · 0.85
TypeIDFunction · 0.85
NewTypeUnionFunction · 0.85
GetMethod · 0.65
PutMethod · 0.65
CloneMethod · 0.65

Tested by

no test coverage detected