private long CreateNode() { long offset = IndexStream.AllocateSpace(BTreeNode.TotalSize).Value; var newIndex = (offset - BTreeHeader.Size) / BTreeNode.TotalSize; return(newIndex); }
private long?AllocateDataSpace(ref uint size) { if (EnableFreelist) { if (size < FreelistNode.Size) { size = FreelistNode.Size; } } size = ((size + 3) / 4) * 4; var result = FreelistTake(ref size); if (!result.HasValue) { result = DataStream.AllocateSpace(size); } return(result); }
public void WriteNewKey(BTreeValue *pEntry, TangleKey key) { if (key.Data.Count > BTreeValue.KeyPrefixSize) { pEntry->KeyOffset = (uint)KeyStream.AllocateSpace((uint)key.Data.Count).Value; } else { pEntry->KeyOffset = 0; } pEntry->KeyLength = (ushort)key.Data.Count; // It's important that we zero out these fields so that when we write the data, // it's done in append mode instead of replace mode pEntry->DataOffset = 0; pEntry->DataLength = 0; pEntry->ExtraDataBytes = 0; WriteKey(ref *pEntry, key); }