Copy uses SliceArgs to copy elements of a source Vec into this Vec. It is logically equivalent to: copy(destVec[args.DestIdx:], args.Src[args.SrcStartIdx:args.SrcEndIdx]) An optional Sel slice can also be provided to apply a filter on the source Vec. Refer to the SliceArgs comment for specifics and
(args SliceArgs)
| 488 | // Vec. |
| 489 | // Refer to the SliceArgs comment for specifics and TestCopy for examples. |
| 490 | func (v *Vec) Copy(args SliceArgs) { |
| 491 | if args.SrcStartIdx == args.SrcEndIdx { |
| 492 | // Nothing to copy, so return early. |
| 493 | return |
| 494 | } |
| 495 | if v.Nulls().MaybeHasNulls() { |
| 496 | // We're about to overwrite this entire range, so unset all the nulls. |
| 497 | v.Nulls().UnsetNullRange(args.DestIdx, args.DestIdx+(args.SrcEndIdx-args.SrcStartIdx)) |
| 498 | } |
| 499 | |
| 500 | switch v.CanonicalTypeFamily() { |
| 501 | case types.BoolFamily: |
| 502 | switch v.t.Width() { |
| 503 | case -1: |
| 504 | default: |
| 505 | fromCol := args.Src.Bool() |
| 506 | toCol := v.Bool() |
| 507 | if args.Sel != nil { |
| 508 | sel := args.Sel[args.SrcStartIdx:args.SrcEndIdx] |
| 509 | n := len(sel) |
| 510 | toCol = toCol[args.DestIdx:] |
| 511 | _ = toCol[n-1] |
| 512 | if args.Src.MaybeHasNulls() { |
| 513 | nulls := args.Src.Nulls() |
| 514 | for i := 0; i < n; i++ { |
| 515 | //gcassert:bce |
| 516 | selIdx := sel[i] |
| 517 | if nulls.NullAt(selIdx) { |
| 518 | v.nulls.SetNull(i + args.DestIdx) |
| 519 | } else { |
| 520 | v := fromCol.Get(selIdx) |
| 521 | //gcassert:bce |
| 522 | toCol.Set(i, v) |
| 523 | } |
| 524 | } |
| 525 | return |
| 526 | } |
| 527 | // No Nulls. |
| 528 | for i := 0; i < n; i++ { |
| 529 | //gcassert:bce |
| 530 | selIdx := sel[i] |
| 531 | v := fromCol.Get(selIdx) |
| 532 | //gcassert:bce |
| 533 | toCol.Set(i, v) |
| 534 | } |
| 535 | return |
| 536 | } |
| 537 | // No Sel. |
| 538 | toCol.CopySlice(fromCol, args.DestIdx, args.SrcStartIdx, args.SrcEndIdx) |
| 539 | v.nulls.set(args) |
| 540 | } |
| 541 | case types.BytesFamily: |
| 542 | switch v.t.Width() { |
| 543 | case -1: |
| 544 | default: |
| 545 | fromCol := args.Src.Bytes() |
| 546 | toCol := v.Bytes() |
| 547 | if args.Sel != nil { |
nothing calls this directly
no test coverage detected