public void AssignToNew(string filename, IPageFormatter pageFormatter) { Flush(); pageFormatter.Format(_page); _ = _page.Append(filename, out _block); _pins = 0; }
public Buffer PinNew(string filename, IPageFormatter pageFormatter) { //try //{ long timestamp = DateTime.UtcNow.Ticks; Buffer buffer = null; lock (_bufferGatheringLock) { buffer = _poolStrategy.PinNew(filename, pageFormatter); } while (buffer == null && !WaitingForTooLong(timestamp)) { Thread.Sleep(_tickWaitingTime); lock (_bufferGatheringLock) { buffer = _poolStrategy.PinNew(filename, pageFormatter); } } if (buffer == null) { throw new BufferBusyException(); } return(buffer); //} //catch (ThreadAbortException) //{ // throw new BufferBusyException(); //} }
public void CanCreateRecordFormatter() { _tableInfo = new TableInfo(RandomFilename, _schema); Assert.DoesNotThrow(() => { _recordFormatter = new RecordFormatter(_tableInfo, _fileManager); }); }
/// <summary> /// Initializes a new instance of the <see cref="Formatter"/> class. /// </summary> /// <param name="orderByFormatter">The order by formatter.</param> /// <param name="pageFormatter">The page formatter.</param> /// <param name="whereFormatter">The where formatter.</param> public Formatter( [NotNull] IOrderByFormatter orderByFormatter, [NotNull] IPageFormatter pageFormatter, [NotNull] IWhereFormatter whereFormatter) { this.orderByFormatter = orderByFormatter; this.pageFormatter = pageFormatter; this.whereFormatter = whereFormatter; }
public void Setup() { _fileManager = new FileManager("temp", "DBs", 100); _logManager = new LogManager(_fileManager, RandomFilename); _pageFormatter = new BasePageFormatter(); // TODO MOCK POOL STRATEGY!!! // Or not? It seems default, mock would be like native... // Anyway, think about it a bit }
public Block PinNew(string filename, IPageFormatter pageFormatter) { var buffer = _bufferManager.PinNew(filename, pageFormatter); var block = buffer.Block; _buffers.TryAdd(block, buffer); _pins.Add(block); return(block); }
public void CanFormatPageWithNoRecordsInside() { _tableInfo = new TableInfo(RandomFilename, _schema); _recordFormatter = new RecordFormatter(_tableInfo, _fileManager); var page = _fileManager.ResolvePage(); Assert.DoesNotThrow(() => { _recordFormatter.Format(page); }); }
public Block Append(string filename, IPageFormatter pageFormatter) { // A dummy block because honestly we do not care about block, we need to get length of this file var dummyBlock = new Block(filename, -1); _concurrencyManager.ExclusiveLock(dummyBlock); var lastBlock = _bufferList.PinNew(filename, pageFormatter); return(lastBlock); }
public void CanFormatPageWithOneStringFieldInside() { _schema.AddStringField("field", 30); _tableInfo = new TableInfo(RandomFilename, _schema); _recordFormatter = new RecordFormatter(_tableInfo, _fileManager); var page = _fileManager.ResolvePage(); Assert.DoesNotThrow(() => { _recordFormatter.Format(page); }); }
public Buffer PinNew(string filename, IPageFormatter pageFormatter) { // Check out, would it be possible to be on a lock as low amount of time as possible? lock (_poolLock) { var buffer = ChooseUnpinnedBuffer(); if (buffer == null) { return(null); } buffer.AssignToNew(filename, pageFormatter); _available--; buffer.Pin(); return(buffer); } }
public AutoRegistrationPlugin(ISynchronizer synchronizer, IRegistrationRepository registrationRepository, IPageRepository pageRepository, IPageFormatter pageFormatter, IEntryFormatter entryFormatter, INotificationSender notificationSender, ILogger logger, IPluginConfiguration configuration, IFileReader fileReader, ISettings settings) { _synchronizer = synchronizer; _fileReader = fileReader; _settings = settings; _registrationRepository = registrationRepository; _pageRepository = pageRepository; _pageFormatter = pageFormatter; _entryFormatter = entryFormatter; _notificationSender = notificationSender; _logger = logger; _configuration = configuration; }
public AutoRegistrationPlugin(ISynchronizer synchronizer, IRegistrationRepository registrationRepository, IPageRepository pageRepository, IPageFormatter pageFormatter, IEntryFormatter entryFormatter, INotificationSender notificationSender, ILogger logger, IPluginConfiguration configuration, IFileReader fileReader, ISettings settings) { _synchronizer = synchronizer; _fileReader = fileReader; _settings = settings; _registrationRepository = registrationRepository; _pageRepository = pageRepository; _pageFormatter = pageFormatter; _entryFormatter = entryFormatter; _notificationSender = notificationSender; _logger = logger; _configuration = configuration; }
public Buffer PinNew(string filename, IPageFormatter pageFormatter) { lock (_poolLock) { Buffer buffer = null; if (_bufferPool.Count < _totalBuffers) { buffer = AddNewBuffer(); buffer.AssignToNew(filename, pageFormatter); } else { return(null); } if (!buffer.IsPinned) { _available--; } buffer.Pin(); return(buffer); } }