コード例 #1
0
ファイル: CachedIoAdapter.cs プロジェクト: masroore/db4o
 /// <summary>
 ///     Creates an instance of CachedIoAdapter with a custom page size and page
 ///     count.<br />
 /// </summary>
 /// <param name="ioAdapter">delegate IO adapter (RandomAccessFileAdapter by default)</param>
 /// <param name="pageSize">cache page size</param>
 /// <param name="pageCount">allocated amount of pages</param>
 public CachedIoAdapter(IoAdapter ioAdapter, int pageSize, int pageCount)
 {
     // private Hashtable4 _posPageMap = new Hashtable4(PAGE_COUNT);
     _io = ioAdapter;
     _pageSize = pageSize;
     _pageCount = pageCount;
 }
コード例 #2
0
ファイル: CachedIoAdapter.cs プロジェクト: pondyond/db4o
 /// <summary>
 ///     Creates an instance of CachedIoAdapter with a custom page size and page
 ///     count.<br />
 /// </summary>
 /// <param name="ioAdapter">delegate IO adapter (RandomAccessFileAdapter by default)</param>
 /// <param name="pageSize">cache page size</param>
 /// <param name="pageCount">allocated amount of pages</param>
 public CachedIoAdapter(IoAdapter ioAdapter, int pageSize, int pageCount)
 {
     // private Hashtable4 _posPageMap = new Hashtable4(PAGE_COUNT);
     _io        = ioAdapter;
     _pageSize  = pageSize;
     _pageCount = pageCount;
 }
コード例 #3
0
 public LoggingIoAdapter(IoAdapter delegateAdapter, string fileName, int config, TextWriter existingOut)
     :
     base(delegateAdapter)
 {
     _fileName = fileName;
     _out = existingOut;
     _config = config;
 }
コード例 #4
0
		protected virtual void Open(bool readOnly)
		{
			if (null != _adapter)
			{
				throw new InvalidOperationException();
			}
			_adapter = Factory().Open(TempFile(), false, 0, readOnly);
		}
コード例 #5
0
		protected virtual void Close()
		{
			if (null != _adapter)
			{
				_adapter.Close();
				_adapter = null;
			}
		}
コード例 #6
0
ファイル: LogReplayer.cs プロジェクト: bvangrinsven/db4o-net
 public LogReplayer(String logFilePath, IoAdapter io, ISet commands)
 {
     _logFilePath = logFilePath;
     _io = io;
     _commands = commands;
     _counts = new Hashtable();
     foreach (object com in commands)
     {
         _counts[com] = (Int64)0;
     }
 }
コード例 #7
0
ファイル: CachedIoAdapter.cs プロジェクト: pondyond/db4o
 /// <summary>Creates an instance of CachedIoAdapter with extended parameters.<br /></summary>
 /// <param name="path">database file path</param>
 /// <param name="lockFile">determines if the file should be locked</param>
 /// <param name="initialLength">
 ///     initial file length, new writes will start from this point
 /// </param>
 /// <param name="readOnly">
 ///     if the file should be used in read-onlyt mode.
 /// </param>
 /// <param name="io">delegate IO adapter (RandomAccessFileAdapter by default)</param>
 /// <param name="pageSize">cache page size</param>
 /// <param name="pageCount">allocated amount of pages</param>
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 public CachedIoAdapter(string path, bool lockFile, long initialLength, bool readOnly
                        , IoAdapter io, int pageSize, int pageCount)
 {
     _readOnly  = readOnly;
     _pageSize  = pageSize;
     _pageCount = pageCount;
     InitCache();
     InitIOAdaptor(path, lockFile, initialLength, readOnly, io);
     _position    = initialLength;
     _filePointer = initialLength;
     _fileLength  = _io.GetLength();
 }
コード例 #8
0
		public LoggingIoAdapter(IoAdapter delegateAdapter, string fileName, int config) : 
			base(delegateAdapter)
		{
			_fileName = fileName;
            try
            {
                _out = new StreamWriter(new FileStream(fileName, FileMode.Append, FileAccess.Write));
            }
            catch (FileNotFoundException e)
            {
                throw new Db4oIOException(e);
            }
        
			_config = config;
		}
