Exemplo n.º 1
0
            public SequenceSize WriteNext(Span <byte> writeTo)
            {
                if (_position == _rows.Count)
                {
                    return(_internalColumnWriter.WriteNext(writeTo));
                }

                var len = Math.Min(_rows.Count - _position, writeTo.Length);

                for (int i = 0; i < len; i++)
                {
                    writeTo[i] = _rows[_position + i] == null ? (byte)1 : (byte)0;
                }

                _position += len;

                if (_position < _rows.Count)
                {
                    return(new SequenceSize(len, 0));
                }

                var size = _internalColumnWriter.WriteNext(writeTo.Slice(len));

                return(new SequenceSize(size.Bytes + len, size.Elements));
            }
Exemplo n.º 2
0
            public SequenceSize WriteNext(Span <byte> writeTo)
            {
                int bytesCount = 0;
                var span       = writeTo;

                for (; _headerPosition < _rows.ListLengths.Count; _headerPosition++)
                {
                    if (!BitConverter.TryWriteBytes(span, (ulong)_rows.ListLengths[_headerPosition]))
                    {
                        return(new SequenceSize(bytesCount, 0));
                    }

                    span        = span.Slice(sizeof(ulong));
                    bytesCount += sizeof(ulong);
                }

                var elementSize = _elementColumnWriter.WriteNext(span);

                _elementPosition += elementSize.Elements;

                var elementsCount = 0;

                while (_position < _rows.ListLengths.Count)
                {
                    if (_rows.ListLengths[_position] > _elementPosition)
                    {
                        break;
                    }

                    ++elementsCount;
                    ++_position;
                }

                return(new SequenceSize(elementSize.Bytes + bytesCount, elementsCount));
            }