@Override
    public void append(ExtendedCell cell) throws IOException {
      // If we are waiting for opportunity to close and we started writing different row,
      // discard the writer and stop waiting.
      boolean doCreateWriter = false;
      if (currentWriter == null) {
        // First append ever, do a sanity check.
        sanityCheckLeft(left, cell);
        doCreateWriter = true;
      } else if (
        lastRowInCurrentWriter != null && !PrivateCellUtil.matchingRows(cell,
          lastRowInCurrentWriter, 0, lastRowInCurrentWriter.length)
      ) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Stopping to use a writer after [" + Bytes.toString(lastRowInCurrentWriter)
            + "] row; wrote out " + cellsInCurrentWriter + " kvs");
        }
        lastRowInCurrentWriter = null;
        cellsInCurrentWriter = 0;
        cellsSeenInPrevious += cellsSeen;
        doCreateWriter = true;
      }
      if (doCreateWriter) {
        // make a copy
        byte[] boundary = existingWriters.isEmpty() ? left : CellUtil.cloneRow(cell);
        if (LOG.isDebugEnabled()) {
          LOG.debug("Creating new writer starting at [" + Bytes.toString(boundary) + "]");
        }
        currentWriter = writerFactory.createWriter();
        boundaries.add(boundary);
        existingWriters.add(currentWriter);
      }

      currentWriter.append(cell);
      lastCell = cell; // for the sanity check
      ++cellsInCurrentWriter;
      cellsSeen = cellsInCurrentWriter;
      if (this.sourceScanner != null) {
        cellsSeen = Math.max(cellsSeen,
          this.sourceScanner.getEstimatedNumberOfKvsScanned() - cellsSeenInPrevious);
      }

      // If we are not already waiting for opportunity to close, start waiting if we can
      // create any more writers and if the current one is too big.
      if (
        lastRowInCurrentWriter == null && existingWriters.size() < targetCount
          && cellsSeen >= targetCells
      ) {
        lastRowInCurrentWriter = CellUtil.cloneRow(cell); // make a copy
        if (LOG.isDebugEnabled()) {
          LOG.debug("Preparing to start a new writer after ["
            + Bytes.toString(lastRowInCurrentWriter) + "] row; observed " + cellsSeen
            + " kvs and wrote out " + cellsInCurrentWriter + " kvs");
        }
      }
    }
@param targetCount The maximum count of writers that can be created.
@param targetKvs   The number of KVs to read from source before starting each new writer.
@param left        The left boundary of the first writer.
@param right       The right boundary of the last writer.
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StripeMultiFileWriter.java