sampledataccl

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2017 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InsertBatched

func InsertBatched(db *gosql.DB, data Data, batchSize int) error

InsertBatched inserts all rows represented by `data` into `db` in batches of `batchSize` rows. The table must exist.

func Setup

func Setup(db *gosql.DB, data Data) error

Setup creates a table in `db` with all the rows and splits of `data`.

func Split

func Split(db *gosql.DB, data Data) error

Split creates the configured number of ranges in an already created created version of the table represented by `data`.

Types

type Backup

type Backup struct {
	// BaseDir can be used for a RESTORE. All paths in the descriptor are
	// relative to this.
	BaseDir string
	Desc    sqlccl.BackupDescriptor
	// contains filtered or unexported fields
}

Backup is a representation of an enterprise BACKUP.

func ToBackup

func ToBackup(t testing.TB, data Data, dir string) (*Backup, error)

ToBackup creates an enterprise backup in `dir`.

func (*Backup) NextKeyValues

func (b *Backup) NextKeyValues(
	count int, newTableID sqlbase.ID,
) ([]engine.MVCCKeyValue, roachpb.Span, error)

NextKeyValues iterates and returns every *user table data* key-value in the backup. At least `count` kvs will be returned, but rows are not broken up, so slightly more than `count` may come back. If fewer than `count` are available, err will be `io.EOF` and kvs may be partially filled with the remainer.

func (*Backup) ResetKeyValueIteration

func (b *Backup) ResetKeyValueIteration()

ResetKeyValueIteration resets the NextKeyValues iteration to the first kv.

type Data

type Data interface {
	// Name returns the fully-qualified name of the represented table.
	Name() string

	// Schema returns the schema for the represented table, such that it can be
	// used in fmt.Sprintf(`CREATE TABLE %s %s`, data.Name(), data.Schema`())`.
	Schema() string

	// NextRow iterates through the rows in the represented table, returning one
	// per call. The row is represented as a slice of strings, each string one
	// of the columns in the row. When no more rows are available, the bool
	// returned is false.
	NextRow() ([]string, bool)

	// NextRow iterates through the split points in the represented table,
	// returning one per call. The split is represented as a slice of strings,
	// each string one of the columns in the split. When no more splits are
	// available, the bool returned is false.
	NextSplit() ([]string, bool)
}

Data is a representation of a sql table, used for creating test data in various forms (sql rows, kvs, enterprise backup). All data tables live in the `data` database.

func Bank

func Bank(rows int, payloadBytes int, ranges int) Data

Bank returns a bank table with three columns: an `id INT PRIMARY KEY` representing an account number, a `balance` INT, and a `payload` BYTES to pad the size of the rows for various tests.

func BankRows

func BankRows(rows int) Data

BankRows returns Bank testdata with the given number of rows and default payload size and range count.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL