code: public void discardCompletedSegments(final UUID cfId, final ReplayPosition context)
      {
          logger.debug("discard completed log segments for {}, column family {}", context, cfId);
  
          // Go thru the active segment files, which are ordered oldest to newest, marking the
          // flushed CF as clean, until we reach the segment file containing the ReplayPosition passed
          // in the arguments. Any segments that become unused after they are marked clean will be
          // recycled or discarded.
          for (Iterator<CommitLogSegment> iter = allocator.getActiveSegments().iterator(); iter.hasNext();)
          {
              CommitLogSegment segment = iter.next();
              segment.markClean(cfId, context);
  
              if (segment.isUnused())
              {
                  logger.debug("Commit log segment {} is unused", segment);
                  allocator.recycleSegment(segment);
              }
              else
              {
                  logger.debug("Not safe to delete{} commit log segment {}; dirty is {}",
                          (iter.hasNext() ? "" : " active"), segment, segment.dirtyString());
              }
  
              // Don't mark or try to delete any newer segments once we've reached the one containing the
              // position of the flush.
              if (segment.contains(context))
                  break;
          }
      }
docs: Modifies the per-CF dirty cursors of any commit log segments for the column family according to the position
  given. Discards any commit log segments that are no longer used.
  
  @param cfId    the column family ID that was flushed
  @param context the replay position of the flush