Skip to content

Separate the logic of different workloads in tpcc prepare #24

@yeya24

Description

@yeya24

Currently in tpcc prepare, we support two kinds of workloads. The first is SQL loader, which directly sends SQL statements to db. Another is csv generator, which just generate csv file locally.

Now the two use the same Workloader struct, which makes the logic quite ugly and hard to read. I propose we can add a new csvWorkloader, which also implements workload.Workloader interface, then we can separate the logic.

// Workloader is the interface for running customized workload
type Workloader interface {
	Name() string
	InitThread(ctx context.Context, threadID int) context.Context
	CleanupThread(ctx context.Context, threadID int)
	Prepare(ctx context.Context, threadID int) error
	CheckPrepare(ctx context.Context, threadID int) error
	Run(ctx context.Context, threadID int) error
	Cleanup(ctx context.Context, threadID int) error
	Check(ctx context.Context, threadID int) error
	DBName() string
}

For csv workloader, we don't need such methods like Check, Run, we can just leave them "not supported" and it is fine.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions