@Override public synchronized void close() throws IOException { isOpen = false; deletePendingFiles(); }
@Override public synchronized Set<String> getPendingDeletions() throws IOException { deletePendingFiles(); if (pendingDeletes.isEmpty()) { return Collections.emptySet(); } else { return Collections.unmodifiableSet(new HashSet<>(pendingDeletes)); } } }
private void maybeDeletePendingFiles() throws IOException { if (pendingDeletes.isEmpty() == false) { // This is a silly heuristic to try to avoid O(N^2), where N = number of files pending deletion, behaviour on Windows: int count = opsSinceLastDelete.incrementAndGet(); if (count >= pendingDeletes.size()) { opsSinceLastDelete.addAndGet(-count); deletePendingFiles(); } } }
@Override public synchronized void close() throws IOException { isOpen = false; deletePendingFiles(); }
private void maybeDeletePendingFiles() throws IOException { if (pendingDeletes.isEmpty() == false) { // This is a silly heuristic to try to avoid O(N^2), where N = number of files pending deletion, behaviour on Windows: int count = opsSinceLastDelete.incrementAndGet(); if (count >= pendingDeletes.size()) { opsSinceLastDelete.addAndGet(-count); deletePendingFiles(); } } }
@Override public synchronized Set<String> getPendingDeletions() throws IOException { deletePendingFiles(); if (pendingDeletes.isEmpty()) { return Collections.emptySet(); } else { return Collections.unmodifiableSet(new HashSet<>(pendingDeletes)); } } }