/// <summary> /// split function "Setup" into `LoadData` and `LoadWorkloads` /// </summary> /// <param name="dataFile"></param> internal void LoadData(string dataFile, int loadCountMax = -1) { // step1: clear the database this.versionDb.Clear(); Console.WriteLine("Cleared the database"); // step2: create version table versionDb.CreateVersionTable(TABLE_ID, REDIS_DB_INDEX); Console.WriteLine("Created version table {0}", TABLE_ID); // step3: load data using (StreamReader reader = new StreamReader(dataFile)) { string line; int count = 0; while ((line = reader.ReadLine()) != null) { string[] fields = this.ParseCommandFormat(line); TxWorkload workload = new TxWorkload(fields[0], TABLE_ID, fields[2], fields[3]); count++; ACTION(Tuple.Create(workload, this.versionDb)); if (count % 1000 == 0) { Console.WriteLine("Loaded {0} records", count); } if (count == loadCountMax) { break; } } Console.WriteLine("Load records successfully, {0} records in total", count); } }
static private void CreateTable(VersionDb versionDb, TpccTable table) { versionDb.CreateVersionTable(table.Name()); }