public Value *TryAppend(USlice buffer) { Contract.Requires(buffer.Data != null && buffer.Count >= Value.SizeOf && ((Key *)buffer.Data)->Size == buffer.Count - Value.SizeOf); var entry = (Value *)TryAllocate(buffer.Count); if (entry == null) { return(null); // the page is full } UnmanagedHelpers.CopyUnsafe((byte *)entry, buffer.Data, buffer.Count); return(entry); }
public Key *TryAppend(USlice buffer) { Contract.Requires(buffer.Data != null && buffer.Count >= Key.SizeOf && ((Key *)buffer.Data)->Size == buffer.Count - Key.SizeOf); var entry = (Key *)TryAllocate(buffer.Count); if (entry == null) { return(null); // this page is full } UnmanagedHelpers.CopyUnsafe((byte *)entry, buffer.Data, buffer.Count); entry->Header = ((ushort)EntryType.Key) << Entry.TYPE_SHIFT; return(entry); }
public unsafe void Add(ulong sequence, USlice userKey, USlice userValue) { // allocate the key var tmp = MemoryDatabaseHandler.PackUserKey(m_scratch, userKey); Key *key = m_keys.Append(tmp); Contract.Assert(key != null, "key == null"); // allocate the value uint size = userValue.Count; Value *value = m_values.Allocate(size, sequence, null, key); Contract.Assert(value != null, "value == null"); UnmanagedHelpers.CopyUnsafe(&(value->Data), userValue); key->Values = value; m_list.Add(new IntPtr(key)); }