Skip to content

Commit b48fb1e

Browse files
committed
Improve deleteByPrefix of CloudStorageWrapper
1 parent a191b70 commit b48fb1e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

core/src/main/java/com/scalar/db/storage/objectstorage/cloudstorage/CloudStorageWrapper.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.google.cloud.storage.BlobInfo;
77
import com.google.cloud.storage.Storage;
88
import com.google.cloud.storage.StorageBatch;
9+
import com.google.cloud.storage.StorageBatchResult;
910
import com.google.cloud.storage.StorageException;
1011
import com.google.cloud.storage.StorageOptions;
1112
import com.google.common.annotations.VisibleForTesting;
@@ -17,6 +18,7 @@
1718
import java.io.IOException;
1819
import java.nio.ByteBuffer;
1920
import java.nio.charset.StandardCharsets;
21+
import java.util.ArrayList;
2022
import java.util.List;
2123
import java.util.Optional;
2224
import java.util.Set;
@@ -183,10 +185,14 @@ public void deleteByPrefix(String prefix) throws ObjectStorageWrapperException {
183185
int endIndex = Math.min(i + BATCH_DELETE_SIZE_LIMIT, blobIds.size());
184186
List<BlobId> batch = blobIds.subList(i, endIndex);
185187
StorageBatch storageBatch = storage.batch();
188+
List<StorageBatchResult<Boolean>> results = new ArrayList<>();
186189
for (BlobId blobId : batch) {
187-
storageBatch.delete(blobId);
190+
results.add(storageBatch.delete(blobId));
188191
}
189192
storageBatch.submit();
193+
for (StorageBatchResult<Boolean> result : results) {
194+
result.get();
195+
}
190196
}
191197
} catch (Exception e) {
192198
throw new ObjectStorageWrapperException(

0 commit comments

Comments
 (0)