/// <summary> /// Get next record using iterator /// </summary> /// <param name="recordInfo"></param> /// <param name="key"></param> /// <param name="value"></param> /// <returns></returns> public bool GetNext(out RecordInfo recordInfo, out Key key, out Value value) { recordInfo = default(RecordInfo); key = default(Key); value = default(Value); currentAddress = nextAddress; while (true) { // Check for boundary conditions if (currentAddress >= endAddress) { return(false); } if (currentAddress < hlog.BeginAddress) { throw new Exception("Iterator address is less than log BeginAddress " + hlog.BeginAddress); } var currentPage = currentAddress >> hlog.LogPageSizeBits; var currentFrame = currentPage % frameSize; var offset = (currentAddress & hlog.PageSizeMask) / recordSize; if (currentAddress < hlog.HeadAddress) { BufferAndLoad(currentAddress, currentPage, currentFrame); } // Check if record fits on page, if not skip to next page if ((currentAddress & hlog.PageSizeMask) + recordSize > hlog.PageSize) { currentAddress = (1 + (currentAddress >> hlog.LogPageSizeBits)) << hlog.LogPageSizeBits; continue; } if (currentAddress >= hlog.HeadAddress) { // Read record from cached page memory nextAddress = currentAddress + recordSize; var page = currentPage % hlog.BufferSize; if (hlog.values[page][offset].info.Invalid) { continue; } recordInfo = hlog.values[page][offset].info; key = hlog.values[page][offset].key; value = hlog.values[page][offset].value; return(true); } nextAddress = currentAddress + recordSize; if (frame.GetInfo(currentFrame, offset).Invalid) { continue; } recordInfo = frame.GetInfo(currentFrame, offset); key = frame.GetKey(currentFrame, offset); value = frame.GetValue(currentFrame, offset); return(true); } }
/// <summary> /// Get next record in iterator /// </summary> /// <param name="recordInfo"></param> /// <returns></returns> public bool GetNext(out RecordInfo recordInfo) { recordInfo = default; currentKey = default; currentValue = default; while (true) { currentAddress = nextAddress; // Check for boundary conditions if (currentAddress >= endAddress) { return(false); } epoch?.Resume(); var headAddress = hlog.HeadAddress; if (currentAddress < hlog.BeginAddress) { epoch?.Suspend(); throw new FasterException("Iterator address is less than log BeginAddress " + hlog.BeginAddress); } if (frameSize == 0 && currentAddress < headAddress) { epoch?.Suspend(); throw new FasterException("Iterator address is less than log HeadAddress in memory-scan mode"); } var currentPage = currentAddress >> hlog.LogPageSizeBits; var offset = (currentAddress & hlog.PageSizeMask) / recordSize; if (currentAddress < headAddress) { BufferAndLoad(currentAddress, currentPage, currentPage % frameSize, headAddress, endAddress); } // Check if record fits on page, if not skip to next page if ((currentAddress & hlog.PageSizeMask) + recordSize > hlog.PageSize) { nextAddress = (1 + (currentAddress >> hlog.LogPageSizeBits)) << hlog.LogPageSizeBits; epoch?.Suspend(); continue; } nextAddress = currentAddress + recordSize; if (currentAddress >= headAddress) { // Read record from cached page memory var page = currentPage % hlog.BufferSize; if (hlog.values[page][offset].info.SkipOnScan) { epoch?.Suspend(); continue; } recordInfo = hlog.values[page][offset].info; currentKey = hlog.values[page][offset].key; currentValue = hlog.values[page][offset].value; epoch?.Suspend(); return(true); } var currentFrame = currentPage % frameSize; if (frame.GetInfo(currentFrame, offset).SkipOnScan) { epoch?.Suspend(); continue; } recordInfo = frame.GetInfo(currentFrame, offset); currentKey = frame.GetKey(currentFrame, offset); currentValue = frame.GetValue(currentFrame, offset); epoch?.Suspend(); return(true); } }