コード例 #9
0
ファイル: IoBenchmark.cs プロジェクト: pondyond/db4o
        /// <exception cref="IOException"></exception>
        private void BenchmarkCommand(string command, int itemCount, string dbFileName, TextWriter
                                      @out)
        {
            HashSet commands = CommandSet(command);

            Db4objects.Db4o.IO.IoAdapter io = IoAdapter(dbFileName);
            LogReplayer replayer            = new LogReplayer(CrudApplication.LogFileName(itemCount), io
                                                              , commands);
            List4     commandList = replayer.ReadCommandList();
            StopWatch watch       = new StopWatch();

            watch.Start();
            replayer.PlayCommandList(commandList);
            watch.Stop();
            io.Close();
            long timeElapsed    = watch.Elapsed();
            long operationCount = ((long)replayer.OperationCounts()[command]);

            PrintStatisticsForCommand(@out, command, timeElapsed, operationCount);
        }
コード例 #10
0
ファイル: IoBenchmark.cs プロジェクト: pondyond/db4o
        private void PrepareDbFile(int itemCount)
        {
            Sysout("Preparing DB file ...");
            DeleteFile(_dbFileName);
            Db4objects.Db4o.IO.IoAdapter rafFactory = new RandomAccessFileAdapter();
            Db4objects.Db4o.IO.IoAdapter raf        = rafFactory.Open(_dbFileName, false, 0, false);
            LogReplayer replayer = new LogReplayer(CrudApplication.LogFileName(itemCount), raf
                                                   );

            try
            {
                replayer.ReplayLog();
            }
            catch (IOException)
            {
                ExitWithError("Error reading I/O operations log file");
            }
            finally
            {
                raf.Close();
            }
        }
コード例 #11
0
 public NonFlushingIoAdapter(IoAdapter delegateAdapter) : base(delegateAdapter)
 {
 }
コード例 #12
0
 public IoAdapterStorage(IoAdapter io)
 {
     _io = io;
 }
コード例 #13
0
ファイル: IoAdapterTest.cs プロジェクト: masroore/db4o
 /// <exception cref="System.Exception"></exception>
 private void AssertReadWriteString(IoAdapter adapter, string str)
 {
     var data = Runtime.GetBytesForString(str);
     var read = new byte[2048];
     adapter.Seek(0);
     adapter.Write(data);
     adapter.Seek(0);
     adapter.Read(read);
     Assert.AreEqual(str, Runtime.GetStringForBytes(read, 0, data.Length));
 }
コード例 #14
0
		public DebugIoAdapter(IoAdapter delegateAdapter) : base(delegateAdapter)
		{
		}
コード例 #15
0
ファイル: DebugIoAdapter.cs プロジェクト: git-thinh/limada
 public DebugIoAdapter(IoAdapter delegateAdapter) : base(delegateAdapter)
 {
 }
コード例 #16
0
ファイル: SyncCommand.cs プロジェクト: erdincay/db4o
		public virtual void Replay(IoAdapter adapter)
		{
			adapter.Sync();
		}
コード例 #17
0
		/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
		public DelayingIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile, long
			 initialLength, Delays delays) : this(delegateAdapter.Open(path, lockFile, initialLength
			, false), delays)
		{
		}
コード例 #18
0
ファイル: CachedIoAdapter.cs プロジェクト: pondyond/db4o
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 private void InitIOAdaptor(string path, bool lockFile, long initialLength, bool readOnly
                            , IoAdapter io)
 {
     _io = io.Open(path, lockFile, initialLength, readOnly);
 }
コード例 #19
0
ファイル: CachedIoAdapter.cs プロジェクト: pondyond/db4o
 /// <summary>
 ///     Creates an instance of CachedIoAdapter with the default page size and
 ///     page count.
 /// </summary>
 /// <remarks>
 ///     Creates an instance of CachedIoAdapter with the default page size and
 ///     page count.
 /// </remarks>
 /// <param name="ioAdapter">delegate IO adapter (RandomAccessFileAdapter by default)</param>
 public CachedIoAdapter(IoAdapter ioAdapter) : this(ioAdapter, DefaultPageSize, DefaultPageCount
                                                    )
 {
 }
