code: @SuppressWarnings("unchecked")
    public Map<BsonValue, ChangeEvent<BsonDocument>> getEvents() {
      nsLock.readLock().lock();
      final Map<BsonValue, ChangeEvent<BsonDocument>> events;
      try {
        events = new HashMap<>(this.events);
      } finally {
        nsLock.readLock().unlock();
      }
  
      nsLock.writeLock().lock();
      try {
        this.events.clear();
        return events;
      } finally {
        nsLock.writeLock().unlock();
      }
    }
docs: Returns the latest change events, and clears them from the change stream listener.
  
  @return the latest change events.