CompletableFuture<Void> prune(Supplier<Set<Long>> initStreamSetObjectIdsSupplier) {
        if (initStreamSetObjectIdsSupplier == null) {
            return CompletableFuture.failedFuture(new IllegalStateException("initStreamSetObjectIdsSupplier cannot be null"));
        }
        return execCompose(() -> {
            writeLock.lock();
            try {
                Set<Long> streamSetObjectIds = initStreamSetObjectIdsSupplier.get();
                Iterator<Map.Entry<Long, SparseRangeIndex>> iterator = streamRangeIndexMap.entrySet().iterator();
                boolean pruned = false;
                while (iterator.hasNext()) {
                    Map.Entry<Long, SparseRangeIndex> entry = iterator.next();
                    SparseRangeIndex sparseRangeIndex = entry.getValue();
                    Set<Long> invalidateObjectIds = new HashSet<>();
                    for (RangeIndex rangeIndex : sparseRangeIndex.getRangeIndexList()) {
                        if (!streamSetObjectIds.contains(rangeIndex.getObjectId())) {
                            invalidateObjectIds.add(rangeIndex.getObjectId());
                        }
                    }
                    if (invalidateObjectIds.isEmpty()) {
                        continue;
                    }
                    totalSize += sparseRangeIndex.compact(null, invalidateObjectIds);
                    if (sparseRangeIndex.length() == 0) {
                        iterator.remove();
                    }
                    pruned = true;
                }
                return pruned ? upload() : CompletableFuture.completedFuture(null);
            } catch (Throwable t) {
                LOGGER.error("Failed to prune local sparse index, clear all", t);
                clear();
                return CompletableFuture.failedFuture(t);
            } finally {
                writeLock.unlock();
            }
        });
    }
Search for the object with the maximum start offset less than or equal to the given start offset.
If not found, return -1.
s3stream/src/main/java/com/automq/stream/s3/index/LocalStreamRangeIndexCache.java