public int compareTo(int left, int right)
    {
        int leftSegment = segment(left);
        int leftSegmentOffset = offset(left);

        int rightSegment = segment(right);
        int rightSegmentOffset = offset(right);

        Slice leftRawSlice = getSegmentRawSlice(leftSegment);
        int leftOffset = offsets[leftSegment][leftSegmentOffset];
        int leftLen = offsets[leftSegment][leftSegmentOffset + 1] - leftOffset;

        Slice rightRawSlice = getSegmentRawSlice(rightSegment);
        int rightOffset = offsets[rightSegment][rightSegmentOffset];
        int rightLen = offsets[rightSegment][rightSegmentOffset + 1] - rightOffset;

        return leftRawSlice.compareTo(leftOffset, leftLen, rightRawSlice, rightOffset, rightLen);
    }
@Test
    public void testCompareTo()
    {
        SegmentedSliceBlockBuilder blockBuilder = new SegmentedSliceBlockBuilder(10, 10);
        for (int i = 0; i < SLICE.length(); i++) {
            blockBuilder.writeBytes(SLICE, i, 1);
            blockBuilder.closeEntry();
        }

        for (int i = 0; i < SLICE.length() - 1; i++) {
            assertLessThan(blockBuilder.compareTo(i, i + 1), 0);
            assertEquals(blockBuilder.compareTo(i, i), 0);
            assertGreaterThan(blockBuilder.compareTo(i + 1, i), 0);
        }
    }