コード例 #20
0
ファイル: WriteCommand.cs プロジェクト: erdincay/db4o
		public virtual void Replay(IoAdapter adapter)
		{
			adapter.Write(PrepareBuffer());
		}
コード例 #21
0
		/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
		private NonFlushingIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile
			, long initialLength, bool readOnly) : base(delegateAdapter, path, lockFile, initialLength
			, readOnly)
		{
		}
コード例 #22
0
		public NonFlushingIoAdapter(IoAdapter delegateAdapter) : base(delegateAdapter)
		{
		}
コード例 #23
0
ファイル: VanillaIoAdapter.cs プロジェクト: masroore/db4o
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 protected VanillaIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile,
     long initialLength, bool readOnly) : this(delegateAdapter.Open(path, lockFile, initialLength
         , readOnly))
 {
 }
コード例 #24
0
ファイル: IoAdapterStorage.cs プロジェクト: erdincay/db4o
		public IoAdapterStorage(IoAdapter io)
		{
			_io = io;
		}
コード例 #25
0
ファイル: CachedIoAdapter.cs プロジェクト: masroore/db4o
 /// <summary>
 ///     Creates an instance of CachedIoAdapter with the default page size and
 ///     page count.
 /// </summary>
 /// <remarks>
 ///     Creates an instance of CachedIoAdapter with the default page size and
 ///     page count.
 /// </remarks>
 /// <param name="ioAdapter">delegate IO adapter (RandomAccessFileAdapter by default)</param>
 public CachedIoAdapter(IoAdapter ioAdapter) : this(ioAdapter, DefaultPageSize, DefaultPageCount
     )
 {
 }
コード例 #26
0
ファイル: IoAdapterStorage.cs プロジェクト: erdincay/db4o
			public IoAdapterBin(IoAdapter io)
			{
				_io = io;
			}
コード例 #27
0
ファイル: CachedIoAdapter.cs プロジェクト: masroore/db4o
 /// <summary>Creates an instance of CachedIoAdapter with extended parameters.<br /></summary>
 /// <param name="path">database file path</param>
 /// <param name="lockFile">determines if the file should be locked</param>
 /// <param name="initialLength">
 ///     initial file length, new writes will start from this point
 /// </param>
 /// <param name="readOnly">
 ///     if the file should be used in read-onlyt mode.
 /// </param>
 /// <param name="io">delegate IO adapter (RandomAccessFileAdapter by default)</param>
 /// <param name="pageSize">cache page size</param>
 /// <param name="pageCount">allocated amount of pages</param>
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 public CachedIoAdapter(string path, bool lockFile, long initialLength, bool readOnly
     , IoAdapter io, int pageSize, int pageCount)
 {
     _readOnly = readOnly;
     _pageSize = pageSize;
     _pageCount = pageCount;
     InitCache();
     InitIOAdaptor(path, lockFile, initialLength, readOnly, io);
     _position = initialLength;
     _filePointer = initialLength;
     _fileLength = _io.GetLength();
 }
コード例 #28
0
		/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
		public DelayingIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile, long
			 initialLength) : this(delegateAdapter, path, lockFile, initialLength, _delays)
		{
		}
コード例 #29
0
ファイル: DebugIoAdapter.cs プロジェクト: git-thinh/limada
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 protected DebugIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile, long
                          initialLength, bool readOnly) : base(delegateAdapter.Open(path, lockFile, initialLength
                                                                                    , readOnly))
 {
 }
コード例 #30
0
ファイル: VanillaIoAdapter.cs プロジェクト: danfma/db4o-net
 public VanillaIoAdapter(IoAdapter delegateAdapter)
 {
     _delegate = delegateAdapter;
 }
