public static void do_bringup_test(DbgGUI win) { LayerManager db = new LayerManager(InitMode.NEW_REGION,"c:\\BENDtst\\main"); db.setValueParsed("test/3","a"); db.setValueParsed("test/2","b"); db.setValueParsed("test/1","c"); db.debugDump(); db.flushWorkingSegment(); // this will flush and read the current segment Console.WriteLine("--- after flush"); db.debugDump(); dumpMergeCandidates(db); Console.WriteLine("--- check record read"); RecordData data; GetStatus status = db.getRecord(new RecordKey().appendParsedKey("test/3"), out data); System.Console.WriteLine("getRecord({0}) returned {1}", "test/3", data.ToString()); Console.WriteLine("--- make lots of segments"); db.setValueParsed("test/4", "d"); db.flushWorkingSegment(); db.setValueParsed("test/5", "e"); db.flushWorkingSegment(); db.setValueParsed("test/6", "f"); db.flushWorkingSegment(); db.debugDump(); System.Console.WriteLine("-------- dump keys ---------------------"); dumpAllDbRecords(db); dumpMergeCandidates(db); System.Console.WriteLine("-------- draw graphical debug ---------------------"); win.debugDump(db); System.Console.WriteLine("-------- PERFORMING A SINGLE MERGE ---------------------"); MergeCandidate mc; mc = db.rangemapmgr.mergeManager.getBestCandidate(); System.Console.WriteLine("MERGE :" + mc); db.performMerge(mc); dumpMergeCandidates(db); db.flushWorkingSegment(); db.debugDump(); dumpSegmentList(db); win.debugDump(db); System.Console.WriteLine("-------- SINGLE MERGE DONE, close/dispose ---------------------"); dumpSegmentList(db); dumpMergeCandidates(db); db.debugDump(); db.Dispose(); System.Console.WriteLine("-------- NOW RESUME ---------------------------------"); db = new LayerManager(InitMode.RESUME, "c:\\BENDtst\\main"); dumpSegmentList(db); dumpMergeCandidates(db); win.debugDump(db); db.debugDump(); System.Console.WriteLine("-------- NOW FINDNEXT ---------------------------------"); dumpAllDbRecords(db); win.debugDump(db); System.Console.WriteLine("-------- NOW MERGE ALL SEGMENTS ---------------------------------"); dumpSegmentList(db); db.mergeAllSegments(); db.debugDump(); win.debugDump(db); // stop(); // ------------------------- (( S T O P )) --------------------------------- System.Console.WriteLine("-------- NOW FINDNEXT (after merge) ---------------------------------"); dumpAllDbRecords(db); //System.Console.WriteLine("-------- Now run Readthreads Test ---------------------------------"); //A03_LayerManagerTests test = new A03_LayerManagerTests(); //test.T10_LayerManager_ReadThreads(); dumpMergeCandidates(db); win.debugDump(db); db.Dispose(); System.Console.WriteLine("-------- Write ALOT of data ---------------------------------"); int keysize = 20 ; int keycount = 1000000; int flush_period = 40000; int commit_period = 1000; bool random_order = true; double elapsed; DateTime start = DateTime.Now; int record_count = 0; db = new LayerManager(InitMode.NEW_REGION, "c:\\BENDtst\\bigtest"); String value = ""; String keybase = "TestValueDataABC"; for (int x = 0; x < keysize / keybase.Length; x++) { value = value + keybase; } int seed = (int)DateTime.Now.Ticks; Random rnd = new Random(seed); System.Console.WriteLine("*** RANDOM SEED: " + seed); var write_group = db.newWriteGroup(); for (int x = 10000001; x < 10000001 + keycount; x++) { if (random_order) { write_group.setValueParsed("test/rnd/" + rnd.Next(), value); } else { write_group.setValueParsed("test/ordered/" + x, value); } record_count++; if (x % commit_period == 0) { write_group.finish(); write_group = db.newWriteGroup(); } if (x % flush_period == 0) { System.Console.WriteLine("*** RANDOM SEED: " + seed); write_group.finish(); write_group = db.newWriteGroup(); System.Console.WriteLine("start % 1000 cycle.."); db.flushWorkingSegment(); db.freespacemgr.debugDumbCurrentFreespace(); win.debugDump(db); dumpMergeCandidates(db); for (int mx = 0; mx < 30; mx++) { mc = db.rangemapmgr.mergeManager.getBestCandidate(); if (mc == null) { break; } if (mc.score() > (1.6 + (float)db.rangemapmgr.mergeManager.getMaxGeneration()/12.0f)) { System.Console.WriteLine("** best merge score too high: " + mc); break; } System.Console.WriteLine("merge " + mx + " : " + mc); win.debugDump(db, mc); db.performMerge(mc); System.Console.WriteLine("mergedone " + mx + " : " + mc); dumpSegmentList(db); dumpMergeCandidates(db); win.debugDump(db); } elapsed = (DateTime.Now - start).TotalMilliseconds / 1000.0; System.GC.Collect(); Console.WriteLine("*************************************************"); Console.WriteLine("*************************************************"); Console.WriteLine("*** merge cycle done {0} records so far, in {1} total time, {2} records/second", record_count,elapsed, (double)record_count/elapsed); Console.WriteLine("*************************************************"); Console.WriteLine("*************************************************"); } } System.Console.WriteLine("-------- Merge a bunch more ------------------"); for (int x = 0; x < 30; x++) { mc = db.rangemapmgr.mergeManager.getBestCandidate(); System.Console.WriteLine("merge : " + mc); if (mc == null) break; win.debugDump(db, mc); db.performMerge(mc); dumpSegmentList(db); dumpMergeCandidates(db); win.debugDump(db,null); } dumpSegmentList(db); elapsed = (DateTime.Now - start).TotalMilliseconds / 1000.0; Console.WriteLine("*************************************************"); Console.WriteLine("*************************************************"); Console.WriteLine("*** merge cycle done {0} records so far, in {1} total time, {2} records/second", record_count, elapsed, (double)record_count / elapsed); Console.WriteLine("*************************************************"); Console.WriteLine("*************************************************"); System.Console.WriteLine("** done."); Environment.Exit(0); }