cockroach: github.com/cockroachdb/cockroach/pkg/col/coldata Index | Files

package coldata

import "github.com/cockroachdb/cockroach/pkg/col/coldata"

Index

Package Files

batch.go bytes.go nulls.go vec.go

Constants

const BatchSize = 1024

BatchSize is the maximum number of tuples that fit in a column batch. TODO(jordan): tune

type Batch Uses

type Batch interface {
    // Length returns the number of values in the columns in the batch.
    Length() uint16
    // SetLength sets the number of values in the columns in the batch.
    SetLength(uint16)
    // Width returns the number of columns in the batch.
    Width() int
    // ColVec returns the ith Vec in this batch.
    ColVec(i int) Vec
    // ColVecs returns all of the underlying Vecs in this batch.
    ColVecs() []Vec
    // Selection, if not nil, returns the selection vector on this batch: a
    // densely-packed list of the indices in each column that have not been
    // filtered out by a previous step.
    Selection() []uint16
    // SetSelection sets whether this batch is using its selection vector or not.
    SetSelection(bool)
    // AppendCol appends a Vec with the specified type to this batch.
    AppendCol(coltypes.T)
    // Reset modifies the caller in-place to have the given length and columns
    // with the given coltypes. If it's possible, Reset will reuse the existing
    // columns and allocations, invalidating existing references to the Batch or
    // its Vecs. However, Reset does _not_ zero out the column data.
    Reset(types []coltypes.T, length int)
    // ResetInternalBatch resets a batch and its underlying Vecs for reuse. It's
    // important for callers to call ResetInternalBatch if they own internal
    // batches that they reuse as not doing this could result in correctness
    // or memory blowup issues.
    ResetInternalBatch()
}

Batch is the type that columnar operators receive and produce. It represents a set of column vectors (partial data columns) as well as metadata about a batch, like the selection vector (which rows in the column batch are selected).

func NewMemBatch Uses

func NewMemBatch(types []coltypes.T) Batch

NewMemBatch allocates a new in-memory Batch. TODO(jordan): pool these allocations.

func NewMemBatchWithSize Uses

func NewMemBatchWithSize(types []coltypes.T, size int) Batch

NewMemBatchWithSize allocates a new in-memory Batch with the given column size. Use for operators that have a precisely-sized output batch.

type Bytes Uses

type Bytes struct {
    // contains filtered or unexported fields
}

Bytes is a wrapper type for a two-dimensional byte slice.

func NewBytes Uses

func NewBytes(n int) *Bytes

NewBytes returns a Bytes struct with enough capacity for n elements.

func (*Bytes) AppendSlice Uses

func (b *Bytes) AppendSlice(src *Bytes, destIdx, srcStartIdx, srcEndIdx int)

AppendSlice appends srcStartIdx inclusive and srcEndIdx inclusive []byte values from src into the receiver starting at destIdx.

func (*Bytes) AppendVal Uses

func (b *Bytes) AppendVal(v []byte)

AppendVal appends the given []byte value to the end of the receiver.

func (*Bytes) CopySlice Uses

func (b *Bytes) CopySlice(src *Bytes, destIdx, srcStartIdx, srcEndIdx int)

CopySlice copies srcStartIdx inclusive and srcEndIdx inclusive []byte values from src into the receiver starting at destIdx.

func (*Bytes) Get Uses

func (b *Bytes) Get(i int) []byte

Get returns the ith []byte in Bytes.

func (*Bytes) Len Uses

func (b *Bytes) Len() int

Len returns how many []byte values the receiver contains.

func (*Bytes) PrimitiveRepr Uses

func (b *Bytes) PrimitiveRepr() [][]byte

PrimitiveRepr is a temprorary migration tool. TODO(asubiotto): Remove this.

func (*Bytes) Reset Uses

func (b *Bytes) Reset()

Reset here is a stub that is added so that the calls that used to be to flatBytes.Reset() don't need to be removed.

func (*Bytes) Set Uses

func (b *Bytes) Set(i int, v []byte)

Set sets the ith []byte in Bytes.

func (*Bytes) Slice Uses

func (b *Bytes) Slice(start, end int) *Bytes

Slice returns a new Bytes struct with its internal data sliced according to start and end.

func (*Bytes) Zero Uses

func (b *Bytes) Zero()

Zero zeroes out the underlying bytes.

