private FetchDataInfo addAbortedTransactions(long startOffset,
                                                 RemoteLogSegmentMetadata segmentMetadata,
                                                 FetchDataInfo fetchInfo,
                                                 UnifiedLog log) throws RemoteStorageException {
        int fetchSize = fetchInfo.records.sizeInBytes();
        OffsetPosition startOffsetPosition = new OffsetPosition(fetchInfo.fetchOffsetMetadata.messageOffset,
                fetchInfo.fetchOffsetMetadata.relativePositionInSegment);

        OffsetIndex offsetIndex = indexCache.getIndexEntry(segmentMetadata).offsetIndex();
        long upperBoundOffset = offsetIndex.fetchUpperBoundOffset(startOffsetPosition, fetchSize)
                .map(position -> position.offset).orElse(segmentMetadata.endOffset() + 1);

        final Set<FetchResponseData.AbortedTransaction> abortedTransactions = new HashSet<>();

        Consumer<List<AbortedTxn>> accumulator =
                abortedTxns -> abortedTransactions.addAll(abortedTxns.stream()
                        .map(AbortedTxn::asAbortedTransaction).collect(Collectors.toList()));

        collectAbortedTransactions(startOffset, upperBoundOffset, segmentMetadata, accumulator, log);

        return new FetchDataInfo(fetchInfo.fetchOffsetMetadata,
                fetchInfo.records,
                fetchInfo.firstEntryIncomplete,
                Optional.of(abortedTransactions.isEmpty() ? Collections.emptyList() : new ArrayList<>(abortedTransactions)));
    }
Returns a map containing the epoch vs start-offset for the given leader epoch map by filtering the epochs that
does not contain any messages/records associated with them.
For ex:
<pre>
{@code
 <epoch - start offset>
 0 - 0
 1 - 10
 2 - 20
 3 - 30
 4 - 40
 5 - 60  // epoch 5 does not have records or messages associated with it
 6 - 60
 7 - 70
}
</pre>
When the above leaderEpochMap is passed to this method, it returns the following map:
<pre>
{@code
 <epoch - start offset>
 0 - 0
 1 - 10
 2 - 20
 3 - 30
 4 - 40
 6 - 60
 7 - 70
}
</pre>
@param leaderEpochs The leader epoch map to be refined.
core/src/main/java/kafka/log/remote/RemoteLogManager.java