Open() 공개 메소드

public Open ( IKeyValueDB keyValueDB, bool dispose ) : void
keyValueDB IKeyValueDB
dispose bool
리턴 void
예제 #1
0
 static ObjectDB CreateDb(IFileCollection fc)
 {
     var lowDb = new KeyValueDB(fc);
     var db = new ObjectDB();
     db.Open(lowDb, true);
     return db;
 }
예제 #2
0
 static ObjectDB CreateInMemoryDb()
 {
     var lowDb = new InMemoryKeyValueDB();
     var db = new ObjectDB();
     db.Open(lowDb, true);
     return db;
 }
예제 #3
0
파일: Program.cs 프로젝트: tomasdeml/BTDB
 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);
         }
     }
 }
예제 #4
0
파일: Program.cs 프로젝트: Bobris/BTDB
        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;
                    }
            }
        }