MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / Copy

Method Copy

pkg/col/coldata/vec.eg.go:490–920  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

488// Vec.
489// Refer to the SliceArgs comment for specifics and TestCopy for examples.
490func (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 {

Callers

nothing calls this directly

Calls 15

NullsMethod · 0.95
CanonicalTypeFamilyMethod · 0.95
BoolMethod · 0.95
BytesMethod · 0.95
DecimalMethod · 0.95
Int16Method · 0.95
Int32Method · 0.95
Int64Method · 0.95
Float64Method · 0.95
TimestampMethod · 0.95
IntervalMethod · 0.95
JSONMethod · 0.95

Tested by

no test coverage detected