Memory storage
Inheritance: IDisposable
Example #1
0
 /// <summary>
 /// 
 /// </summary>
 public void Table_Dispose()
 {
     lock (lock_fs)
     {
         if (_fsData != null)
         {
             _fsData.Dispose();
             _fsData = null;
         }
         if (_fsRollback != null)
         {
             _fsRollback.Dispose();
             _fsRollback = null;
         }
         if (_fsRollbackHelper != null)
         {
             _fsRollbackHelper.Dispose();
             _fsRollbackHelper = null;
         }
     }
 }
Example #2
0
        private void InitFiles()
        {
            //Creates filestreams and rollbacks, restores rollback to the initial file, if necessary

            try
            {
                this._fsData = new MemoryStorage(1024 * 16, 1024 * 500, MemoryStorage.eMemoryExpandStartegy.FIXED_LENGTH_INCREASE);
                this._fsRollback = new MemoryStorage(1024 * 16, 1024 * 128, MemoryStorage.eMemoryExpandStartegy.FIXED_LENGTH_INCREASE);
                this._fsRollbackHelper = new MemoryStorage(8, 10, MemoryStorage.eMemoryExpandStartegy.FIXED_LENGTH_INCREASE);

                //Writing root
                this._fsData.Write_ToTheEnd(new byte[64]);

                eofData = this._fsData.EOF;

                _storageFixTime = DateTime.UtcNow;
            }
            catch (Exception ex)
            {
                IsOperable = false;
                throw DBreezeException.Throw(DBreezeException.eDBreezeExceptions.DB_IS_NOT_OPERABLE, "MSR INIT FAILED: " + this._fileName, ex);
            }
        }
Example #3
0
        private void TestMemoryStorage()
        {
            if (memoryEngine == null)
            {
                memoryEngine = new DBreezeEngine(new DBreezeConfiguration()
                {
                     Storage = DBreezeConfiguration.eStorage.MEMORY
                });
            }

            //SortedDictionary<string, int> _d = new SortedDictionary<string, int>();

            //DBreeze.Diagnostic.SpeedStatistic.StartCounter("a");
            //DateTime dt=new DateTime(1970,1,1);

            //for (int i = 0; i < 1000000; i++)
            //{
            //    _d.Add(dt.Ticks.ToString(), i);
            //    dt=dt.AddSeconds(7);
            //}

            //DBreeze.Diagnostic.SpeedStatistic.PrintOut("a", true);

            //DBreeze.Diagnostic.SpeedStatistic.StartCounter("a");
            //int c1 = 0;
            //foreach (var row in _d.OrderBy(r => r.Key))
            //{
            //    c1++;
            //}
            //DBreeze.Diagnostic.SpeedStatistic.PrintOut("a", true);
            //Console.WriteLine(c1);

            //memoryEngine.Scheme.DeleteTable("t1");

            //DBreeze.Diagnostic.SpeedStatistic.StartCounter("a");
            ////DateTime dt = new DateTime(1970, 1, 1);

            //using (var tran = memoryEngine.GetTransaction())
            //{
            //    for (int i = 0; i < 1000000; i++)
            //    {
            //  //      tran.Insert<string, int>("t1", dt.Ticks.ToString(), i);
            //    //    dt = dt.AddSeconds(7);

            //        tran.Insert<byte[], byte[]>("t1", i.To_4_bytes_array_BigEndian(), i.To_4_bytes_array_BigEndian());

            //    }

            //    //Console.WriteLine(tran.Count("t1"));
            //    tran.Commit();
            //}

            //DBreeze.Diagnostic.SpeedStatistic.PrintOut("a", true);

            //int c1 = 0;

            //DBreeze.Diagnostic.SpeedStatistic.StartCounter("a");

            //using (var tran = memoryEngine.GetTransaction())
            //{
            //    DBreeze.Diagnostic.SpeedStatistic.StartCounter("a");

            //    foreach (var row in tran.SelectForward<string, int>("t1"))
            //    {
            //        c1++;
            //    }

            //    DBreeze.Diagnostic.SpeedStatistic.PrintOut("a", true);
            //    Console.WriteLine(c1);
            //}

            ms = new MemoryStorage(10, 10, MemoryStorage.eMemoryExpandStartegy.FIXED_LENGTH_INCREASE);

            ms.Write_ToTheEnd(new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
            ms.Write_ToTheEnd(new byte[] { 1, 1, 1, 1, 1 });
            //ms.Write_ByOffset(17,new byte[] { 1, 1, 1, 1, 1 });
            //Console.WriteLine(ms.MemorySize);
            //Console.WriteLine(ms.Read(0, ms.MemorySize).ToBytesString(""));
            Console.WriteLine(ms.GetFullData().Length);
        }