LoadKvsFromDir(string dir, TpccTable table) { string csvPath = FileHelper.CSVPath(dir, table.Type().Name()); foreach (string[] columns in FileHelper.LoadCsv(csvPath)) { yield return(table.ParseColumns(columns)); } }
static void SyncLoadTpccTable( TpccTable table, VersionDb versionDb, string dir) { Console.WriteLine($"Start loading table: '{table.Type().Name()}'"); var startTime = DateTime.UtcNow; int c = TPCCTableLoader.Load(dir, table, versionDb); var time = (DateTime.UtcNow - startTime).TotalSeconds; Console.WriteLine( $"{c} records in '{table.Name()}' loaded in {time:F3} sec"); }
int Load(string dir, TpccTable table, VersionDb versionDb) { CreateTable(versionDb, table); int recordCount = 0; var txExec = new SyncExecution(versionDb, (int)table.Type()); var auxIndexLoader = AuxIndexLoader.FromTableType(table.Type()); foreach (var kv in LoadKvsFromDir(dir, table)) { txExec.Start(); if (txExec.Insert(kv.Item1, kv.Item2).IsAborted()) { continue; } if (txExec.Commit().IsAborted()) { continue; } auxIndexLoader.BuildAuxIndex(kv.Item1, kv.Item2); ++recordCount; } recordCount += auxIndexLoader.SaveTo(versionDb); return(recordCount); }