Inheritance: IFileCollection
Esempio n. 1
0
 public File(OnDiskFileCollection owner, uint index, string fileName)
 {
     _owner = owner;
     _index = index;
     _fileName = fileName;
     _stream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read, 1, FileOptions.None);
     _writer = new Writer(this);
 }
Esempio n. 2
0
 public File(OnDiskFileCollection owner, uint index, string fileName)
 {
     _owner    = owner;
     _index    = index;
     _fileName = fileName;
     _stream   = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read, 1, FileOptions.None);
     _writer   = new Writer(this);
 }
Esempio n. 3
0
 static void Main(string[] args)
 {
     if (args.Length < 1)
     {
         Console.WriteLine("Need to have just one parameter with directory of ObjectDB");
         return;
     }
     using (var dfc = new OnDiskFileCollection(args[0]))
     using (var kdb = new KeyValueDB(dfc))
     using (var odb = new ObjectDB())
     {
         odb.Open(kdb, false);
         using (var tr = odb.StartTransaction())
         {
             var visitor = new ToStringVisitor();
             var iterator = new ODBIterator(tr, visitor);
             iterator.Iterate();
             var text = visitor.ToString();
             Console.WriteLine(text);
         }
     }
 }
Esempio n. 4
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Need to have just one parameter with directory of ObjectDB");
                return;
            }
            var action = "dump";
            if (args.Length > 1)
            {
                action = args[1].ToLowerInvariant();
            }

            switch (action)
            {
                case "dump":
                    {
                        using (var dfc = new OnDiskFileCollection(args[0]))
                        using (var kdb = new KeyValueDB(dfc))
                        using (var odb = new ObjectDB())
                        {
                            odb.Open(kdb, false);
                            using (var tr = odb.StartTransaction())
                            {
                                var visitor = new ToStringVisitor();
                                var iterator = new ODBIterator(tr, visitor);
                                iterator.Iterate();
                                var text = visitor.ToString();
                                Console.WriteLine(text);
                            }
                        }
                        break;
                    }
                case "stat":
                    {
                        using (var dfc = new OnDiskFileCollection(args[0]))
                        using (var kdb = new KeyValueDB(dfc))
                        {
                            Console.WriteLine(kdb.CalcStats());
                        }
                        break;
                    }
                case "compact":
                    {
                        using (var dfc = new OnDiskFileCollection(args[0]))
                        using (var kdb = new KeyValueDB(dfc, new SnappyCompressionStrategy(), 100 * 1024 * 1024, null))
                        {
                            Console.WriteLine("Starting first compaction");
                            while (kdb.Compact(new CancellationToken()))
                            {
                                Console.WriteLine(kdb.CalcStats());
                                Console.WriteLine("Another compaction needed");
                            }
                            Console.WriteLine(kdb.CalcStats());
                        }
                        break;
                    }
                case "export":
                    {
                        using (var dfc = new OnDiskFileCollection(args[0]))
                        using (var kdb = new KeyValueDB(dfc))
                        using (var tr = kdb.StartReadOnlyTransaction())
                        using (var st = File.Create(Path.Combine(args[0], "export.dat")))
                        {
                            KeyValueDBExportImporter.Export(tr, st);
                        }
                        break;
                    }
                default:
                    {
                        Console.WriteLine($"Unknown action: {action}");
                        break;
                    }
            }
        }
Esempio n. 5
0
 void DoWork5ReadCheck()
 {
     _sw.Restart();
     using (var fileCollection = new OnDiskFileCollection("data"))
     using (IKeyValueDB db = new KeyValueDB(fileCollection))
     {
         using (var trCheck = db.StartTransaction())
         {
             long pureDataLengthCheck = 0;
             while (trCheck.FindNextKey())
             {
                 pureDataLengthCheck += trCheck.GetKey().Length + trCheck.GetValue().Length;
             }
             if (pureDataLengthCheck != 396130000)
             {
                 throw new Exception("Bug");
             }
         }
     }
     _sw.Stop();
     Console.WriteLine("Time: {0,15}ms", _sw.Elapsed.TotalMilliseconds);
 }