private ChunkCreator.ChunkType useIndexChunks(int numOfCells) {
    int dataChunkSize = ChunkCreator.getInstance().getChunkSize();
    int numOfCellsInChunk = calcNumOfCellsInChunk(dataChunkSize);
    int cellsInLastChunk = numOfCells % numOfCellsInChunk;
    if (cellsInLastChunk == 0) { // There is no free space in the last chunk and thus,
      return ChunkCreator.ChunkType.DATA_CHUNK; // no need to use index chunks.
    } else {
      int chunkSpace = dataChunkSize - ChunkCreator.SIZEOF_CHUNK_HEADER;
      int freeSpaceInLastChunk = chunkSpace - cellsInLastChunk * ClassSize.CELL_CHUNK_MAP_ENTRY;
      if (freeSpaceInLastChunk > INDEX_CHUNK_UNUSED_SPACE_PRECENTAGE * chunkSpace) {
        return ChunkCreator.ChunkType.INDEX_CHUNK;
      }
      return ChunkCreator.ChunkType.DATA_CHUNK;
    }
  }
------------------------------------------------------------------------ C-tor to be used when
new CellChunkImmutableSegment is built as a result of flattening of CSLMImmutableSegment The
given iterator returns the Cells that "survived" the compaction.
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CellChunkImmutableSegment.java