Esempio n. 1
0
        public AsyncUnaryCall <Schema> GetSchema(FlightDescriptor flightDescriptor, Metadata headers = null)
        {
            var schemaResult = _client.GetSchemaAsync(flightDescriptor.ToProtocol(), headers);

            var schema = schemaResult
                         .ResponseAsync
                         .ContinueWith(async schema => FlightMessageSerializer.DecodeSchema((await schemaResult.ResponseAsync.ConfigureAwait(false)).Schema.Memory))
                         .Unwrap();

            return(new AsyncUnaryCall <Schema>(
                       schema,
                       schemaResult.ResponseHeadersAsync,
                       schemaResult.GetStatus,
                       schemaResult.GetTrailers,
                       schemaResult.Dispose));
        }
Esempio n. 2
0
        public async ValueTask <Schema> ReadSchema()
        {
            if (HasReadSchema)
            {
                return(Schema);
            }

            var moveNextResult = await _flightDataStream.MoveNext().ConfigureAwait(false);

            if (!moveNextResult)
            {
                throw new Exception("No records or schema in this flight");
            }

            //AppMetadata will never be null, but length 0 if empty
            //Those are skipped
            if (_flightDataStream.Current.AppMetadata.Length > 0)
            {
                _applicationMetadatas.Add(_flightDataStream.Current.AppMetadata);
            }

            var     header  = _flightDataStream.Current.DataHeader.Memory;
            Message message = Message.GetRootAsMessage(
                ArrowReaderImplementation.CreateByteBuffer(header));


            if (_flightDataStream.Current.FlightDescriptor != null)
            {
                _flightDescriptor = new FlightDescriptor(_flightDataStream.Current.FlightDescriptor);
            }

            switch (message.HeaderType)
            {
            case MessageHeader.Schema:
                Schema = FlightMessageSerializer.DecodeSchema(message.ByteBuffer);
                break;

            default:
                throw new Exception($"Expected schema as the first message, but got: {message.HeaderType.ToString()}");
            }
            return(Schema);
        }