cockroach: Index | Files

package coldatatestutils

import ""


Package Files

random_testutils.go utils.go

func CopyBatch Uses

func CopyBatch(
    original coldata.Batch, typs []*types.T, factory coldata.ColumnFactory,
) coldata.Batch

CopyBatch copies the original batch and returns that copy. However, note that the underlying capacity might be different (a new batch is created only with capacity original.Length()). NOTE: memory accounting is not performed.

func RandomBatch Uses

func RandomBatch(
    allocator *colmem.Allocator,
    rng *rand.Rand,
    typs []*types.T,
    capacity int,
    length int,
    nullProbability float64,
) coldata.Batch

RandomBatch returns a batch with a capacity of capacity and a number of random elements equal to length (capacity if length is 0). The values will be null with a probability of nullProbability.

func RandomBatchWithSel Uses

func RandomBatchWithSel(
    allocator *colmem.Allocator,
    rng *rand.Rand,
    typs []*types.T,
    n int,
    nullProbability float64,
    selProbability float64,
) coldata.Batch

RandomBatchWithSel is equivalent to RandomBatch, but will also add a selection vector to the batch where each row is selected with probability selProbability. If selProbability is 1, all the rows will be selected, if selProbability is 0, none will. The returned batch will have its length set to the length of the selection vector, unless selProbability is 0.

func RandomSel Uses

func RandomSel(rng *rand.Rand, batchSize int, probOfOmitting float64) []int

RandomSel creates a random selection vector up to a given batchSize in length. probOfOmitting specifies the probability that a row should be omitted from the batch (i.e. whether it should be selected out). So if probOfOmitting is 0, then the selection vector will contain all rows, but if it is > 0, then some rows might be omitted and the length of the selection vector might be less than batchSize.

func RandomVec Uses

func RandomVec(args RandomVecArgs)

RandomVec populates vector with random values, setting each value to null with the given probability. It is assumed that N is in bounds of the given vector.

type RandomDataOp Uses

type RandomDataOp struct {
    // contains filtered or unexported fields

RandomDataOp is an operator that generates random data according to RandomDataOpArgs. Call GetBuffer to get all data that was returned.

func NewRandomDataOp Uses

func NewRandomDataOp(
    allocator *colmem.Allocator, rng *rand.Rand, args RandomDataOpArgs,
) *RandomDataOp

NewRandomDataOp creates a new RandomDataOp.

func (*RandomDataOp) Child Uses

func (o *RandomDataOp) Child(nth int, verbose bool) execinfra.OpNode

Child implements the execinfra.OpNode interface.

func (*RandomDataOp) ChildCount Uses

func (o *RandomDataOp) ChildCount(verbose bool) int

ChildCount implements the execinfra.OpNode interface.

func (*RandomDataOp) Init Uses

func (o *RandomDataOp) Init()

Init is part of the colexec.Operator interface.

func (*RandomDataOp) Next Uses

func (o *RandomDataOp) Next(context.Context) coldata.Batch

Next is part of the colexec.Operator interface.

func (*RandomDataOp) Typs Uses

func (o *RandomDataOp) Typs() []*types.T

Typs returns the output types of the RandomDataOp.

type RandomDataOpArgs Uses

type RandomDataOpArgs struct {
    // DeterministicTyps, if set, overrides MaxSchemaLength and disables type
    // randomization, forcing the RandomDataOp to use this schema.
    DeterministicTyps []*types.T
    // MaxSchemaLength is the maximum length of the operator's schema, which will
    // be at least one type.
    MaxSchemaLength int
    // BatchSize() is the size of batches returned.
    BatchSize int
    // NumBatches is the number of batches returned before the final, zero batch.
    NumBatches int
    // Selection specifies whether random selection vectors should be generated
    // over the batches.
    Selection bool
    // Nulls specifies whether nulls should be set in batches.
    Nulls bool
    // BatchAccumulator, if set, will be called before returning a coldata.Batch
    // from Next.
    BatchAccumulator func(b coldata.Batch, typs []*types.T)

RandomDataOpArgs are arguments passed in to RandomDataOp. All arguments are optional (refer to the constants above this struct definition for the defaults). Bools are false by default.

type RandomVecArgs Uses

type RandomVecArgs struct {
    // Rand is the provided RNG.
    Rand *rand.Rand
    // Vec is the vector to be filled with random values.
    Vec coldata.Vec
    // N is the number of values to be generated.
    N   int
    // NullProbability determines the probability of a single value being NULL.
    NullProbability float64

    // BytesFixedLength (when greater than zero) specifies the fixed length of
    // the bytes slice to be generated. It is used only if vec's physical
    // representation is flat bytes.
    BytesFixedLength int
    // IntRange (when greater than zero) determines the range of possible
    // values for integer vectors; namely, all values will be in
    // (-IntRange, +IntRange) interval.
    IntRange int
    // ZeroProhibited determines whether numeric zero values are disallowed to
    // be generated.
    ZeroProhibited bool

RandomVecArgs is a utility struct that contains arguments to RandomVec call.

Package coldatatestutils imports 13 packages (graph). Updated 2020-06-02. Refresh now. Tools for package owners.