Beispiel #1
0
        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));
        }
Beispiel #2
0
        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)));
        }
Beispiel #3
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]
Beispiel #5
0
 public override uint ReadUInt(int offset)
 {
     CheckAlignment(offset, sizeof(uint));
     return(ScalarSpanReader.ReadUInt(this.memory.AsSpan().Slice(offset)));
 }
Beispiel #6
0
 public int Compare(ReadOnlySpan <byte> left, ReadOnlySpan <byte> right)
 => ScalarSpanReader.ReadUInt(left).CompareTo(ScalarSpanReader.ReadUInt(right));
Beispiel #7
0
 public override uint ReadUInt(int offset)
 {
     return(ScalarSpanReader.ReadUInt(this.memory.AsSpan().Slice(offset)));
 }