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

Method DecodeTypeValue

context.go:421–579  ·  view source on GitHub ↗
(tv scode.Bytes)

Source from the content-addressed store, hash-verified

419}
420
421func (c *Context) DecodeTypeValue(tv scode.Bytes) (Type, scode.Bytes) {
422 if len(tv) == 0 {
423 return nil, nil
424 }
425 id := tv[0]
426 tv = tv[1:]
427 switch id {
428 case TypeValueNameDef:
429 name, tv := DecodeName(tv)
430 if tv == nil {
431 return nil, nil
432 }
433 var typ Type
434 typ, tv = c.DecodeTypeValue(tv)
435 if tv == nil {
436 return nil, nil
437 }
438 named, err := c.LookupTypeNamed(name, typ)
439 if err != nil {
440 return nil, nil
441 }
442 return named, tv
443 case TypeValueNameRef:
444 name, tv := DecodeName(tv)
445 if tv == nil {
446 return nil, nil
447 }
448 typ := c.LookupTypeDef(name)
449 if typ == nil {
450 return nil, nil
451 }
452 return typ, tv
453 case TypeValueRecord:
454 n, tv := DecodeLength(tv)
455 if tv == nil || n > MaxRecordFields {
456 return nil, nil
457 }
458 fields := make([]Field, 0, n)
459 optlen := (n + 7) >> 3
460 if optlen > len(tv) {
461 return nil, nil
462 }
463 opts := tv[:optlen]
464 tv = tv[optlen:]
465 for k := range n {
466 var name string
467 name, tv = DecodeName(tv)
468 if tv == nil {
469 return nil, nil
470 }
471 var typ Type
472 typ, tv = c.DecodeTypeValue(tv)
473 if tv == nil {
474 return nil, nil
475 }
476 fields = append(fields, Field{name, typ, scode.TestBit(opts, k)})
477 }
478 typ, err := c.LookupTypeRecord(fields)

Callers 4

LookupByValueMethod · 0.95
compareValuesFunction · 0.95
evalMethod · 0.80
evalTypeOfTypeMethod · 0.80

Calls 14

LookupTypeNamedMethod · 0.95
LookupTypeDefMethod · 0.95
LookupTypeRecordMethod · 0.95
LookupTypeArrayMethod · 0.95
LookupTypeSetMethod · 0.95
LookupTypeMapMethod · 0.95
LookupTypeUnionMethod · 0.95
LookupTypeEnumMethod · 0.95
LookupTypeErrorMethod · 0.95
LookupTypeFusionMethod · 0.95
TestBitFunction · 0.92
DecodeNameFunction · 0.85

Tested by

no test coverage detected