示例#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;
        public static void SortVector(
            Span <byte> buffer,
            int vectorUOffset,
            int vtableIndex,
            int?keyInlineSize,
            ISpanComparer comparer)
        {
            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 override ushort ReadUShort(int offset)
 {
     CheckAlignment(offset, sizeof(ushort));
     return(ScalarSpanReader.ReadUShort(this.memory.AsSpan().Slice(offset)));
 }
示例#7
0
 public override long ReadLong(int offset)
 {
     CheckAlignment(offset, sizeof(long));
     return(ScalarSpanReader.ReadLong(this.memory.AsSpan().Slice(offset)));
 }
 public override ulong ReadULong(int offset)
 {
     CheckAlignment(offset, sizeof(ulong));
     return(ScalarSpanReader.ReadULong(this.memory.Span.Slice(offset)));
 }
示例#9
0
 public override sbyte ReadSByte(int offset)
 {
     return(ScalarSpanReader.ReadSByte(this.memory.AsSpan().Slice(offset)));
 }
示例#10
0
 public override long ReadLong(int offset)
 {
     return(ScalarSpanReader.ReadLong(this.memory.AsSpan().Slice(offset)));
 }
 public override int ReadInt(int offset)
 {
     CheckAlignment(offset, sizeof(int));
     return(ScalarSpanReader.ReadInt(this.memory.Span.Slice(offset)));
 }
示例#12
0
 public override int ReadInt(int offset)
 {
     return(ScalarSpanReader.ReadInt(this.memory.Span.Slice(offset)));
 }
示例#13
0
 protected override string ReadStringProtected(int offset, int byteLength, Encoding encoding)
 {
     return(ScalarSpanReader.ReadString(this.memory.AsSpan().Slice(offset, byteLength), encoding));
 }
示例#14
0
 public int Compare(ReadOnlySpan <byte> left, ReadOnlySpan <byte> right)
 => ScalarSpanReader.ReadUInt(left).CompareTo(ScalarSpanReader.ReadUInt(right));
示例#15
0
 public string ReadString(int offset, int byteLength, Encoding encoding)
 {
     return(ScalarSpanReader.ReadString(this.memory.AsSpan().Slice(offset, byteLength), encoding));
 }
示例#16
0
 public override ulong ReadULong(int offset)
 {
     return(ScalarSpanReader.ReadULong(this.memory.Span.Slice(offset)));
 }
示例#17
0
 public override double ReadDouble(int offset)
 {
     return(ScalarSpanReader.ReadDouble(this.memory.AsSpan().Slice(offset)));
 }
示例#18
0
 public override float ReadFloat(int offset)
 {
     return(ScalarSpanReader.ReadFloat(this.memory.AsSpan().Slice(offset)));
 }
示例#19
0
 public override float ReadFloat(int offset)
 {
     CheckAlignment(offset, sizeof(float));
     return(ScalarSpanReader.ReadFloat(this.memory.AsSpan().Slice(offset)));
 }
示例#20
0
 public ulong ReadULong(int offset)
 {
     this.CheckAlignment(offset, sizeof(ulong));
     return(ScalarSpanReader.ReadULong(this.memory.AsSpan().Slice(offset)));
 }
示例#21
0
 public override double ReadDouble(int offset)
 {
     CheckAlignment(offset, sizeof(double));
     return(ScalarSpanReader.ReadDouble(this.memory.AsSpan().Slice(offset)));
 }
 public override byte ReadByte(int offset)
 {
     return(ScalarSpanReader.ReadByte(this.memory.Span.Slice(offset)));
 }
示例#23
0
 public int ReadInt(int offset)
 {
     this.CheckAlignment(offset, sizeof(int));
     return(ScalarSpanReader.ReadInt(this.memory.AsSpan().Slice(offset)));
 }
示例#24
0
 public override ushort ReadUShort(int offset)
 {
     return(ScalarSpanReader.ReadUShort(this.memory.AsSpan().Slice(offset)));
 }