Skip to content

Commit

Permalink
[doc] clarify lazy-eval of removeObjects
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinSmile committed Nov 7, 2019
1 parent cd1109b commit 6a53d9b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions api/src/main/java/io/minio/MinioClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2987,19 +2987,27 @@ private List<DeleteError> removeObject(String bucketName, List<DeleteObject> obj
/**
* Removes multiple objects from a bucket.
*
* <p><b>Note:</b></p>
* This method does lazy evaluation. You need to traverse over the returned Iterable to do the
* real delete jobs.
*
* </p><b>Example:</b><br>
* <pre>{@code // Create object list for removal.
* List<String> objectNames = new LinkedList<String>();
* objectNames.add("my-objectname1");
* objectNames.add("my-objectname2");
* objectNames.add("my-objectname3");
* // need to traverse over the returned Iterable to do the real delete jobs.
* for (Result<DeleteError> errorResult: minioClient.removeObjects("my-bucketname", objectNames)) {
* DeleteError error = errorResult.get();
* System.out.println("Failed to remove '" + error.objectName() + "'. Error:" + error.message());
* } }</pre>
*
* @param bucketName Bucket name.
* @param objectNames List of Object names in the bucket.
*
* @return (lazy) Iterable of the delete-error Result.
*
*/
public Iterable<Result<DeleteError>> removeObjects(final String bucketName, final Iterable<String> objectNames) {
return new Iterable<Result<DeleteError>>() {
Expand Down
3 changes: 2 additions & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -3079,7 +3079,7 @@ __Parameters__

|Return Type | Exceptions |
|:--- |:--- |
| ``Iterable<Result<DeleteError>>``:an iterator of Result DeleteError. | _None_ |
| ``Iterable<Result<DeleteError>>``:a lazy iterator of Result DeleteError. | _None_ |



Expand All @@ -3093,6 +3093,7 @@ objectNames.add("my-objectname2");
objectNames.add("my-objectname3");
try {
// Remove object all objects in objectNames list from the bucket my-bucketname.
// Lazy evaluation. Need to traverse over the returned Iterable to do the real delete jobs.
for (Result<DeleteError> errorResult: minioClient.removeObjects("my-bucketname", objectNames)) {
DeleteError error = errorResult.get();
System.out.println("Failed to remove '" + error.objectName() + "'. Error:" + error.message());
Expand Down
1 change: 1 addition & 0 deletions examples/RemoveObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public static void main(String[] args)
objectNames.add("my-objectname3");

// Remove object all objects 'objectNames' list from 'my-bucketname'.
// Lazy evaluation. Need to traverse over the returned Iterable to do the real delete jobs.
for (Result<DeleteError> errorResult: minioClient.removeObjects("my-bucketname", objectNames)) {
DeleteError error = errorResult.get();
System.out.println("Failed to remove '" + error.objectName() + "'. Error:" + error.message());
Expand Down

0 comments on commit 6a53d9b

Please sign in to comment.