コード例 #1
0
		private MemoryBin NewBin(int initialSize, IGrowthStrategy strategy)
		{
			MemoryStorage storage = new MemoryStorage(strategy);
			MemoryBin bin = (MemoryBin)storage.Open(new BinConfiguration(Uri, false, initialSize
				, false));
			return bin;
		}
コード例 #2
0
 private IEmbeddedConfiguration Config(MemoryStorage storage)
 {
     var config = Db4oEmbedded.NewConfiguration();
     config.File.Storage = storage;
     config.Common.ReflectWith(Platform4.ReflectorForType(typeof (Item
         )));
     return config;
 }
コード例 #3
0
 public static void UsingMemoryStorage()
 {
     // #example: Using memory-storage
     IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
     MemoryStorage memory = new MemoryStorage();
     configuration.File.Storage = memory;
     IObjectContainer container = Db4oEmbedded.OpenFile(configuration, "database.db4o");
     // #end example
 }
コード例 #4
0
 public static void SpecifyGrowStrategyForMemoryStorage()
 {
     IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();
     // #example: Using memory-storage with constant grow strategy
     IGrowthStrategy growStrategy = new ConstantGrowthStrategy(100);
     MemoryStorage memory = new MemoryStorage(growStrategy);
     configuration.File.Storage = memory;
     // #end example
     IObjectContainer container = Db4oEmbedded.OpenFile(configuration, "database.db4o");
 }
コード例 #5
0
 public virtual void Test()
 {
     var origStorage = new MemoryStorage();
     var origConfig = Config(origStorage);
     IObjectContainer origDb = Db4oEmbedded.OpenFile(origConfig, BinUri);
     origDb.Store(new Item(ItemName));
     origDb.Close();
     var origBin = origStorage.Bin(BinUri);
     var data = origBin.Data();
     Assert.AreEqual(data.Length, origBin.Length());
     var newBin = new MemoryBin(data, new DoublingGrowthStrategy());
     var newStorage = new MemoryStorage();
     newStorage.Bin(BinUri, newBin);
     IObjectContainer newDb = Db4oEmbedded.OpenFile(Config(newStorage), BinUri);
     var result = newDb.Query(typeof (Item));
     Assert.AreEqual(1, result.Count);
     Assert.AreEqual(ItemName, ((Item) result.Next())._name
         );
     newDb.Close();
 }
コード例 #6
0
		public virtual void Test()
		{
			MemoryStorage origStorage = new MemoryStorage();
			IEmbeddedConfiguration origConfig = Config(origStorage);
			IObjectContainer origDb = Db4oEmbedded.OpenFile(origConfig, BinUri);
			origDb.Store(new MemoryBinIsReusableTestCase.Item(ItemName));
			origDb.Close();
			MemoryBin origBin = origStorage.Bin(BinUri);
			byte[] data = origBin.Data();
			Assert.AreEqual(data.Length, origBin.Length());
			MemoryBin newBin = new MemoryBin(data, new DoublingGrowthStrategy());
			MemoryStorage newStorage = new MemoryStorage();
			newStorage.Bin(BinUri, newBin);
			IObjectContainer newDb = Db4oEmbedded.OpenFile(Config(newStorage), BinUri);
			IObjectSet result = newDb.Query(typeof(MemoryBinIsReusableTestCase.Item));
			Assert.AreEqual(1, result.Count);
			Assert.AreEqual(ItemName, ((MemoryBinIsReusableTestCase.Item)result.Next())._name
				);
			newDb.Close();
		}
コード例 #7
0
ファイル: Main.cs プロジェクト: Galigator/db4o
		public static void RunTest ()
		{
			MemoryStorage storage = new MemoryStorage();
			
			StoreSomething(Prepare(storage)).Close();
			
			/*System.GC.Collect();
			
			for(int i=0;i<count;i++)
			{
				Query(storage);
			}*/

			Stopwatch sw = new Stopwatch();
			
			System.GC.Collect();
			/*sw.Start();
			
			for(int i=0;i<count;i++)
			{
				Prepare(storage).Close();
			}
			
			sw.Stop();
			
			long otherStuff = sw.ElapsedMilliseconds;
			
			sw.Reset();
			System.GC.Collect();*/
			
			sw.Start();
			
			for(int i=0;i<count;i++)
			{
				Query(storage);
			}
			
			sw.Stop();
			
			Console.WriteLine("Elapsed: " + (sw.ElapsedMilliseconds));
		}
コード例 #8
0
			/// <exception cref="System.Exception"></exception>
			public override void SetUp()
			{
				_memoryStorage = new MemoryStorage();
			}
コード例 #9
0
			private DefragmentConfig DefragmentConfig(MemoryStorage storage)
			{
				DefragmentConfig defragConfig = new DefragmentConfig(Uri, TempFile(), new InMemoryIdMapping
					());
				defragConfig.Db4oConfig(Config(storage));
				defragConfig.BackupStorage(BackupStorage());
				return defragConfig;
			}
コード例 #10
0
 public void Setup()
 {
     storage = new MemoryStorage();
 }
コード例 #11
0
 public void Setup()
 {
     fileSystem = new MemoryStorage();
     this.toTest = new IdGenerator();
 }