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

Function NewConstFromValue

vector/const.go:74–96  ·  view source on GitHub ↗
(val super.Value, length uint32)

Source from the content-addressed store, hash-verified

72}
73
74func NewConstFromValue(val super.Value, length uint32) *Const {
75 switch id := val.Type().ID(); {
76 case super.IsUnsigned(id):
77 return NewConstUint(val.Type(), val.Uint(), length)
78 case super.IsSigned(id):
79 return NewConstInt(val.Type(), val.Int(), length)
80 case super.IsFloat(id):
81 return NewConstFloat(val.Type(), val.Float(), length)
82 case id == super.IDBool:
83 return NewConstBool(val.Bool(), length)
84 case id == super.IDBytes:
85 return NewConstBytes(val.Bytes(), length)
86 case id == super.IDString:
87 return NewConstString(string(val.Bytes()), length)
88 case id == super.IDIP:
89 return NewConstIP(super.DecodeIP(val.Bytes()), length)
90 case id == super.IDNet:
91 return NewConstNet(super.DecodeNet(val.Bytes()), length)
92 case id == super.IDType:
93 return NewConstType(val.Bytes(), length)
94 }
95 panic(fmt.Sprintf("%#v\n", super.TypeUnder(val.Type())))
96}
97
98func (c *Const) Len() uint32 {
99 return c.len

Callers 4

projectMethod · 0.92
NewSearchFunction · 0.92
EvalMethod · 0.92
CallMethod · 0.92

Calls 15

IsUnsignedFunction · 0.92
IsSignedFunction · 0.92
IsFloatFunction · 0.92
DecodeIPFunction · 0.92
DecodeNetFunction · 0.92
TypeUnderFunction · 0.92
NewConstUintFunction · 0.85
NewConstIntFunction · 0.85
NewConstFloatFunction · 0.85
NewConstBoolFunction · 0.85
NewConstBytesFunction · 0.85
NewConstStringFunction · 0.85

Tested by

no test coverage detected