public void DisposeSingleWriter(ref Key key, ref Input input, ref Value src, ref Value dst, ref Output output, ref RecordInfo recordInfo, ref UpsertInfo upsertInfo, WriteReason reason) => _clientSession.functions.DisposeSingleWriter(ref key, ref input, ref src, ref dst, ref output, ref upsertInfo, reason);
/// <summary> /// Get next record in 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; if (currentAddress < hlog.HeadAddress) { BufferAndLoad(currentAddress, currentPage, currentFrame); } var recordSize = hlog.GetRecordSize(hlog.GetPhysicalAddress(currentAddress)); // 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 var _physicalAddress = hlog.GetPhysicalAddress(currentAddress); if (hlog.GetInfo(_physicalAddress).Invalid) { currentAddress += hlog.GetRecordSize(_physicalAddress); continue; } recordInfo = hlog.GetInfo(_physicalAddress); key = hlog.GetKey(_physicalAddress); value = hlog.GetValue(_physicalAddress); nextAddress = currentAddress + hlog.GetRecordSize(_physicalAddress); return(true); } var physicalAddress = frame.GetPhysicalAddress(currentFrame, offset); if (hlog.GetInfo(physicalAddress).Invalid) { currentAddress += hlog.GetRecordSize(physicalAddress); continue; } recordInfo = hlog.GetInfo(physicalAddress); key = hlog.GetKey(physicalAddress); value = hlog.GetValue(physicalAddress); nextAddress = currentAddress + hlog.GetRecordSize(physicalAddress); return(true); } }
public override ref Value GetValue(long physicalAddress) { return(ref Unsafe.AsRef <Value>((byte *)physicalAddress + RecordInfo.GetLength() + KeySize(physicalAddress))); }
public void ReadCompletionCallback(ref Key key, ref Input input, ref Output output, Context ctx, Status status, RecordInfo recordInfo) { _fasterKV._functions.ReadCompletionCallback(ref key, ref input, ref output, ctx, status); }
public bool Unlock(ref RecordInfo recordInfo, ref Key key, ref Value value, LockType lockType, long lockContext) => true;
public void ConcurrentReader(ref Key key, ref Input input, ref Value value, ref Output dst, ref RecordInfo recordInfo, long address) { _fasterKV._functions.ConcurrentReader(ref key, ref input, ref value, ref dst); }
public void ConcurrentDeleter(ref Key key, ref Value value, ref RecordInfo recordInfo, long address) { }
public Status Read(ref Key key, ref Input input, ref Output output, ref RecordInfo recordInfo, ReadFlags readFlags = ReadFlags.None, Context userContext = default, long serialNo = 0) => throw new FasterException(AdvancedOnlyMethodErr);
public void ConcurrentReader(ref Key key, ref Input input, ref Value value, ref Output dst, ref RecordInfo recordInfo, long address) { if (!this.SupportsLocking) { _clientSession.functions.ConcurrentReader(ref key, ref input, ref value, ref dst); } else { ConcurrentReaderLock(ref key, ref input, ref value, ref dst, ref recordInfo); } }
public void DisposeDeserializedFromDisk(ref Key key, ref Value value, ref RecordInfo recordInfo) => _clientSession.functions.DisposeDeserializedFromDisk(ref key, ref value);
public bool Unlock(ref RecordInfo recordInfo, ref Key key, ref Value value, LockType lockType, long lockContext) => _clientSession.functions.Unlock(ref recordInfo, ref key, ref value, lockType, lockContext);
public void DisposeSingleDeleter(ref Key key, ref Value value, ref RecordInfo recordInfo, ref DeleteInfo deleteInfo) => _clientSession.functions.DisposeSingleDeleter(ref key, ref value, ref deleteInfo);
public void DisposeInitialUpdater(ref Key key, ref Input input, ref Value value, ref Output output, ref RecordInfo recordInfo, ref RMWInfo rmwInfo) => _clientSession.functions.DisposeInitialUpdater(ref key, ref input, ref value, ref output, ref rmwInfo);
public void DisposeCopyUpdater(ref Key key, ref Input input, ref Value oldValue, ref Value newValue, ref Output output, ref RecordInfo recordInfo, ref RMWInfo rmwInfo) => _clientSession.functions.DisposeCopyUpdater(ref key, ref input, ref oldValue, ref newValue, ref output, ref rmwInfo);
public override AddressInfo *GetValueAddressInfo(long physicalAddress) { return((AddressInfo *)((byte *)physicalAddress + RecordInfo.GetLength() + keySize)); }
public void ConcurrentReaderLock(ref Key key, ref Input input, ref Value value, ref Output dst, ref RecordInfo recordInfo) { for (bool retry = true; retry; /* updated in loop */) { long context = 0; this.Lock(ref recordInfo, ref key, ref value, LockType.Shared, ref context); try { _clientSession.functions.ConcurrentReader(ref key, ref input, ref value, ref dst); } finally { retry = !this.Unlock(ref recordInfo, ref key, ref value, LockType.Shared, context); } } }
private long ValueOffset(long physicalAddress) => physicalAddress + RecordInfo.GetLength() + AlignedKeySize(physicalAddress);
public bool ConcurrentWriter(ref Key key, ref Value src, ref Value dst, ref RecordInfo recordInfo, long address) => !this.SupportsLocking ? ConcurrentWriterNoLock(ref key, ref src, ref dst, address) : ConcurrentWriterLock(ref key, ref src, ref dst, ref recordInfo, address);
public bool ConcurrentWriter(ref Key key, ref Value src, ref Value dst, ref RecordInfo recordInfo, long address) { return(_fasterKV._functions.ConcurrentWriter(ref key, ref src, ref dst)); }
private bool ConcurrentWriterLock(ref Key key, ref Value src, ref Value dst, ref RecordInfo recordInfo, long address) { long context = 0; this.Lock(ref recordInfo, ref key, ref dst, LockType.Exclusive, ref context); try { return(!recordInfo.Tombstone && ConcurrentWriterNoLock(ref key, ref src, ref dst, address)); } finally { this.Unlock(ref recordInfo, ref key, ref dst, LockType.Exclusive, context); } }
public bool InPlaceUpdater(ref Key key, ref Input input, ref Value value, ref Output output, ref RecordInfo recordInfo, long address) { return(_fasterKV._functions.InPlaceUpdater(ref key, ref input, ref value, ref output)); }
private void ConcurrentDeleterNoLock(ref Key key, ref Value value, ref RecordInfo recordInfo, long address) { // Non-Advanced IFunctions has no ConcurrentDeleter recordInfo.Tombstone = true; }
public void Lock(ref RecordInfo recordInfo, ref Key key, ref Value value, LockType lockType, ref long lockContext) { }
public bool InPlaceUpdater(ref Key key, ref Input input, ref Value value, ref RecordInfo recordInfo, long address) => !this.SupportsLocking ? InPlaceUpdaterNoLock(ref key, ref input, ref value, address) : InPlaceUpdaterLock(ref key, ref input, ref value, ref recordInfo, address);
/// <summary> /// Get next record in iterator /// </summary> /// <param name="recordInfo"></param> /// <returns></returns> public bool GetNext(out RecordInfo recordInfo) { recordInfo = default(RecordInfo); currentAddress = nextAddress; while (true) { // Check for boundary conditions if (currentAddress >= endAddress) { return(false); } if (currentAddress < hlog.BeginAddress) { throw new FasterException("Iterator address is less than log BeginAddress " + hlog.BeginAddress); } if (frameSize == 0 && currentAddress < hlog.HeadAddress) { throw new FasterException("Iterator address is less than log HeadAddress in memory-scan mode"); } var currentPage = currentAddress >> hlog.LogPageSizeBits; var offset = currentAddress & hlog.PageSizeMask; if (currentAddress < hlog.HeadAddress) { BufferAndLoad(currentAddress, currentPage, currentPage % frameSize); } var physicalAddress = default(long); if (currentAddress >= hlog.HeadAddress) { physicalAddress = hlog.GetPhysicalAddress(currentAddress); } else { physicalAddress = frame.GetPhysicalAddress(currentPage % frameSize, offset); } // Check if record fits on page, if not skip to next page var recordSize = hlog.GetRecordSize(physicalAddress); if ((currentAddress & hlog.PageSizeMask) + recordSize > hlog.PageSize) { currentAddress = (1 + (currentAddress >> hlog.LogPageSizeBits)) << hlog.LogPageSizeBits; continue; } ref var info = ref hlog.GetInfo(physicalAddress); if (info.Invalid || info.IsNull()) { currentAddress += recordSize; continue; } currentPhysicalAddress = physicalAddress; recordInfo = info; nextAddress = currentAddress + recordSize; return(true); }
private bool InPlaceUpdaterLock(ref Key key, ref Input input, ref Value value, ref RecordInfo recordInfo, long address) { long context = 0; this.Lock(ref recordInfo, ref key, ref value, LockType.Exclusive, ref context); try { return(!recordInfo.Tombstone && InPlaceUpdaterNoLock(ref key, ref input, ref value, address)); } finally { this.Unlock(ref recordInfo, ref key, ref value, LockType.Exclusive, context); } }
public override ref Key GetKey(long physicalAddress) { return(ref Unsafe.AsRef <Key>((byte *)physicalAddress + RecordInfo.GetLength())); }
public override AddressInfo *GetKeyAddressInfo(long physicalAddress) { return((AddressInfo *)((byte *)physicalAddress + RecordInfo.GetLength())); }
/// <summary> /// Get next record /// </summary> /// <param name="recordInfo"></param> /// <returns>True if record found, false if end of scan</returns> public bool GetNext(out RecordInfo recordInfo) { recordInfo = default; while (true) { currentAddress = nextAddress; // Check for boundary conditions if (currentAddress >= endAddress) { return(false); } epoch?.Resume(); var headAddress = hlog.HeadAddress; if (currentAddress < hlog.BeginAddress && !forceInMemory) { epoch?.Suspend(); throw new FasterException("Iterator address is less than log BeginAddress " + hlog.BeginAddress); } if (frameSize == 0 && currentAddress < headAddress && !forceInMemory) { 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; if (currentAddress < headAddress && !forceInMemory) { BufferAndLoad(currentAddress, currentPage, currentPage % frameSize); } long physicalAddress; if (currentAddress >= headAddress || forceInMemory) { physicalAddress = hlog.GetPhysicalAddress(currentAddress); currentPhysicalAddress = 0; } else { currentPhysicalAddress = physicalAddress = frame.GetPhysicalAddress(currentPage % frameSize, offset); } // Check if record fits on page, if not skip to next page var recordSize = hlog.GetRecordSize(physicalAddress).Item2; if ((currentAddress & hlog.PageSizeMask) + recordSize > hlog.PageSize) { nextAddress = (1 + (currentAddress >> hlog.LogPageSizeBits)) << hlog.LogPageSizeBits; epoch?.Suspend(); continue; } nextAddress = currentAddress + recordSize; ref var info = ref hlog.GetInfo(physicalAddress); if (info.Invalid || info.IsNull()) { epoch?.Suspend(); continue; } recordInfo = info; if (currentPhysicalAddress == 0) { currentKey = hlog.GetKey(physicalAddress); currentValue = hlog.GetValue(physicalAddress); } epoch?.Suspend(); return(true); }
private bool ConcurrentDeleterNoLock(ref Key key, ref Value value, ref RecordInfo recordInfo, ref DeleteInfo deleteInfo) { recordInfo.SetDirty(); recordInfo.SetTombstone(); return(_clientSession.functions.ConcurrentDeleter(ref key, ref value, ref deleteInfo)); }