type CopySliceArgs Uses

type CopySliceArgs struct {
    SliceArgs
    // Sel64 overrides Sel. Used when the amount of data being copied exceeds the
    // representation capabilities of a []uint16.
    Sel64 []uint64
    // SelOnDest, if true, uses the selection vector as a lens into the
    // destination as well as the source. Normally, when SelOnDest is false, the
    // selection vector is applied to the source vector, but the results are
    // copied densely into the destination vector.
    SelOnDest bool
}

CopySliceArgs represents the extension of SliceArgs that is passed in to Vec.Copy.

type MemBatch Uses

type MemBatch struct {
    // contains filtered or unexported fields
}

MemBatch is an in-memory implementation of Batch.

func (*MemBatch) AppendCol Uses

func (m *MemBatch) AppendCol(t coltypes.T)

AppendCol implements the Batch interface.

func (*MemBatch) ColVec Uses

func (m *MemBatch) ColVec(i int) Vec

ColVec implements the Batch interface.

func (*MemBatch) ColVecs Uses

func (m *MemBatch) ColVecs() []Vec

ColVecs implements the Batch interface.

func (*MemBatch) Length Uses

func (m *MemBatch) Length() uint16

Length implements the Batch interface.

func (*MemBatch) Reset Uses

func (m *MemBatch) Reset(types []coltypes.T, length int)

Reset implements the Batch interface.

func (*MemBatch) ResetInternalBatch Uses

func (m *MemBatch) ResetInternalBatch()

ResetInternalBatch implements the Batch interface.

func (*MemBatch) Selection Uses

func (m *MemBatch) Selection() []uint16

Selection implements the Batch interface.

func (*MemBatch) SetLength Uses

func (m *MemBatch) SetLength(n uint16)

SetLength implements the Batch interface.

func (*MemBatch) SetSelection Uses

func (m *MemBatch) SetSelection(b bool)

SetSelection implements the Batch interface.

func (*MemBatch) Width Uses

func (m *MemBatch) Width() int

Width implements the Batch interface.

type Nulls Uses

type Nulls struct {
    // contains filtered or unexported fields
}

Nulls represents a list of potentially nullable values using a bitmap. It is intended to be used alongside a slice (e.g. in the Vec interface) -- if the ith bit is off, then the ith element in that slice should be treated as NULL.

func NewNulls Uses

func NewNulls(len int) Nulls

NewNulls returns a new nulls vector, initialized with a length.

func (*Nulls) Copy Uses

func (n *Nulls) Copy() Nulls

Copy returns a copy of n which can be modified independently.

func (*Nulls) MaybeHasNulls Uses

func (n *Nulls) MaybeHasNulls() bool

MaybeHasNulls returns true if the column possibly has any null values, and returns false if the column definitely has no null values.

func (*Nulls) NullAt Uses

func (n *Nulls) NullAt(i uint16) bool

NullAt returns true if the ith value of the column is null.

func (*Nulls) NullAt64 Uses

func (n *Nulls) NullAt64(i uint64) bool

NullAt64 returns true if the ith value of the column is null.

func (*Nulls) NullBitmap Uses

func (n *Nulls) NullBitmap() []byte

NullBitmap returns the null bitmap.

func (*Nulls) Or Uses

func (n *Nulls) Or(n2 *Nulls) *Nulls

Or returns a new Nulls vector where NullAt(i) iff n1.NullAt(i) or n2.NullAt(i).

func (*Nulls) SetNull Uses

func (n *Nulls) SetNull(i uint16)

SetNull sets the ith value of the column to null.

func (*Nulls) SetNull64 Uses

func (n *Nulls) SetNull64(i uint64)

SetNull64 sets the ith value of the column to null.

func (*Nulls) SetNullBitmap Uses

func (n *Nulls) SetNullBitmap(bm []byte, size int)

SetNullBitmap sets the null bitmap. size corresponds to how many elements this bitmap represents. The bits past the end of this size will be set to valid.

func (*Nulls) SetNullRange Uses

func (n *Nulls) SetNullRange(start uint64, end uint64)

SetNullRange sets all the values in [start, end) to null.

func (*Nulls) SetNulls Uses

func (n *Nulls) SetNulls()

SetNulls sets the column to have only null values.

func (*Nulls) Slice Uses

func (n *Nulls) Slice(start uint64, end uint64) Nulls

