AllocateSpace() публичный Метод

Allocates size byte(s) of unused space at the end of the stream.
public AllocateSpace ( uint size ) : long?
size uint The number of bytes to allocate.
Результат long?
Пример #1
0
        private long CreateNode()
        {
            long offset   = IndexStream.AllocateSpace(BTreeNode.TotalSize).Value;
            var  newIndex = (offset - BTreeHeader.Size) / BTreeNode.TotalSize;

            return(newIndex);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }