public TimestampOffset lookup(long targetTimestamp) {
        return maybeLock(lock, () -> {
            ByteBuffer idx = mmap().duplicate();
            int slot = largestLowerBoundSlotFor(idx, targetTimestamp, IndexSearchType.KEY);
            if (slot == -1)
                return new TimestampOffset(RecordBatch.NO_TIMESTAMP, baseOffset());
            else
                return parseEntry(idx, slot);
        });
    }
@Test
    public void testLookUp() {
        // Empty time index
        assertEquals(new TimestampOffset(-1L, baseOffset), idx.lookup(100L));

        // Add several time index entries.
        appendEntries(maxEntries - 1);

        // look for timestamp smaller than the earliest entry
        assertEquals(new TimestampOffset(-1L, baseOffset), idx.lookup(9));
        // look for timestamp in the middle of two entries.
        assertEquals(new TimestampOffset(20L, 65L), idx.lookup(25));
        // look for timestamp same as the one in the entry
        assertEquals(new TimestampOffset(30L, 75L), idx.lookup(30));
    }