示例#1
0
 static void countAllSegments()
 {
     int count = 0;
     LayerManager db = new LayerManager(InitMode.RESUME, @"c:\EmailTest\DB");
     foreach (var seg in db.listAllSegments()) {
         count++;
         Console.WriteLine(seg);
     }
     Console.WriteLine("{0} segments", count);
 }
示例#2
0
        public static void dumpSegmentList(LayerManager db)
        {
            #if true
                // this is the slow method

                var walk = db.rangemapmgr.mergeManager.segmentInfo.GetEnumerator();

                bool discrepancy = false;

                foreach (var seg in db.listAllSegments()) {

                    // Assert.AreEqual(true, walk.MoveNext(), "mergemanager missing record!");
                    // Assert.AreEqual(0, walk.Current.Key.CompareTo(seg), "mergemanager and db.listAllSegments have different data!");
                    if (walk.MoveNext()) {
                        if (walk.Current.Key.CompareTo(seg) != 0) {
                            discrepancy = true;
                            Console.WriteLine("  mismatch: db{0} mm{1}", seg, walk.Current.Key);
                        }
                    } else { discrepancy = true; }

                    System.Console.WriteLine("db gen{0} start({1}) end({2})", seg.generation, seg.start_key, seg.end_key);
                }

                if (discrepancy) {
                    foreach (var seginfo in db.rangemapmgr.mergeManager.segmentInfo) {
                        var seg = seginfo.Key;
                        System.Console.WriteLine("mm gen{0} start({1}) end({2})", seg.generation, seg.start_key, seg.end_key);
                    }
                    throw new Exception("mergemanager and db.listAllSegments have different data!");
                }
            #else
                // this is the fast method
                foreach (var seginfo in db.rangemapmgr.mergeManager.segmentInfo) {
                    var seg = seginfo.Key;
                    System.Console.WriteLine("fgen{0} start({1}) end({2})", seg.generation, seg.start_key, seg.end_key);
                }
            #endif
        }