public void upsert(ExtendedCell cell, long readpoint, MemStoreSizing memStoreSizing,
    boolean sizeAddedPreOperation) {
    internalAdd(cell, false, memStoreSizing, sizeAddedPreOperation);

    // Get the Cells for the row/family/qualifier regardless of timestamp.
    // For this case we want to clean up any other puts
    ExtendedCell firstCell =
      PrivateCellUtil.createFirstOnRowColTS(cell, HConstants.LATEST_TIMESTAMP);
    SortedSet<ExtendedCell> ss = this.tailSet(firstCell);
    Iterator<ExtendedCell> it = ss.iterator();
    // versions visible to oldest scanner
    int versionsVisible = 0;
    while (it.hasNext()) {
      ExtendedCell cur = it.next();

      if (cell == cur) {
        // ignore the one just put in
        continue;
      }
      // check that this is the row and column we are interested in, otherwise bail
      if (CellUtil.matchingRows(cell, cur) && CellUtil.matchingQualifier(cell, cur)) {
        // only remove Puts that concurrent scanners cannot possibly see
        if (cur.getTypeByte() == KeyValue.Type.Put.getCode() && cur.getSequenceId() <= readpoint) {
          if (versionsVisible >= 1) {
            // if we get here we have seen at least one version visible to the oldest scanner,
            // which means we can prove that no scanner will see this version

            // false means there was a change, so give us the size.
            // TODO when the removed cell ie.'cur' having its data in MSLAB, we can not release that
            // area. Only the Cell object as such going way. We need to consider cellLen to be
            // decreased there as 0 only. Just keeping it as existing code now. We need to know the
            // removed cell is from MSLAB or not. Will do once HBASE-16438 is in
            int cellLen = getCellLength(cur);
            long heapSize = heapSizeChange(cur, true);
            long offHeapSize = offHeapSizeChange(cur, true);
            incMemStoreSize(-cellLen, -heapSize, -offHeapSize, -1);
            if (memStoreSizing != null) {
              memStoreSizing.decMemStoreSize(cellLen, heapSize, offHeapSize, 1);
            }
            it.remove();
          } else {
            versionsVisible++;
          }
        }
      } else {
        // past the row or column, done
        break;
      }
    }
  }
Adds the given cell into the segment
@param cell      the cell to add
@param mslabUsed whether using MSLAB
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MutableSegment.java