public AccessRange ( long offset, uint size, MemoryMappedFileAccess access = MemoryMappedFileAccess.ReadWrite ) : |
||
offset | long | The offset within the stream, relative to the end of the stream header. |
size | uint | The size of the range to access, in bytes. |
access | MemoryMappedFileAccess | |
Résultat |
public StreamRange AccessRange(long offset, uint size, MemoryMappedFileAccess access = MemoryMappedFileAccess.ReadWrite)
{
unchecked {
long actualBegin = offset + HeaderSize;
uint actualSize = size;
EnsureCapacity(HeaderSize + offset + actualSize);
var viewRef = Cache.CreateView(actualBegin, actualSize, access);
return new StreamRange(
this, viewRef, actualBegin, actualSize
);
}
}
public StreamRange AccessNode(long index, bool forWrite) { unchecked { long position = BTreeHeader.Size + (index * BTreeNode.TotalSize); var range = IndexStream.AccessRange(position, BTreeNode.TotalSize, MemoryMappedFileAccess.ReadWrite); var pNode = (BTreeNode *)range.Pointer; if (pNode->IsValid != 1) { // If the node is fully uninitialized, locking it for write is okay if ((pNode->NumValues != 0) || (pNode->HasLeaves != 0)) { throw new InvalidDataException(); } } if (forWrite) { pNode->IsValid = 0; } return(range); } }