private static long getSegmentsKeySize(List<? extends Segment> list) {
    long res = 0;
    for (Segment segment : list) {
      res += segment.getDataSize();
    }
    return res;
  }
Swaps the versioned list at the tail of the pipeline with a new segment. Swapping only if there
were no changes to the suffix of the list since the version list was created.
@param versionedList    suffix of the pipeline to be replaced can be tail or all the pipeline
@param segment          new segment to replace the suffix. Can be null if the suffix just needs
                        to be removed.
@param closeSuffix      whether to close the suffix (to release memory), as part of swapping it
                        out During index merge op this will be false and for compaction it will
                        be true.
@param updateRegionSize whether to update the region size. Update the region size, when the
                        pipeline is swapped as part of in-memory-flush and further
                        merge/compaction. Don't update the region size when the swap is result
                        of the snapshot (flush-to-disk).
@return true iff swapped tail with new segment
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CompactionPipeline.java