public CompletableFuture<Long> getMinOffsetFromFileAsync() {
        int length = MessageFormatUtil.QUEUE_OFFSET_POSITION + Long.BYTES;
        if (this.fileSegmentTable.isEmpty() ||
            this.getCommitOffset() - this.getMinOffset() < length) {
            return CompletableFuture.completedFuture(GET_OFFSET_ERROR);
        }
        return this.readAsync(this.getMinOffset(), length)
            .thenApply(buffer -> {
                firstOffset.set(MessageFormatUtil.getQueueOffset(buffer));
                return firstOffset.get();
            });
    }
@Test
    public void getMinOffsetFromFileAsyncTest() {
        String filePath = MessageStoreUtil.toFilePath(queue);
        FlatCommitLogFile flatFile = flatFileFactory.createFlatFileForCommitLog(filePath);

        // append some messages
        for (int i = 6; i < 9; i++) {
            ByteBuffer byteBuffer = MessageFormatUtilTest.buildMockedMessageBuffer();
            byteBuffer.putLong(MessageFormatUtil.QUEUE_OFFSET_POSITION, i);
            Assert.assertEquals(AppendResult.SUCCESS, flatFile.append(byteBuffer, i));
        }
        Assert.assertEquals(-1L, flatFile.getMinOffsetFromFileAsync().join().longValue());

        // append some messages
        for (int i = 9; i < 30; i++) {
            if (i == 20) {
                flatFile.commitAsync().join();
                flatFile.rollingNewFile(flatFile.getAppendOffset());
            }
            ByteBuffer byteBuffer = MessageFormatUtilTest.buildMockedMessageBuffer();
            byteBuffer.putLong(MessageFormatUtil.QUEUE_OFFSET_POSITION, i);
            Assert.assertEquals(AppendResult.SUCCESS, flatFile.append(byteBuffer, i));
        }

        flatFile.commitAsync().join();
        Assert.assertEquals(6L, flatFile.getMinOffsetFromFile());
        Assert.assertEquals(6L, flatFile.getMinOffsetFromFileAsync().join().longValue());

        // recalculate min offset here
        flatFile.destroyExpiredFile(20L);
        Assert.assertEquals(20L, flatFile.getMinOffsetFromFile());
        Assert.assertEquals(20L, flatFile.getMinOffsetFromFileAsync().join().longValue());

        // clean expired file again
        flatFile.destroyExpiredFile(20L);
        Assert.assertEquals(20L, flatFile.getMinOffsetFromFile());
        Assert.assertEquals(20L, flatFile.getMinOffsetFromFileAsync().join().longValue());
    }