code: private void removeAllEntries() {
          // A bit unusual, but we want to make sure we do not call this while the index is active.
          Preconditions.checkState(this.closed, "Cannot call removeAllEntries unless the ReadIndex is closed.");
          int count;
          synchronized (this.lock) {
              this.indexEntries.forEach(entry -> {
                  if (entry.isDataEntry()) {
                      CacheKey key = getCacheKey(entry);
                      this.cache.remove(key);
                  }
              });
  
              count = this.indexEntries.size();
              this.indexEntries.clear();
          }
  
          if (count > 0) {
              log.debug("{}: Cleared all cache entries ({}).", this.traceObjectId, count);
          }
      }
docs: Removes all entries from the cache and the SortedIndex, regardless of their state.
  
  @throws IllegalStateException If the StreamSegmentReadIndex is not closed.