public int appendIndex(final long logIndex, final int position, final byte logType) {
        this.writeLock.lock();
        try {
            assert (logIndex > getLastLogIndex());
            final byte[] writeData = encodeData(toRelativeOffset(logIndex), position, logType);
            return doAppend(logIndex, writeData);
        } finally {
            this.writeLock.unlock();
        }
    }
@Test
    public void testAppendIndex() {
        this.offsetIndex.appendIndex(appendEntry0.getOffset(), appendEntry0.getPosition(), segmentIndex);
        this.offsetIndex.appendIndex(appendEntry1.getOffset(), appendEntry1.getPosition(), segmentIndex);
        this.offsetIndex.appendIndex(appendEntry2.getOffset(), appendEntry2.getPosition(), segmentIndex);
        this.offsetIndex.flush();
        assertEquals(this.offsetIndex.getLastLogIndex(), appendEntry2.getOffset());
    }