private boolean isOffsetPresentInFirstLocalSegment(TopicPartition topicPartition,
                                                       Long firstLogFileBaseOffset,
                                                       Long offsetToSearch)  {
        if (offsetToSearch < firstLogFileBaseOffset) {
            return false;
        }
        if (offsetToSearch.equals(firstLogFileBaseOffset)) {
            return true;
        }
        File logDir = brokerStorageDirectories.stream()
                .filter(dir -> dirContainsTopicPartition(topicPartition, dir))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException(String.format("[BrokerId=%d] Directory for the topic-partition %s " +
                "was not found", brokerId, topicPartition)));
        File partitionDir = new File(logDir.getAbsolutePath(), topicPartition.toString());
        File firstSegmentFile = new File(partitionDir.getAbsolutePath(),
                LogFileUtils.filenamePrefixFromOffset(firstLogFileBaseOffset) + LogFileUtils.LOG_FILE_SUFFIX);
        try (FileRecords fileRecords = FileRecords.open(firstSegmentFile, false)) {
            for (FileLogInputStream.FileChannelRecordBatch batch : fileRecords.batches()) {
                if (batch.baseOffset() <= offsetToSearch && batch.lastOffset() >= offsetToSearch) {
                    return true;
                }
            }
        } catch (final IOException ex) {
            return false;
        }
        return false;
    }
Check if the given offset is present in the first local segment of the given topic-partition.
@param topicPartition The topic-partition to check.
@param firstLogFileBaseOffset The base offset of the first local segment.
@param offsetToSearch The offset to search.
@return true if the offset is present in the first local segment, false otherwise.
storage/src/test/java/org/apache/kafka/tiered/storage/utils/BrokerLocalStorage.java