protected virtual void ReadSchema()
        {
            if (HasReadSchema)
            {
                return;
            }

            // Figure out length of schema
            int schemaMessageLength = 0;

            ArrayPool <byte> .Shared.RentReturn(4, lengthBuffer =>
            {
                int bytesRead = BaseStream.ReadFullBuffer(lengthBuffer);
                EnsureFullRead(lengthBuffer, bytesRead);

                schemaMessageLength = BitUtility.ReadInt32(lengthBuffer);
            });

            ArrayPool <byte> .Shared.RentReturn(schemaMessageLength, buff =>
            {
                int bytesRead = BaseStream.ReadFullBuffer(buff);
                EnsureFullRead(buff, bytesRead);

                var schemabb = CreateByteBuffer(buff);
                Schema       = MessageSerializer.GetSchema(ReadMessage <Flatbuf.Schema>(schemabb));
            });
        }
        protected virtual async ValueTask ReadSchemaAsync()
        {
            if (HasReadSchema)
            {
                return;
            }

            // Figure out length of schema
            int schemaMessageLength = 0;
            await ArrayPool <byte> .Shared.RentReturnAsync(4, async (lengthBuffer) =>
            {
                int bytesRead = await BaseStream.ReadFullBufferAsync(lengthBuffer).ConfigureAwait(false);
                EnsureFullRead(lengthBuffer, bytesRead);

                schemaMessageLength = BitUtility.ReadInt32(lengthBuffer);
            }).ConfigureAwait(false);

            await ArrayPool <byte> .Shared.RentReturnAsync(schemaMessageLength, async (buff) =>
            {
                // Read in schema
                int bytesRead = await BaseStream.ReadFullBufferAsync(buff).ConfigureAwait(false);
                EnsureFullRead(buff, bytesRead);

                var schemabb = CreateByteBuffer(buff);
                Schema       = MessageSerializer.GetSchema(ReadMessage <Flatbuf.Schema>(schemabb));
            }).ConfigureAwait(false);
        }
        private void ReadSchema()
        {
            if (HasReadSchema)
            {
                return;
            }

            // Figure out length of schema
            int schemaMessageLength = BinaryPrimitives.ReadInt32LittleEndian(_buffer.Span.Slice(_bufferPosition));

            _bufferPosition += sizeof(int);

            if (schemaMessageLength == MessageSerializer.IpcContinuationToken)
            {
                // ARROW-6313, if the first 4 bytes are continuation message, read the next 4 for the length
                if (_buffer.Length <= _bufferPosition + sizeof(int))
                {
                    throw new InvalidDataException("Corrupted IPC message. Received a continuation token at the end of the message.");
                }

                schemaMessageLength = BinaryPrimitives.ReadInt32LittleEndian(_buffer.Span.Slice(_bufferPosition));
                _bufferPosition    += sizeof(int);
            }

            ByteBuffer schemaBuffer = CreateByteBuffer(_buffer.Slice(_bufferPosition));

            Schema           = MessageSerializer.GetSchema(ReadMessage <Flatbuf.Schema>(schemaBuffer));
            _bufferPosition += schemaMessageLength;
        }
Пример #4
0
        private void ReadSchema()
        {
            if (HasReadSchema)
            {
                return;
            }

            // Figure out length of schema
            int schemaMessageLength = BinaryPrimitives.ReadInt32LittleEndian(_buffer.Span.Slice(_bufferPosition));

            _bufferPosition += sizeof(int);

            ByteBuffer schemaBuffer = CreateByteBuffer(_buffer.Slice(_bufferPosition));

            Schema           = MessageSerializer.GetSchema(ReadMessage <Flatbuf.Schema>(schemaBuffer));
            _bufferPosition += schemaMessageLength;
        }
        protected virtual void ReadSchema()
        {
            if (HasReadSchema)
            {
                return;
            }

            // Figure out length of schema
            int schemaMessageLength = ReadMessageLength(throwOnFullRead: true);

            ArrayPool <byte> .Shared.RentReturn(schemaMessageLength, buff =>
            {
                int bytesRead = BaseStream.ReadFullBuffer(buff);
                EnsureFullRead(buff, bytesRead);

                FlatBuffers.ByteBuffer schemabb = CreateByteBuffer(buff);
                Schema = MessageSerializer.GetSchema(ReadMessage <Flatbuf.Schema>(schemabb), ref _dictionaryMemo);
            });
        }
        protected virtual async ValueTask ReadSchemaAsync()
        {
            if (HasReadSchema)
            {
                return;
            }

            // Figure out length of schema
            int schemaMessageLength = await ReadMessageLengthAsync(throwOnFullRead : true)
                                      .ConfigureAwait(false);

            await ArrayPool <byte> .Shared.RentReturnAsync(schemaMessageLength, async (buff) =>
            {
                // Read in schema
                int bytesRead = await BaseStream.ReadFullBufferAsync(buff).ConfigureAwait(false);
                EnsureFullRead(buff, bytesRead);

                FlatBuffers.ByteBuffer schemabb = CreateByteBuffer(buff);
                Schema = MessageSerializer.GetSchema(ReadMessage <Flatbuf.Schema>(schemabb), ref _dictionaryMemo);
            }).ConfigureAwait(false);
        }
Пример #7
0
        protected virtual async Task <Schema> ReadSchemaAsync()
        {
            if (HasReadSchema)
            {
                return(Schema);
            }

            byte[] buff = null;

            try
            {
                // Figure out length of schema

                buff = Buffers.Rent(4);
                await BaseStream.ReadAsync(buff, 0, 4);

                var schemaMessageLength = BitConverter.ToInt32(buff, 0);
                Buffers.Return(buff);

                // Allocate byte array for schema flat buffer

                buff = Buffers.Rent(schemaMessageLength);
                var schemabb = new FlatBuffers.ByteBuffer(buff);

                // Read in schema

                await BaseStream.ReadAsync(buff, 0, schemaMessageLength);

                Schema = MessageSerializer.GetSchema(ReadMessage <Flatbuf.Schema>(schemabb));

                return(Schema);
            }
            finally
            {
                if (buff != null)
                {
                    Buffers.Return(buff);
                }
            }
        }