Esempio n. 1
0
        public async Task CopyToWithFullBufferAsync()
        {
            var content = new byte[1234];
            var r       = new Random();

            r.NextBytes(content);

            using (var testReadStream = new PartialReadStream(content, 100))
            {
                int bytesWritten = 0;
                using (var testWriteStream = new WriteCallbackStream((bufferToWrite, offset, count) =>
                {
                    Assert.Equal(250, bufferToWrite.Length);
                    bytesWritten += count;
                    if (bytesWritten < content.Length)
                    {
                        Assert.Equal(250, count);
                    }
                    else
                    {
                        Assert.Equal(content.Length % 250, count);
                    }
                }))
                {
                    await testReadStream.CopyToWithFullBufferAsync(testWriteStream, 250);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Verifies that the stream reader reads multiple times when a stream
        /// only returns a subset of the data from each Read.
        /// </summary>
        private static async Task TestReaderFromPartialReadStream(Func <ArrowStreamReader, RecordBatch, Task> verificationFunc)
        {
            RecordBatch originalBatch = TestData.CreateSampleRecordBatch(length: 100);

            using (PartialReadStream stream = new PartialReadStream())
            {
                ArrowStreamWriter writer = new ArrowStreamWriter(stream, originalBatch.Schema);
                await writer.WriteRecordBatchAsync(originalBatch);

                stream.Position = 0;

                ArrowStreamReader reader = new ArrowStreamReader(stream);
                await verificationFunc(reader, originalBatch);
            }
        }
Esempio n. 3
0
        public async Task ReadBytes()
        {
            var content = new byte[100];
            var r       = new Random();

            r.NextBytes(content);

            var buffer = new byte[100];

            using (var testReadStream = new PartialReadStream(content, buffer.Length / 2))
            {
                await testReadStream.ReadBytes(buffer, buffer.Length);

                Assert.True(content.SequenceEqual(buffer));
            }
        }