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.
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
Workloaderstruct, which makes the logic quite ugly and hard to read. I propose we can add a newcsvWorkloader, which also implementsworkload.Workloaderinterface, then we can separate the logic.For csv workloader, we don't need such methods like
Check,Run, we can just leave them "not supported" and it is fine.