@Override
    public void delete(final Segment segment) {
        while (true) {
            int index = -1;
            final Segment[] curViews = segmentList.get();
            for (int i = 0; i < curViews.length; i++) {
                if (curViews[i] == segment) {
                    index = i;
                    break;
                }
            }
            if (index == -1) {
                return;
            }
            final Segment[] update = new Segment[curViews.length - 1];
            System.arraycopy(curViews, 0, update, 0, index);
            if (index + 1 < curViews.length) {
                System.arraycopy(curViews, index + 1, update, index, curViews.length - index - 1);
            }
            if (this.segmentList.compareAndSet(curViews, update)) {
                return;
            }
        }
    }
Check FileSegments whether is expired, close all expired FileSegments, and then delete these files.

@param sb   string buffer
inlong-tubemq/tubemq-server/src/main/java/org/apache/inlong/tubemq/server/broker/msgstore/disk/FileSegmentList.java