private void prepareWriterFor(Cell cell) throws IOException {
      if (currentWriter != null && !isCellAfterCurrentWriter(cell)) return; // Use same writer.

      stopUsingCurrentWriter();
      // See if KV will be past the writer we are about to create; need to add another one.
      while (isCellAfterCurrentWriter(cell)) {
        checkCanCreateWriter();
        createEmptyWriter();
      }
      checkCanCreateWriter();
      hasAnyWriter = true;
      currentWriter = writerFactory.createWriter();
      existingWriters.add(currentWriter);
    }
@param targetBoundaries The boundaries on which writers/files are separated.
@param majorRangeFrom   Major range is the range for which at least one file should be
                        written (because all files are included in compaction).
                        majorRangeFrom is the left boundary.
@param majorRangeTo     The right boundary of majorRange (see majorRangeFrom).
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StripeMultiFileWriter.java