cockroach: github.com/cockroachdb/cockroach/pkg/testutils/distsqlutils Index | Files

package distsqlutils

import "github.com/cockroachdb/cockroach/pkg/testutils/distsqlutils"

Index

Package Files

row_buffer.go

type BufferedRecord Uses

type BufferedRecord struct {
    Meta *execinfrapb.ProducerMetadata
    // contains filtered or unexported fields
}

BufferedRecord represents a row or metadata record that has been buffered inside a RowBuffer.

type RowBuffer Uses

type RowBuffer struct {
    Mu  struct {
        syncutil.Mutex

        // records represent the data that has been buffered. Push appends a row
        // to the back, Next removes a row from the front.
        Records []BufferedRecord
        // contains filtered or unexported fields
    }

    // Done is used when the RowBuffer is used as a RowSource; it is set to true
    // when the receiver read all the rows.
    Done bool

    ConsumerStatus execinfra.ConsumerStatus
    // contains filtered or unexported fields
}

RowBuffer is an implementation of RowReceiver that buffers (accumulates) results in memory, as well as an implementation of RowSource that returns records from a record buffer. Just for tests.

func NewRowBuffer Uses

func NewRowBuffer(types []types.T, rows sqlbase.EncDatumRows, hooks RowBufferArgs) *RowBuffer

NewRowBuffer creates a RowBuffer with the given schema and initial rows.

func (*RowBuffer) ConsumerClosed Uses

func (rb *RowBuffer) ConsumerClosed()

ConsumerClosed is part of the RowSource interface.

func (*RowBuffer) ConsumerDone Uses

func (rb *RowBuffer) ConsumerDone()

ConsumerDone is part of the RowSource interface.

func (*RowBuffer) GetRowsNoMeta Uses

func (rb *RowBuffer) GetRowsNoMeta(t *testing.T) sqlbase.EncDatumRows

GetRowsNoMeta returns the rows in the buffer; it fails the test if it encounters any metadata.

func (*RowBuffer) Next Uses

func (rb *RowBuffer) Next() (sqlbase.EncDatumRow, *execinfrapb.ProducerMetadata)

Next is part of the RowSource interface.

There's no synchronization here with Push(). The assumption is that these two methods are not called concurrently.

func (*RowBuffer) NextNoMeta Uses

func (rb *RowBuffer) NextNoMeta(tb testing.TB) sqlbase.EncDatumRow

NextNoMeta is a version of Next which fails the test if it encounters any metadata.

func (*RowBuffer) OutputTypes Uses

func (rb *RowBuffer) OutputTypes() []types.T

OutputTypes is part of the RowSource interface.

func (*RowBuffer) ProducerClosed Uses

func (rb *RowBuffer) ProducerClosed() bool

ProducerClosed is a utility function used by tests to check whether the RowBuffer has had ProducerDone() called on it.

func (*RowBuffer) ProducerDone Uses

func (rb *RowBuffer) ProducerDone()

ProducerDone is part of the RowSource interface.

func (*RowBuffer) Push Uses

func (rb *RowBuffer) Push(
    row sqlbase.EncDatumRow, meta *execinfrapb.ProducerMetadata,
) execinfra.ConsumerStatus

Push is part of the RowReceiver interface.

func (*RowBuffer) Start Uses

func (rb *RowBuffer) Start(ctx context.Context) context.Context

Start is part of the RowSource interface.

func (*RowBuffer) Types Uses

func (rb *RowBuffer) Types() []types.T

Types is part of the RowReceiver interface.

type RowBufferArgs Uses

type RowBufferArgs struct {
    // If not set, then the RowBuffer will behave like a RowChannel and not
    // accumulate rows after it's been put in draining mode. If set, rows will still
    // be accumulated. Useful for tests that want to observe what rows have been
    // pushed after draining.
    AccumulateRowsWhileDraining bool
    // OnConsumerDone, if specified, is called as the first thing in the
    // ConsumerDone() method.
    OnConsumerDone func(*RowBuffer)
    // OnConsumerClose, if specified, is called as the first thing in the
    // ConsumerClosed() method.
    OnConsumerClosed func(*RowBuffer)
    // OnNext, if specified, is called as the first thing in the Next() method.
    // If it returns an empty row and metadata, then RowBuffer.Next() is allowed
    // to run normally. Otherwise, the values are returned from RowBuffer.Next().
    OnNext func(*RowBuffer) (sqlbase.EncDatumRow, *execinfrapb.ProducerMetadata)
    // OnPush, if specified, is called as the first thing in the Push() method.
    OnPush func(sqlbase.EncDatumRow, *execinfrapb.ProducerMetadata)
}

RowBufferArgs contains testing-oriented parameters for a RowBuffer.

Package distsqlutils imports 9 packages (graph) and is imported by 1 packages. Updated 2019-09-18. Refresh now. Tools for package owners.