You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
randomSeed:=flag.Int64("random-seed", 12345, "Random seed to use.")
30
+
dataImportFile:=flag.String("data-import-terms", "", "Read field replacement data from file in csv format. each column should start and end with '__' chars. Example __field1__,__field2__.")
31
+
dataImportMode:=flag.String("data-import-terms-mode", "seq", "Either 'seq' or 'rand'.")
29
32
randomIntMin:=flag.Int64("random-int-min", 1, "__rand_int__ lower value limit. __rand_int__ distribution is uniform Random")
30
33
randomIntMax:=flag.Int64("random-int-max", 1000000, "__rand_int__ upper value limit. __rand_int__ distribution is uniform Random")
log.Printf("Reading term data import file from: %s. Using '%s' record read mode.\n", *dataImportFile, *dataImportMode)
115
+
dataReplacementEnabled=true
116
+
replacementArr=make([]map[string]string, 0)
117
+
118
+
f, err:=os.Open(*dataImportFile)
119
+
iferr!=nil {
120
+
log.Fatal("Unable to read input file "+*dataImportFile, err)
121
+
}
122
+
deferf.Close()
123
+
124
+
csvReader:=csv.NewReader(f)
125
+
records, err:=csvReader.ReadAll()
126
+
headers:=records[0]
127
+
rlen:=len(records) -1
128
+
fori:=0; i<int(*numberRequests); i++ {
129
+
// seq mode
130
+
recordPos:=i%rlen
131
+
ifstrings.Compare(*dataImportMode, "rand") ==0 {
132
+
recordPos=rand.Intn(rlen)
133
+
}
134
+
record:=records[recordPos+1]
135
+
lineMap:=make(map[string]string)
136
+
forj:=0; j<len(headers); j++ {
137
+
lineMap[headers[j]] =record[j]
138
+
}
139
+
replacementArr=append(replacementArr, lineMap)
140
+
}
141
+
iferr!=nil {
142
+
log.Fatal("Unable to parse file as CSV for "+*dataImportFile, err)
143
+
}
144
+
log.Printf("There are a total of %d disticint lines of terms. Each line has %d columns. Prepared %d groups of records for the benchmark.\n", rlen, len(headers), len(replacementArr))
0 commit comments