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

Function indexMap

runtime/sam/expr/eval.go:761–781  ·  view source on GitHub ↗
(sctx *super.Context, typ *super.TypeMap, mapBytes scode.Bytes, key super.Value)

Source from the content-addressed store, hash-verified

759}
760
761func indexMap(sctx *super.Context, typ *super.TypeMap, mapBytes scode.Bytes, key super.Value) super.Value {
762 if key.IsMissing() {
763 return sctx.Missing()
764 }
765 if key.Type() != typ.KeyType {
766 if union, ok := super.TypeUnder(typ.KeyType).(*super.TypeUnion); ok {
767 if tag := union.TagOf(key.Type()); tag >= 0 {
768 var b scode.Builder
769 super.BuildUnion(&b, union.TagOf(key.Type()), key.Bytes())
770 if valBytes, ok := lookupKey(mapBytes, b.Bytes().Body()); ok {
771 return deunion(typ.ValType, valBytes)
772 }
773 }
774 }
775 return sctx.Missing()
776 }
777 if valBytes, ok := lookupKey(mapBytes, key.Bytes()); ok {
778 return deunion(typ.ValType, valBytes)
779 }
780 return sctx.Missing()
781}
782
783func deunion(typ super.Type, b scode.Bytes) super.Value {
784 if union, ok := typ.(*super.TypeUnion); ok {

Callers 2

EvalMethod · 0.70
EvalMethod · 0.70

Calls 11

BytesMethod · 0.95
TypeUnderFunction · 0.92
BuildUnionFunction · 0.92
lookupKeyFunction · 0.85
MissingMethod · 0.80
TagOfMethod · 0.80
BodyMethod · 0.80
deunionFunction · 0.70
TypeMethod · 0.65
IsMissingMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected