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

Function getNthFromRecord

runtime/sam/expr/eval.go:633–651  ·  view source on GitHub ↗
(typ *super.TypeRecord, container scode.Bytes, idx int)

Source from the content-addressed store, hash-verified

631}
632
633func getNthFromRecord(typ *super.TypeRecord, container scode.Bytes, idx int) (scode.Bytes, int) {
634 if idx < 0 {
635 idx += len(typ.Fields)
636 if idx < 0 || idx >= len(typ.Fields) {
637 return nil, -1
638 }
639 }
640 it := scode.NewRecordIter(container, typ.Opts)
641 for i := 0; !it.Done(); i++ {
642 elem, none := it.Next(typ.Fields[i].Opt)
643 if i == idx {
644 if none {
645 return nil, -1
646 }
647 return elem, idx
648 }
649 }
650 return nil, -1
651}
652
653func lookupKey(mapBytes, target scode.Bytes) (scode.Bytes, bool) {
654 for it := mapBytes.Iter(); !it.Done(); {

Callers 2

indexRecordByIndexFunction · 0.85
EvalMethod · 0.85

Calls 3

DoneMethod · 0.95
NextMethod · 0.95
NewRecordIterFunction · 0.92

Tested by

no test coverage detected