Example #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;
		}
 private IEmbeddedConfiguration Config(MemoryStorage storage)
 {
     var config = Db4oEmbedded.NewConfiguration();
     config.File.Storage = storage;
     config.Common.ReflectWith(Platform4.ReflectorForType(typeof (Item
         )));
     return config;
 }
 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
 }
 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");
 }
 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();
 }
		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();
		}
Example #7
0
		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));
		}
			/// <exception cref="System.Exception"></exception>
			public override void SetUp()
			{
				_memoryStorage = new MemoryStorage();
			}
			private DefragmentConfig DefragmentConfig(MemoryStorage storage)
			{
				DefragmentConfig defragConfig = new DefragmentConfig(Uri, TempFile(), new InMemoryIdMapping
					());
				defragConfig.Db4oConfig(Config(storage));
				defragConfig.BackupStorage(BackupStorage());
				return defragConfig;
			}
 public void Setup()
 {
     storage = new MemoryStorage();
 }
 public void Setup()
 {
     fileSystem = new MemoryStorage();
     this.toTest = new IdGenerator();
 }