public static List<DwrfProto.ColumnEncoding> toColumnEncodings(Map<Integer, ColumnEncoding> columnEncodingsByNodeId)
    {
        ImmutableList.Builder<DwrfProto.ColumnEncoding> columnEncodings = ImmutableList.builder();
        for (Entry<Integer, ColumnEncoding> entry : columnEncodingsByNodeId.entrySet()) {
            int nodeId = entry.getKey();
            ColumnEncoding columnEncoding = entry.getValue();

            if (columnEncoding.getAdditionalSequenceEncodings().isPresent()) {
                Map<Integer, DwrfSequenceEncoding> sequences = columnEncoding.getAdditionalSequenceEncodings().get();
                for (Entry<Integer, DwrfSequenceEncoding> sequenceEntry : sequences.entrySet()) {
                    int sequence = sequenceEntry.getKey();
                    DwrfSequenceEncoding sequenceEncoding = sequenceEntry.getValue();
                    columnEncodings.add(toColumnEncoding(nodeId, sequence, sequenceEncoding));
                }
            }
            else {
                columnEncodings.add(toColumnEncoding(nodeId, columnEncoding));
            }
        }
        return columnEncodings.build();
    }
@Test(dataProvider = "sequenceKeyProvider")
    public void testToColumnEncodingsWithSequence(DwrfProto.KeyInfo key1, DwrfProto.KeyInfo key2)
    {
        int expectedDictionarySize1 = 5;
        int expectedSequenceId1 = 0;
        ColumnEncoding valueEncoding1 = new ColumnEncoding(DIRECT, expectedDictionarySize1);
        DwrfSequenceEncoding sequenceEncoding1 = new DwrfSequenceEncoding(key1, valueEncoding1);

        int expectedDictionarySize2 = 10;
        int expectedSequenceId2 = 5;
        ColumnEncoding valueEncoding2 = new ColumnEncoding(DICTIONARY, expectedDictionarySize2);
        DwrfSequenceEncoding sequenceEncoding2 = new DwrfSequenceEncoding(key2, valueEncoding2);

        ImmutableSortedMap<Integer, DwrfSequenceEncoding> additionalSequenceEncodings = ImmutableSortedMap.of(
                expectedSequenceId1, sequenceEncoding1,
                expectedSequenceId2, sequenceEncoding2);
        ColumnEncoding columnEncoding = new ColumnEncoding(DIRECT, 0, Optional.of(additionalSequenceEncodings));

        List<DwrfProto.ColumnEncoding> actual = toColumnEncodings(ImmutableMap.of(COLUMN_ID, columnEncoding));
        assertEquals(actual.size(), 2);

        DwrfProto.ColumnEncoding actualValueEncoding1 = actual.get(0);
        assertEquals(actualValueEncoding1.getColumn(), COLUMN_ID);
        assertEquals(actualValueEncoding1.getKind(), DwrfProto.ColumnEncoding.Kind.DIRECT);
        assertEquals(actualValueEncoding1.getDictionarySize(), expectedDictionarySize1);

        assertEquals(actualValueEncoding1.getSequence(), expectedSequenceId1);
        assertEquals(actualValueEncoding1.getKey(), key1);

        DwrfProto.ColumnEncoding actualValueEncoding2 = actual.get(1);
        assertEquals(actualValueEncoding2.getColumn(), COLUMN_ID);
        assertEquals(actualValueEncoding2.getKind(), DwrfProto.ColumnEncoding.Kind.DICTIONARY);
        assertEquals(actualValueEncoding2.getDictionarySize(), expectedDictionarySize2);
        assertEquals(actualValueEncoding2.getSequence(), expectedSequenceId2);
        assertEquals(actualValueEncoding2.getKey(), key2);
    }