예제 #1
0
        public async Task TestGetSingleRecordBatch()
        {
            var flightDescriptor = FlightDescriptor.CreatePathDescriptor("test");
            var expectedBatch    = CreateTestBatch(0, 100);

            //Add batch to the in memory store
            GivenStoreBatches(flightDescriptor, new RecordBatchWithMetadata(expectedBatch));

            //Get the flight info for the ticket
            var flightInfo = await _flightClient.GetInfo(flightDescriptor);

            Assert.Single(flightInfo.Endpoints);

            var endpoint = flightInfo.Endpoints.FirstOrDefault();

            var getStream  = _flightClient.GetStream(endpoint.Ticket);
            var resultList = await getStream.ResponseStream.ToListAsync();

            Assert.Single(resultList);
            ArrowReaderVerifier.CompareBatches(expectedBatch, resultList[0]);
        }
예제 #2
0
        public async Task ArrowFlight()
        {
            var flightTicket = new FlightTicket(Sql);
            var stream       = flightClient.GetStream(flightTicket);

            await foreach (var recordBatch in stream.ResponseStream)
            {
                for (int i = 0; i < recordBatch.ColumnCount; i++)
                {
                    var array = recordBatch.Arrays.ElementAt(i);
                    switch (recordBatch.Schema.GetFieldByIndex(i).DataType.TypeId)
                    {
                    case ArrowTypeId.Int64:
                        Int64Array int64Array = (Int64Array)array;
                        Sum(int64Array);
                        break;

                    case ArrowTypeId.String:
                        StringArray stringArray = (StringArray)array;
                        for (int z = 0; z < stringArray.Length; z++)
                        {
                            stringArray.GetString(z);
                        }
                        break;

                    case ArrowTypeId.Timestamp:
                        TimestampArray timestampArray = (TimestampArray)array;

                        for (int z = 0; z < timestampArray.Length; z++)
                        {
                            timestampArray.GetTimestamp(z);
                        }
                        break;
                    }
                }

                //nop
            }
        }