예제 #1
0
    public int Compare(bool leftExists, ReadOnlySpan <byte> left, bool rightExists, ReadOnlySpan <byte> right)
    {
        byte leftValue  = leftExists ? ScalarSpanReader.ReadByte(left) : this.defaultValue;
        byte rightValue = rightExists ? ScalarSpanReader.ReadByte(right) : this.defaultValue;

        return(leftValue.CompareTo(rightValue));
    }
예제 #2
0
    public int Compare(bool leftExists, ReadOnlySpan <byte> left, bool rightExists, ReadOnlySpan <byte> right)
    {
        ulong leftValue  = leftExists ? ScalarSpanReader.ReadULong(left) : this.defaultValue;
        ulong rightValue = rightExists ? ScalarSpanReader.ReadULong(right) : this.defaultValue;

        return(leftValue.CompareTo(rightValue));
    }
예제 #3
0
    public int Compare(bool leftExists, ReadOnlySpan <byte> left, bool rightExists, ReadOnlySpan <byte> right)
    {
        if (!leftExists || !rightExists)
        {
            return(leftExists.CompareTo(rightExists));
        }

        return(ScalarSpanReader.ReadByte(left).CompareTo(ScalarSpanReader.ReadByte(right)));
    }
예제 #4
0
    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;
예제 #5
0
        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]
예제 #6
0
    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;
        }
    }
예제 #7
0
 public double ReadDouble(int offset)
 {
     this.CheckAlignment(offset, sizeof(double));
     return(ScalarSpanReader.ReadDouble(this.memory.AsSpan().Slice(offset)));
 }
예제 #8
0
 public float ReadFloat(int offset)
 {
     this.CheckAlignment(offset, sizeof(float));
     return(ScalarSpanReader.ReadFloat(this.memory.AsSpan().Slice(offset)));
 }
예제 #9
0
 public long ReadLong(int offset)
 {
     this.CheckAlignment(offset, sizeof(long));
     return(ScalarSpanReader.ReadLong(this.memory.AsSpan().Slice(offset)));
 }
예제 #10
0
 public short ReadShort(int offset)
 {
     this.CheckAlignment(offset, sizeof(short));
     return(ScalarSpanReader.ReadShort(this.memory.AsSpan().Slice(offset)));
 }
예제 #11
0
 public sbyte ReadSByte(int offset)
 {
     return(ScalarSpanReader.ReadSByte(this.memory.AsSpan().Slice(offset)));
 }
예제 #12
0
 public string ReadString(int offset, int byteLength, Encoding encoding)
 {
     return(ScalarSpanReader.ReadString(this.memory.AsSpan().Slice(offset, byteLength), encoding));
 }
 public ulong ReadULong(int offset)
 {
     this.CheckAlignment(offset, sizeof(ulong));
     return(ScalarSpanReader.ReadULong(this.pointer.segment.AsSpan().Slice(offset)));
 }
 public int ReadInt(int offset)
 {
     this.CheckAlignment(offset, sizeof(int));
     return(ScalarSpanReader.ReadInt(this.pointer.segment.AsSpan().Slice(offset)));
 }
 public sbyte ReadSByte(int offset)
 {
     return(ScalarSpanReader.ReadSByte(this.pointer.segment.AsSpan().Slice(offset)));
 }