private QueueFileInfo GetStreamInfoFromHandle(QueueStreamHandle handle) { QueueFileInfo queueFileInfo; _files.TryGetValue(handle.Id, out queueFileInfo); return(queueFileInfo); }
private void AddHandle(int id, long position, int length) { var handle = new QueueStreamHandle(id, position, length); _recordQueue.Enqueue(handle); HashSet <QueueStreamHandle> handles; if (!_recordMap.TryGetValue(id, out handles)) { handles = new HashSet <QueueStreamHandle>(); _recordMap.Add(id, handles); } handles.Add(handle); }
private void RemoveHandle(QueueStreamHandle handle, QueueFileInfo queueFileInfo) { HashSet <QueueStreamHandle> handles; if (!_recordMap.TryGetValue(handle.Id, out handles)) { return; } handles.Remove(handle); if (handles.Count != 0) { return; } _recordMap.Remove(handle.Id); if (queueFileInfo == _head) { // tail caught up with head, so let's truncate the file queueFileInfo.Stream.SetLength(0); } else { // no undeleted records in non-head file, remove file RemoveFile(queueFileInfo); } if (_head.Id == 1 || _recordQueue.Count > 0) { return; } if (_recordMap.Count > 0) { return; } // the head is not the first file and there are no remaining items, so we can reset the head to the first file RemoveFile(_head); CreateHead(1); }
private void RemoveHandle(QueueStreamHandle handle, QueueFileInfo queueFileInfo) { HashSet<QueueStreamHandle> handles; if(!_recordMap.TryGetValue(handle.Id, out handles)) { return; } handles.Remove(handle); if(handles.Count != 0) { return; } _recordMap.Remove(handle.Id); if(queueFileInfo == _head) { // tail caught up with head, so let's truncate the file queueFileInfo.Stream.SetLength(0); } else { // no undeleted records in non-head file, remove file RemoveFile(queueFileInfo); } if(_head.Id == 1 || _recordQueue.Count > 0) { return; } if(_recordMap.Count > 0) { return; } // the head is not the first file and there are no remaining items, so we can reset the head to the first file RemoveFile(_head); CreateHead(1); }
private QueueFileInfo GetStreamInfoFromHandle(QueueStreamHandle handle) { QueueFileInfo queueFileInfo; _files.TryGetValue(handle.Id, out queueFileInfo); return queueFileInfo; }
private void AddHandle(int id, long position, int length) { var handle = new QueueStreamHandle(id, position, length); _recordQueue.Enqueue(handle); HashSet<QueueStreamHandle> handles; if(!_recordMap.TryGetValue(id, out handles)) { handles = new HashSet<QueueStreamHandle>(); _recordMap.Add(id, handles); } handles.Add(handle); }