Source:
private void startNextBlob(Optional<IndexedRecord> optionalIndexedRecord) throws IOException { if (currentBlobWriterComponents != null) { LOG.info("Starting new blob as current blob size is " + currentBlobWriterComponents.azureBlobOutputStream.getSize() + " and max blob size is " + maxBlobSize + " or number of records is " + recordsInCurrentBlob + " and max records in blob is " + maxRecordsPerBlob); currentBlobWriterComponents.dataFileWriter.flush(); currentBlobWriterComponents.azureBlobOutputStream.releaseBuffer(); recordsInCurrentBlob = 0; } if (datumWriter == null) { if (optionalIndexedRecord.isPresent()) { IndexedRecord record = optionalIndexedRecord.get(); schema = record.getSchema(); if (record instanceof SpecificRecord) { datumWriter = new SpecificDatumWriter<>(schema); } else { datumWriter = new GenericDatumWriter<>(schema); } } else { throw new IllegalStateException("Writing without schema setup."); } } String blobURL; if (useRandomStringInBlobName) { blobURL = String.format(BLOB_NAME_RANDOM_STRING_AVRO, blobURLPrefix, UTC_FORMATTER.format(System.currentTimeMillis()), blobNumber, UUID.randomUUID().toString().substring(0, 8), compression.getFileExtension()); } else { blobURL = String.format(BLOB_NAME_AVRO, blobURLPrefix, UTC_FORMATTER.format(System.currentTimeMillis()), blobNumber, compression.getFileExtension()); } LOG.info("Creating new blob: {}", blobURL); BlockBlobAsyncClient blockBlobAsyncClient = containerAsyncClient.getBlobAsyncClient(blobURL).getBlockBlobAsyncClient(); blobNumber++; DataFileWriter<IndexedRecord> dataFileWriter = new DataFileWriter<>(datumWriter); AzureBlobOutputStream azureBlobOutputStream = new AzureBlobOutputStream(blockBlobAsyncClient, blobThreadPool, metrics, flushTimeoutMs, maxBlockFlushThresholdSize, compression); dataFileWriter.create(schema, azureBlobOutputStream); dataFileWriter.setFlushOnEveryBlock(false); this.currentBlobWriterComponents = new BlobWriterComponents(dataFileWriter, azureBlobOutputStream, blockBlobAsyncClient); allBlobWriterComponents.add(this.currentBlobWriterComponents); LOG.info("Created new blob: {}", blobURL); }

Target:
private void startNextBlob(Optional<IndexedRecord> optionalIndexedRecord) throws IOException { if (currentBlobWriterComponents != null) { LOG.info("Starting new blob as current blob size is " + currentBlobWriterComponents.azureBlobOutputStream.getSize() + " and max blob size is " + maxBlobSize + " or number of records is " + recordsInCurrentBlob + " and max records in blob is " + maxRecordsPerBlob); currentBlobWriterComponents.dataFileWriter.flush(); currentBlobWriterComponents.azureBlobOutputStream.releaseBuffer(); recordsInCurrentBlob = 0; } if (datumWriter == null) { if (optionalIndexedRecord.isPresent()) { IndexedRecord record = optionalIndexedRecord.get(); schema = record.getSchema(); if (record instanceof SpecificRecord) { datumWriter = new SpecificDatumWriter<>(schema); } else { datumWriter = new GenericDatumWriter<>(schema); } } else { throw new IllegalStateException("Writing without schema setup."); } } String blobURL; if (useRandomStringInBlobName) { blobURL = String.format(BLOB_NAME_RANDOM_STRING_AVRO, blobURLPrefix, UTC_FORMATTER.format(System.currentTimeMillis()), UUID.randomUUID().toString().substring(0, 8), compression.getFileExtension()); } else { blobURL = String.format(BLOB_NAME_AVRO, blobURLPrefix, UTC_FORMATTER.format(System.currentTimeMillis()), compression.getFileExtension()); } LOG.info("Creating new blob: {}", blobURL); BlockBlobAsyncClient blockBlobAsyncClient = containerAsyncClient.getBlobAsyncClient(blobURL).getBlockBlobAsyncClient(); DataFileWriter<IndexedRecord> dataFileWriter = new DataFileWriter<>(datumWriter); AzureBlobOutputStream azureBlobOutputStream = new AzureBlobOutputStream(blockBlobAsyncClient, blobThreadPool, metrics, flushTimeoutMs, maxBlockFlushThresholdSize, compression); dataFileWriter.create(schema, azureBlobOutputStream); dataFileWriter.setFlushOnEveryBlock(false); this.currentBlobWriterComponents = new BlobWriterComponents(dataFileWriter, azureBlobOutputStream, blockBlobAsyncClient); allBlobWriterComponents.add(this.currentBlobWriterComponents); LOG.info("Created new blob: {}", blobURL); }