-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* tpc-h: add run part Signed-off-by: mahjonp <[email protected]>
- Loading branch information
1 parent
91f1256
commit b36483e
Showing
31 changed files
with
5,081 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dbgen | ||
======== | ||
|
||
This dbgen was port from TPC-H dbgen v2.4.0. | ||
|
||
Official TPC-H benchmark - [http://www.tpc.org/tpch](http://www.tpc.org/tpch) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
TPC, TPC Benchmark and TPC-C are trademarks of the Transaction Processing Performance Council. | ||
All other materials are ©2015-2016 TPC. All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package dbgen | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
) | ||
|
||
const ( | ||
cPhneSd = 28 | ||
cAbalSd = 29 | ||
cMsegSd = 30 | ||
cAddrLen = 25 | ||
cCmntLen = 73 | ||
cAddrSd = 26 | ||
cCmntSd = 31 | ||
cAbalMin = -99999 | ||
cAbalMax = 999999 | ||
lNtrgSd = 27 | ||
) | ||
|
||
type Cust struct { | ||
CustKey dssHuge | ||
Name string | ||
Address string | ||
NationCode dssHuge | ||
Phone string | ||
Acctbal dssHuge | ||
MktSegment string | ||
Comment string | ||
} | ||
|
||
type custLoader struct { | ||
io.StringWriter | ||
} | ||
|
||
func (c custLoader) Load(item interface{}) error { | ||
cust := item.(*Cust) | ||
if _, err := c.WriteString( | ||
fmt.Sprintf("%d|%s|%s|%d|%s|%s|%s|%s|\n", | ||
cust.CustKey, | ||
cust.Name, | ||
cust.Address, | ||
cust.NationCode, | ||
cust.Phone, | ||
FmtMoney(cust.Acctbal), | ||
cust.MktSegment, | ||
cust.Comment)); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func (c custLoader) Flush() error { | ||
return nil | ||
} | ||
|
||
func newCustLoader(writer io.StringWriter) custLoader { | ||
return custLoader{writer} | ||
} | ||
|
||
func sdCust(child Table, skipCount dssHuge) { | ||
advanceStream(cAddrSd, skipCount*9, false) | ||
advanceStream(cCmntSd, skipCount*2, false) | ||
advanceStream(lNtrgSd, skipCount, false) | ||
advanceStream(cPhneSd, skipCount*3, false) | ||
advanceStream(cAbalSd, skipCount, false) | ||
advanceStream(cMsegSd, skipCount, false) | ||
} | ||
|
||
func makeCust(idx dssHuge) *Cust { | ||
cust := &Cust{} | ||
cust.CustKey = idx | ||
cust.Name = fmt.Sprintf("Customer#%09d", idx) | ||
cust.Address = vStr(cAddrLen, cAddrSd) | ||
i := random(0, dssHuge(nations.count-1), lNtrgSd) | ||
cust.NationCode = i | ||
cust.Phone = genPhone(i, cPhneSd) | ||
cust.Acctbal = random(cAbalMin, cAbalMax, cAbalSd) | ||
pickStr(&cMsegSet, cMsegSd, &cust.MktSegment) | ||
cust.Comment = makeText(cCmntLen, cCmntSd) | ||
|
||
return cust | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package dbgen | ||
|
||
import "github.com/pingcap/go-tpc/tpch/dbgen/dist" | ||
|
||
var ( | ||
nations distribution | ||
nations2 distribution | ||
regions distribution | ||
oPrioritySet distribution | ||
lInstructSet distribution | ||
lSmodeSet distribution | ||
lCategorySet distribution | ||
lRflagSet distribution | ||
cMsegSet distribution | ||
colors distribution | ||
pTypesSet distribution | ||
pCntrSet distribution | ||
articles distribution | ||
nouns distribution | ||
adjectives distribution | ||
adverbs distribution | ||
prepositions distribution | ||
verbs distribution | ||
terminators distribution | ||
auxillaries distribution | ||
np distribution | ||
vp distribution | ||
grammar distribution | ||
) | ||
|
||
type setMember struct { | ||
weight long | ||
text string | ||
} | ||
|
||
type distribution struct { | ||
count int | ||
max int32 | ||
members []setMember | ||
permute []long | ||
} | ||
|
||
func readDist(name string, d *distribution) { | ||
dist := dist.Maps[name] | ||
d.count = len(dist) | ||
for _, item := range dist { | ||
d.max += item.Weight | ||
d.members = append(d.members, setMember{text: item.Text, weight: long(d.max)}) | ||
} | ||
} | ||
|
||
func permute(permute []long, count int, stream long) { | ||
for i := 0; i < count; i++ { | ||
source := random(dssHuge(i), dssHuge(count-1), stream) | ||
permute[source], permute[i] = permute[i], permute[source] | ||
} | ||
} | ||
|
||
func permuteDist(dist *distribution, stream long) { | ||
if len(dist.permute) == 0 { | ||
dist.permute = make([]long, dist.count) | ||
} | ||
for i := 0; i < dist.count; i++ { | ||
dist.permute[i] = long(i) | ||
} | ||
permute(dist.permute, dist.count, stream) | ||
} | ||
|
||
func initDists() { | ||
readDist("p_cntr", &pCntrSet) | ||
readDist("colors", &colors) | ||
readDist("p_types", &pTypesSet) | ||
readDist("nations", &nations) | ||
readDist("regions", ®ions) | ||
readDist("o_oprio", &oPrioritySet) | ||
readDist("instruct", &lInstructSet) | ||
readDist("smode", &lSmodeSet) | ||
readDist("category", &lCategorySet) | ||
readDist("rflag", &lRflagSet) | ||
readDist("msegmnt", &cMsegSet) | ||
readDist("nouns", &nouns) | ||
readDist("verbs", &verbs) | ||
readDist("adjectives", &adjectives) | ||
readDist("adverbs", &adverbs) | ||
readDist("auxillaries", &auxillaries) | ||
readDist("terminators", &terminators) | ||
readDist("articles", &articles) | ||
readDist("prepositions", &prepositions) | ||
readDist("grammar", &grammar) | ||
readDist("np", &np) | ||
readDist("vp", &vp) | ||
} |
Oops, something went wrong.