//static readonly Brush tableBrush = new LinearGradientBrush(new Rectangle(0, 0, Consts.tableBlockLength, bmpHeight), Color.LightBlue, Color.DarkBlue, 0f); private static void DrawTables(FileDBContext db, FileStream fs, Bitmap[] bmps) { TableBlock tableBlockHead = db.GetTableBlockHeadNode(); TableBlock previousTable = tableBlockHead; { long index = previousTable.ThisPos.PagePos() / Consts.pageSize; Bitmap bmp = bmps[index]; Graphics g = Graphics.FromImage(bmp); int length = previousTable.ToBytes().Length; int startPos = (int)(previousTable.ThisPos - Consts.pageSize * index); Brush brush = new LinearGradientBrush(new Point(startPos, 0), new Point(startPos + length), Color.DarkOrange, Color.OrangeRed); g.FillRectangle(brush, startPos, 1, length, bmpHeight - 1); g.DrawRectangle(boundPen, startPos, 1, length, bmpHeight - 1); g.Dispose(); } while (previousTable.NextPos != 0) { previousTable.TryLoadNextObj(fs); TableBlock table = previousTable.NextObj; long index = table.ThisPos.PagePos() / Consts.pageSize; Bitmap bmp = bmps[index]; Graphics g = Graphics.FromImage(bmp); int length = table.ToBytes().Length; int startPos = (int)(table.ThisPos - Consts.pageSize * index); Brush brush = new LinearGradientBrush(new Point(startPos, 0), new Point(startPos + length, 0), Color.DarkOrange, Color.OrangeRed); g.FillRectangle(brush, startPos, 1, length, bmpHeight - 1); g.DrawRectangle(boundPen, startPos, 1, length, bmpHeight - 1); g.Dispose(); previousTable = table; } }
/// <summary> /// 把数据库当前的所有skip list结点和所有key value都画到若干个BMP图片里。 /// </summary> /// <param name="db"></param> /// <param name="directory"></param> /// <param name="prefix">图片文件名前缀</param> public static void SkipListShot(this FileDBContext db, string directory, string prefix = "") { string dir = Path.Combine(directory, "skiplists"); Directory.CreateDirectory(dir); { TableBlock tableBlockHead = db.GetTableBlockHeadNode(); FileStream fs = db.GetFileStream(); TableBlock previousTable = tableBlockHead; while (previousTable.NextPos != 0) { previousTable.TryLoadNextObj(fs); TableBlock table = previousTable.NextObj; PrintTableBlock(table, dir, prefix, db); previousTable = table; } } }