github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/col/coldata/datum_vec.go (about)

     1  // Copyright 2020 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  package coldata
    12  
    13  // Datum is abstract type for elements inside DatumVec, this type in reality
    14  // should be tree.Datum. However, in order to avoid pulling in 'tree' package
    15  // into the 'coldata' package, we use a runtime cast instead.
    16  type Datum interface{}
    17  
    18  // DatumVec is the interface for a specialized vector that operates on
    19  // tree.Datums in the vectorized engine. In order to avoid import of 'tree'
    20  // package the implementation of DatumVec lives in 'coldataext' package.
    21  type DatumVec interface {
    22  	// Get returns the datum at index i in the vector.
    23  	Get(i int) Datum
    24  	// Set sets the datum at index i in the vector. It must check whether the
    25  	// provided datum is compatible with the type that the DatumVec stores.
    26  	Set(i int, v Datum)
    27  	// Slice creates a "window" into the vector. It behaves similarly to
    28  	// Golang's slice.
    29  	Slice(start, end int) DatumVec
    30  	// CopySlice copies srcStartIdx inclusive and srcEndIdx exclusive
    31  	// tree.Datum values from src into the vector starting at destIdx.
    32  	CopySlice(src DatumVec, destIdx, srcStartIdx, srcEndIdx int)
    33  	// AppendSlice appends srcStartIdx inclusive and srcEndIdx exclusive
    34  	// tree.Datum values from src into the vector starting at destIdx.
    35  	AppendSlice(src DatumVec, destIdx, srcStartIdx, srcEndIdx int)
    36  	// AppendVal appends the given tree.Datum value to the end of the vector.
    37  	AppendVal(v Datum)
    38  	// SetLength sets the length of the vector.
    39  	SetLength(l int)
    40  	// Len returns the length of the vector.
    41  	Len() int
    42  	// Cap returns the underlying capacity of the vector.
    43  	Cap() int
    44  	// MarshalAt returns the marshaled representation of datum at index i.
    45  	MarshalAt(i int) ([]byte, error)
    46  	// UnmarshalTo unmarshals the byte representation of a datum and sets it at
    47  	// index i.
    48  	UnmarshalTo(i int, b []byte) error
    49  }