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

Method singleIP

runtime/vam/expr/function/networkof.go:34–61  ·  view source on GitHub ↗
(vec vector.Any)

Source from the content-addressed store, hash-verified

32}
33
34func (n *NetworkOf) singleIP(vec vector.Any) vector.Any {
35 var errs []uint32
36 var nets vector.Any
37 switch vec := vec.(type) {
38 case *vector.IP:
39 nets, errs = n.singleIPLoop(vec, nil)
40 case *vector.Const:
41 ip := vector.IPValue(vec, 0)
42 if !ip.Is4() {
43 return errNotIP4(n.sctx, vec)
44 }
45 net := netip.PrefixFrom(ip, bitsFromIP(ip.As4())).Masked()
46 return vector.NewConstNet(net, vec.Len())
47 case *vector.View:
48 nets, errs = n.singleIPLoop(vec.Any.(*vector.IP), vec.Index)
49 case *vector.Dict:
50 netVals, derrs := n.singleIPLoop(vec.Any.(*vector.IP), nil)
51 index, counts := vec.Index, vec.Counts
52 if len(derrs) > 0 {
53 index, counts, errs = vec.RebuildDropTags(derrs...)
54 }
55 nets = vector.NewDict(netVals, index, counts)
56 }
57 if len(errs) > 0 {
58 return vector.Combine(nets, errs, errNotIP4(n.sctx, vector.Pick(vec, errs)))
59 }
60 return nets
61}
62
63func (n *NetworkOf) singleIPLoop(vec *vector.IP, index []uint32) (*vector.Net, []uint32) {
64 var nets []netip.Prefix

Callers 1

CallMethod · 0.95

Calls 10

singleIPLoopMethod · 0.95
IPValueFunction · 0.92
NewConstNetFunction · 0.92
NewDictFunction · 0.92
CombineFunction · 0.92
PickFunction · 0.92
errNotIP4Function · 0.85
bitsFromIPFunction · 0.85
RebuildDropTagsMethod · 0.80
LenMethod · 0.65

Tested by

no test coverage detected