internal async virtual Task <Chunk> BuildChunk(
            bool async,
            string chunkPath,
            long blockOffset = 0,
            long eventIndex  = 0,
            CancellationToken cancellationToken = default)
        {
            BlobClient blobClient = _containerClient.GetBlobClient(chunkPath);
            AvroReader avroReader;

            Stream dataStream = _lazyLoadingBlobStreamFactory.BuildLazyLoadingBlobStream(
                blobClient,
                offset: blockOffset,
                blockSize: Constants.ChangeFeed.ChunkBlockDownloadSize);

            // We aren't starting from the beginning of the Chunk
            if (blockOffset != 0)
            {
                Stream headStream = _lazyLoadingBlobStreamFactory.BuildLazyLoadingBlobStream(
                    blobClient,
                    offset: 0,
                    blockSize: Constants.ChangeFeed.LazyLoadingBlobStreamBlockSize);

                avroReader = _avroReaderFactory.BuildAvroReader(
                    dataStream,
                    headStream,
                    blockOffset,
                    eventIndex);
            }
            else
            {
                avroReader = _avroReaderFactory.BuildAvroReader(dataStream);
            }

            await avroReader.Initalize(async, cancellationToken).ConfigureAwait(false);

            return(new Chunk(
                       avroReader,
                       blockOffset,
                       eventIndex,
                       chunkPath));
        }
Exemplo n.º 2
0
        public virtual Chunk BuildChunk(
            string chunkPath,
            long?blockOffset = default,
            long?eventIndex  = default)
        {
            BlobClient blobClient = _containerClient.GetBlobClient(chunkPath);

            blockOffset ??= 0;
            eventIndex ??= 0;
            AvroReader avroReader;

            Stream dataStream = _lazyLoadingBlobStreamFactory.BuildLazyLoadingBlobStream(
                blobClient,
                offset: blockOffset.Value,
                blockSize: Constants.ChangeFeed.ChunkBlockDownloadSize);

            // We aren't starting from the beginning of the Chunk
            if (blockOffset != 0)
            {
                Stream headStream = _lazyLoadingBlobStreamFactory.BuildLazyLoadingBlobStream(
                    blobClient,
                    offset: 0,
                    blockSize: 3 * Constants.KB);

                avroReader = _avroReaderFactory.BuildAvroReader(
                    dataStream,
                    headStream,
                    blockOffset.Value,
                    eventIndex.Value);
            }
            else
            {
                avroReader = _avroReaderFactory.BuildAvroReader(dataStream);
            }

            return(new Chunk(
                       avroReader,
                       blockOffset.Value,
                       eventIndex.Value));
        }
Exemplo n.º 3
0
        internal virtual Chunk BuildChunk(
            string chunkPath,
            long blockOffset = 0,
            long eventIndex  = 0)
        {
            BlobClient blobClient = _containerClient.GetBlobClient(chunkPath);
            AvroReader avroReader;

            Stream dataStream = _lazyLoadingBlobStreamFactory.BuildLazyLoadingBlobStream(
                blobClient,
                offset: blockOffset,
                blockSize: Constants.ChangeFeed.ChunkBlockDownloadSize);

            // We aren't starting from the beginning of the Chunk
            if (blockOffset != 0)
            {
                Stream headStream = _lazyLoadingBlobStreamFactory.BuildLazyLoadingBlobStream(
                    blobClient,
                    offset: 0,
                    blockSize: Constants.ChangeFeed.LazyLoadingBlobStreamBlockSize);

                avroReader = _avroReaderFactory.BuildAvroReader(
                    dataStream,
                    headStream,
                    blockOffset,
                    eventIndex);
            }
            else
            {
                avroReader = _avroReaderFactory.BuildAvroReader(dataStream);
            }

            return(new Chunk(
                       avroReader,
                       blockOffset,
                       eventIndex));
        }