Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
Signed-off-by: mahjonp <junpeng.man@gmail.com>
  • Loading branch information
mahjonp committed Jul 24, 2020
1 parent c73034d commit 577a28d
Show file tree
Hide file tree
Showing 17 changed files with 961 additions and 103 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
bin
.idea/
go-tpc
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ For example:
```

#### Other usages

```bash
# Generate csv files (split to 100 files each table)
./bin/go-tpc tpcc --warehouses 4 prepare -T 100 --output-type csv --output-dir data
Expand Down Expand Up @@ -120,3 +121,24 @@ If you want to import tpcc data into TiDB, please refer to [import-to-tidb](docs
# Cleanup
./bin/go-tpc tpch cleanup
```

### CH-benCHmark

#### Prepare

1. First please refer to the above instruction(`go-tpc tpcc --warehouses $warehouses prepare`) to prepare the TP part schema and populate data

2. Then uses `go-tpc ch prepare` to prepare the AP part schema and data

```bash
# Prepare data
./bin/go-tpc ch prepare
# Prepare data, create tiflash replica, and analyze table after data loaded
./bin/go-tpc ch --analyze --tiflash prepare
```

#### Run

```bash
./bin/go-tpc ch --warehouses $warehouses -T $tpWorkers -t $apWorkers --time $measurement-time run
```
73 changes: 73 additions & 0 deletions ch/ddl.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package ch

import (
"context"
"fmt"
)

var allTables []string

func init() {
allTables = []string{"customer", "district", "history", "item", "new_order", "order_line", "orders", "region", "warehouse",
"nation", "stock", "supplier"}
}

func (w *Workloader) createTableDDL(ctx context.Context, query string, tableName string, action string) error {
s := w.getState(ctx)
fmt.Printf("%s %s\n", action, tableName)
if _, err := s.Conn.ExecContext(ctx, query); err != nil {
return err
}
if w.cfg.CreateTiFlashReplica {
fmt.Printf("creating tiflash replica for %s\n", tableName)
replicaSQL := fmt.Sprintf("ALTER TABLE %s SET TIFLASH REPLICA 1", tableName)
if _, err := s.Conn.ExecContext(ctx, replicaSQL); err != nil {
return err
}
}
return nil
}

// createTables creates tables schema.
func (w Workloader) createTables(ctx context.Context) error {
query := `
CREATE TABLE IF NOT EXISTS nation (
N_NATIONKEY BIGINT NOT NULL,
N_NAME CHAR(25) NOT NULL,
N_REGIONKEY BIGINT NOT NULL,
N_COMMENT VARCHAR(152),
PRIMARY KEY (N_NATIONKEY)
)`

if err := w.createTableDDL(ctx, query, "nation", "creating"); err != nil {
return err
}

query = `
CREATE TABLE IF NOT EXISTS region (
R_REGIONKEY BIGINT NOT NULL,
R_NAME CHAR(25) NOT NULL,
R_COMMENT VARCHAR(152),
PRIMARY KEY (R_REGIONKEY)
)`
if err := w.createTableDDL(ctx, query, "region", "creating"); err != nil {
return err
}

query = `
CREATE TABLE IF NOT EXISTS supplier (
S_SUPPKEY BIGINT NOT NULL,
S_NAME CHAR(25) NOT NULL,
S_ADDRESS VARCHAR(40) NOT NULL,
S_NATIONKEY BIGINT NOT NULL,
S_PHONE CHAR(15) NOT NULL,
S_ACCTBAL DECIMAL(15, 2) NOT NULL,
S_COMMENT VARCHAR(101) NOT NULL,
PRIMARY KEY (S_SUPPKEY)
)`
if err := w.createTableDDL(ctx, query, "supplier", "creating"); err != nil {
return err
}

return nil
}
Loading

0 comments on commit 577a28d

Please sign in to comment.