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 SyncLoadTpccTablesInto(VersionDb versionDb, string dir) { // foreach (var t in TpccTable.allTypes) // { // SyncLoadTpccTable(TpccTable.Instance(t), versionDb, dir); // } Parallel.ForEach( TpccTable.AllUsedTypes, t => SyncLoadTpccTable(TpccTable.Instance(t), versionDb, dir)); }
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"); }
public override int SaveTo(VersionDb versionDb) { CreateTable(versionDb, TpccTable.Instance(TableType.CUSTOMER_INDEX)); int recordCount = 0; SyncExecution txExec = new SyncExecution(versionDb); foreach (var kv in this.tempStore) { CustomerLastNameIndexKey lastNameKey = kv.Key; List <uint> cids = kv.Value; txExec.Start(); txExec.Insert( lastNameKey, CustomerLastNamePayloads.FromList(cids)); txExec.Commit(); ++recordCount; } return(recordCount); }
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); }
static private void CreateTable(VersionDb versionDb, TpccTable table) { versionDb.CreateVersionTable(table.Name()); }