public void addIndexes(int maxIndex, int[] dictionaryIndexes, int indexCount)
    {
        if (indexCount == 0 && indexRetainedBytes > 0) {
           // Ignore empty segment, since there are other segments present.
            return;
        }
        checkState(maxIndex >= lastMaxIndex, "LastMax is greater than the current max");
        lastMaxIndex = maxIndex;

        if (maxIndex <= Byte.MAX_VALUE) {
            byte[] byteIndexes = new byte[indexCount];
            for (int i = 0; i < indexCount; i++) {
                byteIndexes[i] = (byte) dictionaryIndexes[i];
            }
            appendByteIndexes(byteIndexes);
        }
        else if (maxIndex <= Short.MAX_VALUE) {
            short[] shortIndexes = new short[indexCount];
            for (int i = 0; i < indexCount; i++) {
                shortIndexes[i] = (short) dictionaryIndexes[i];
            }
            appendShortIndexes(shortIndexes);
        }
        else {
            int[] intIndexes = Arrays.copyOf(dictionaryIndexes, indexCount);
            appendIntegerIndexes(intIndexes);
        }
    }
@Test
    public void testEmptyDictionary()
    {
        DictionaryRowGroupBuilder rowGroupBuilder = new DictionaryRowGroupBuilder();
        rowGroupBuilder.addIndexes(-1, new int[0], 0);

        byte[] byteIndexes = getByteIndexes(rowGroupBuilder);
        assertEquals(0, byteIndexes.length);
    }