Slice returns a new Nulls representing a slice of the current Nulls from [start, end).

func (*Nulls) Truncate Uses

func (n *Nulls) Truncate(start uint16)

Truncate sets all values with index greater than or equal to start to null.

func (*Nulls) UnsetNull Uses

func (n *Nulls) UnsetNull(i uint16)

UnsetNull unsets the ith value of the column.

func (*Nulls) UnsetNull64 Uses

func (n *Nulls) UnsetNull64(i uint64)

UnsetNull64 unsets the ith values of the column.

func (*Nulls) UnsetNullRange Uses

func (n *Nulls) UnsetNullRange(start, end uint64)

UnsetNullRange unsets all the nulls in the range [start, end). After using UnsetNullRange, n might not contain any null values, but maybeHasNulls could still be true.

func (*Nulls) UnsetNulls Uses

func (n *Nulls) UnsetNulls()

UnsetNulls sets the column to have no null values.

func (*Nulls) UnsetNullsAfter Uses

func (n *Nulls) UnsetNullsAfter(idx uint16)

UnsetNullsAfter sets all values with index greater than or equal to idx to non-null.

type SliceArgs Uses

type SliceArgs struct {
    // ColType is the type of both the destination and source slices.
    ColType coltypes.T
    // Src is the data being appended.
    Src Vec
    // Sel is an optional slice specifying indices to append to the destination
    // slice. Note that Src{Start,End}Idx apply to Sel.
    Sel []uint16
    // DestIdx is the first index that Append will append to.
    DestIdx uint64
    // SrcStartIdx is the index of the first element in Src that Append will
    // append.
    SrcStartIdx uint64
    // SrcEndIdx is the exclusive end index of Src. i.e. the element in the index
    // before SrcEndIdx is the last element appended to the destination slice,
    // similar to Src[SrcStartIdx:SrcEndIdx].
    SrcEndIdx uint64
}

SliceArgs represents the arguments passed in to Vec.Append and Nulls.set.

type Vec Uses

type Vec interface {
    // Type returns the type of data stored in this Vec.
    Type() coltypes.T

    // TODO(jordan): is a bitmap or slice of bools better?
    // Bool returns a bool list.
    Bool() []bool
    // Int8 returns an int8 slice.
    Int8() []int8
    // Int16 returns an int16 slice.
    Int16() []int16
    // Int32 returns an int32 slice.
    Int32() []int32
    // Int64 returns an int64 slice.
    Int64() []int64
    // Float32 returns a float32 slice.
    Float32() []float32
    // Float64 returns a float64 slice.
    Float64() []float64
    // Bytes returns a flat Bytes representation.
    Bytes() *Bytes
    // TODO(jordan): should this be [][]byte?
    // Decimal returns an apd.Decimal slice.
    Decimal() []apd.Decimal

    // Col returns the raw, typeless backing storage for this Vec.
    Col() interface{}

    // SetCol sets the member column (in the case of mutable columns).
    SetCol(interface{})

    // Append uses SliceArgs to append elements of a source Vec into this Vec.
    // It is logically equivalent to:
    // destVec = append(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 TestAppend for examples.
    Append(SliceArgs)

    // Copy uses CopySliceArgs 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 CopySliceArgs comment for specifics and TestCopy for examples.
    Copy(CopySliceArgs)

    // Slice returns a new Vec representing a slice of the current Vec from
    // [start, end).
    Slice(colType coltypes.T, start uint64, end uint64) Vec

    // PrettyValueAt returns a "pretty"value for the idx'th value in this Vec.
    // It uses the reflect package and is not suitable for calling in hot paths.
    PrettyValueAt(idx uint16, colType coltypes.T) string

    // MaybeHasNulls returns true if the column possibly has any null values, and
    // returns false if the column definitely has no null values.
    MaybeHasNulls() bool

    // Nulls returns the nulls vector for the column.
    Nulls() *Nulls

    // SetNulls sets the nulls vector for this column.
    SetNulls(*Nulls)
    // contains filtered or unexported methods
}

Vec is an interface that represents a column vector that's accessible by Go native types.

func NewMemColumn Uses

func NewMemColumn(t coltypes.T, n int) Vec

NewMemColumn returns a new memColumn, initialized with a length.

Package coldata imports 5 packages (graph) and is imported by 20 packages. Updated 2019-09-17. Refresh now. Tools for package owners.