@Override
    public void truncate() {
        truncateToEntries(0);
    }
@Test
    public void truncate() throws IOException {
        try (OffsetIndex idx = new OffsetIndex(nonExistentTempFile(), 0L, 10 * 8)) {
            idx.truncate();
            IntStream.range(1, 10).forEach(i -> idx.append(i, i));

            // now check the last offset after various truncate points and validate that we can still append to the index.
            idx.truncateTo(12);
            assertEquals(new OffsetPosition(9, 9), idx.lookup(10),
                    "Index should be unchanged by truncate past the end");
            assertEquals(9, idx.lastOffset(),
                    "9 should be the last entry in the index");

            idx.append(10, 10);
            idx.truncateTo(10);
            assertEquals(new OffsetPosition(9, 9), idx.lookup(10),
                    "Index should be unchanged by truncate at the end");
            assertEquals(9, idx.lastOffset(),
                    "9 should be the last entry in the index");
            idx.append(10, 10);

            idx.truncateTo(9);
            assertEquals(new OffsetPosition(8, 8), idx.lookup(10),
                    "Index should truncate off last entry");
            assertEquals(8, idx.lastOffset(),
                    "8 should be the last entry in the index");
            idx.append(9, 9);

            idx.truncateTo(5);
            assertEquals(new OffsetPosition(4, 4), idx.lookup(10),
                    "4 should be the last entry in the index");
            assertEquals(4, idx.lastOffset(),
                    "4 should be the last entry in the index");
            idx.append(5, 5);

            idx.truncate();
            assertEquals(0, idx.entries(), "Full truncation should leave no entries");
        }

    }