コード例 #31
0
		/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
		protected DebugIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile, long
			 initialLength, bool readOnly) : base(delegateAdapter.Open(path, lockFile, initialLength
			, readOnly))
		{
		}
コード例 #32
0
		public void Io(IoAdapter adapter)
		{
			GlobalSettingOnly();
			Storage = new IoAdapterStorage(adapter);
		}
コード例 #33
0
ファイル: IoAdapterTest.cs プロジェクト: masroore/db4o
 /// <exception cref="System.Exception"></exception>
 private void AssertReadWriteAheadFileEnd(IoAdapter adapter, string str)
 {
     var data = Runtime.GetBytesForString(str);
     var read = new byte[2048];
     adapter.Seek(10);
     var readBytes = adapter.Read(data);
     Assert.AreEqual(-1, readBytes);
     Assert.AreEqual(0, adapter.GetLength());
     adapter.Seek(0);
     readBytes = adapter.Read(data);
     Assert.AreEqual(-1, readBytes);
     Assert.AreEqual(0, adapter.GetLength());
     adapter.Seek(10);
     adapter.Write(data);
     Assert.AreEqual(10 + data.Length, adapter.GetLength());
     adapter.Seek(0);
     readBytes = adapter.Read(read);
     Assert.AreEqual(10 + data.Length, readBytes);
     adapter.Seek(20 + data.Length);
     readBytes = adapter.Read(read);
     Assert.AreEqual(-1, readBytes);
     adapter.Seek(1024 + data.Length);
     readBytes = adapter.Read(read);
     Assert.AreEqual(-1, readBytes);
     adapter.Seek(1200);
     adapter.Write(data);
     adapter.Seek(0);
     readBytes = adapter.Read(read);
     Assert.AreEqual(1200 + data.Length, readBytes);
 }
コード例 #34
0
		public DelayingIoAdapter(IoAdapter delegateAdapter, Delays delays) : base(delegateAdapter
			)
		{
			_delays = delays;
			_timing = new TicksTiming();
		}
コード例 #35
0
 public IoAdapterBin(IoAdapter io)
 {
     _io = io;
 }
コード例 #36
0
		private void WriteBytes(IoAdapter io, int numBytes)
		{
			io.Write(new byte[numBytes]);
		}
コード例 #37
0
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 private NonFlushingIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile
                              , long initialLength, bool readOnly) : base(delegateAdapter, path, lockFile, initialLength
                                                                          , readOnly)
 {
 }
コード例 #38
0
ファイル: CachedIoAdapter.cs プロジェクト: masroore/db4o
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 private void InitIOAdaptor(string path, bool lockFile, long initialLength, bool readOnly
     , IoAdapter io)
 {
     _io = io.Open(path, lockFile, initialLength, readOnly);
 }
コード例 #39
0
ファイル: LogReplayer.cs プロジェクト: bvangrinsven/db4o-net
 public LogReplayer(String logFilePath, IoAdapter io): this(logFilePath, io, LogConstants.AllEntries())
 {
     
 }
コード例 #40
0
ファイル: VanillaIoAdapter.cs プロジェクト: masroore/db4o
 public VanillaIoAdapter(IoAdapter delegateAdapter)
 {
     _delegate = delegateAdapter;
 }
コード例 #41
0
ファイル: VanillaIoAdapter.cs プロジェクト: danfma/db4o-net
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 protected VanillaIoAdapter(IoAdapter delegateAdapter, string path, bool lockFile,
                            long initialLength, bool readOnly) : this(delegateAdapter.Open(path, lockFile, initialLength
                                                                                           , readOnly))
 {
 }
コード例 #42
0
 private void AssertReadOnly(IoAdapter adapter)
 {
     Assert.Expect(typeof (Db4oIOException), new _ICodeBlock_21(adapter));
 }
コード例 #43
0
ファイル: ReadCommand.cs プロジェクト: erdincay/db4o
		public virtual void Replay(IoAdapter adapter)
		{
			adapter.Read(PrepareBuffer(), _length);
		}
コード例 #44
0
 public _ICodeBlock_21(IoAdapter adapter)
 {
     this.adapter = adapter;
 }