public int Compare(bool leftExists, ReadOnlySpan <byte> left, bool rightExists, ReadOnlySpan <byte> right) { uint leftValue = leftExists ? ScalarSpanReader.ReadUInt(left) : this.defaultValue; uint rightValue = rightExists ? ScalarSpanReader.ReadUInt(right) : this.defaultValue; return(leftValue.CompareTo(rightValue)); }
public int Compare(bool leftExists, ReadOnlySpan <byte> left, bool rightExists, ReadOnlySpan <byte> right) { if (!leftExists || !rightExists) { return(leftExists.CompareTo(rightExists)); } return(ScalarSpanReader.ReadUInt(left).CompareTo(ScalarSpanReader.ReadUInt(right))); }
public static void SortVector <TSpanComparer>( Span <byte> buffer, int vectorUOffset, int vtableIndex, int?keyInlineSize, TSpanComparer comparer) where TSpanComparer : ISpanComparer { checked { int vectorStartOffset = vectorUOffset + (int)ScalarSpanReader.ReadUInt(buffer.Slice(vectorUOffset)); int vectorLength = (int)ScalarSpanReader.ReadUInt(buffer.Slice(vectorStartOffset)); int index0Position = vectorStartOffset + sizeof(int); (int, int, int)[]? pooledArray = null;
public static void SortVector <TSpanComparer>( Span <byte> buffer, int vectorUOffset, int vtableIndex, int?keyInlineSize, TSpanComparer comparer) where TSpanComparer : ISpanComparer { checked { int vectorStartOffset = vectorUOffset + (int)ScalarSpanReader.ReadUInt(buffer.Slice(vectorUOffset)); int vectorLength = (int)ScalarSpanReader.ReadUInt(buffer.Slice(vectorStartOffset)); int index0Position = vectorStartOffset + sizeof(int); // Traverse the vector and figure out the offsets of all the keys. // Store that in some local data, hopefully on the stack. 512 is somewhat arbitrary, but we want to avoid stack overflows. Span <(int offset, int length, int tableOffset)> keyOffsets = vectorLength < 512 ? stackalloc (int, int, int)[vectorLength]
public static void Create <TInputBuffer>(TInputBuffer inputBuffer, int offset, out VTable4 item) where TInputBuffer : IInputBuffer { inputBuffer.InitializeVTable( offset, out _, out nuint fieldCount, out ReadOnlySpan <byte> fieldData); item = new VTable4(); switch (fieldCount) { case 0: break; case 1: { item.offset0 = ScalarSpanReader.ReadUShort(fieldData); } break; case 2: { item.offset0ui = ScalarSpanReader.ReadUInt(fieldData); } break; case 3: { fieldData = fieldData.Slice(0, 6); item.offset0ui = ScalarSpanReader.ReadUInt(fieldData); item.offset4 = ScalarSpanReader.ReadUShort(fieldData.Slice(4, 2)); } break; default: { item.offset0ul = ScalarSpanReader.ReadULong(fieldData); } break; } }
public uint ReadUInt(int offset) { this.CheckAlignment(offset, sizeof(uint)); return(ScalarSpanReader.ReadUInt(this.memory.AsSpan().Slice(offset))); }