private synchronized void clearSnapshots() {
    queueTailIndex2SnapshotsCache.setLeft(Long.MIN_VALUE);
    queueTailIndex2SnapshotsCache
        .getRight()
        .forEach(
            event ->
                event.decreaseReferenceCount(AbstractPipeListeningQueue.class.getName(), false));
    queueTailIndex2SnapshotsCache.setRight(new ArrayList<>());
  }
{@link AbstractPipeListeningQueue} is the encapsulation of the {@link
AbstractSerializableListeningQueue} to enable using reference count to control opening and
closing. This class also enables a {@link PipeTask} to find the snapshots close enough to send if
existed.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/datastructure/queue/listening/AbstractPipeListeningQueue.java