< Summary

Class:Azure.Storage.Blobs.ChangeFeed.ChunkFactory
Assembly:Azure.Storage.Blobs.ChangeFeed
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs.ChangeFeed\src\ChunkFactory.cs
Covered lines:32
Uncovered lines:0
Coverable lines:32
Total lines:75
Line coverage:100% (32 of 32)
Covered branches:2
Total branches:2
Branch coverage:100% (2 of 2)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
BuildChunk()-100%100%
.ctor()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs.ChangeFeed\src\ChunkFactory.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System.IO;
 5using System.Threading;
 6using System.Threading.Tasks;
 7using Azure.Storage.Internal.Avro;
 8
 9namespace Azure.Storage.Blobs.ChangeFeed
 10{
 11    internal class ChunkFactory
 12    {
 13        private readonly LazyLoadingBlobStreamFactory _lazyLoadingBlobStreamFactory;
 14        private readonly AvroReaderFactory _avroReaderFactory;
 15        private readonly BlobContainerClient _containerClient;
 16
 8817        public ChunkFactory(
 8818            BlobContainerClient containerClient,
 8819            LazyLoadingBlobStreamFactory lazyLoadingBlobStreamFactory,
 8820            AvroReaderFactory avroReaderFactory)
 21        {
 8822            _containerClient = containerClient;
 8823            _lazyLoadingBlobStreamFactory = lazyLoadingBlobStreamFactory;
 8824            _avroReaderFactory = avroReaderFactory;
 8825        }
 26
 27        internal async virtual Task<Chunk> BuildChunk(
 28            bool async,
 29            string chunkPath,
 30            long blockOffset = 0,
 31            long eventIndex = 0,
 32            CancellationToken cancellationToken = default)
 33        {
 22834            BlobClient blobClient = _containerClient.GetBlobClient(chunkPath);
 35            AvroReader avroReader;
 36
 22837            Stream dataStream = _lazyLoadingBlobStreamFactory.BuildLazyLoadingBlobStream(
 22838                blobClient,
 22839                offset: blockOffset,
 22840                blockSize: Constants.ChangeFeed.ChunkBlockDownloadSize);
 41
 42            // We aren't starting from the beginning of the Chunk
 22843            if (blockOffset != 0)
 44            {
 5245                Stream headStream = _lazyLoadingBlobStreamFactory.BuildLazyLoadingBlobStream(
 5246                blobClient,
 5247                offset: 0,
 5248                blockSize: Constants.ChangeFeed.LazyLoadingBlobStreamBlockSize);
 49
 5250                avroReader = _avroReaderFactory.BuildAvroReader(
 5251                    dataStream,
 5252                    headStream,
 5253                    blockOffset,
 5254                    eventIndex);
 55            }
 56            else
 57            {
 17658                avroReader = _avroReaderFactory.BuildAvroReader(dataStream);
 59            }
 60
 22861            await avroReader.Initalize(async, cancellationToken).ConfigureAwait(false);
 62
 22863            return new Chunk(
 22864                avroReader,
 22865                blockOffset,
 22866                eventIndex,
 22867                chunkPath);
 22868        }
 69
 70        /// <summary>
 71        /// Constructor for mocking.
 72        /// </summary>
 4073        public ChunkFactory() { }
 74    }
 75}

Methods/Properties

.ctor(...)
BuildChunk()
.ctor()