frankgh commented on code in PR #72:
URL: https://github.com/apache/cassandra-sidecar/pull/72#discussion_r1361345814


##########
src/main/java/org/apache/cassandra/sidecar/snapshots/SnapshotPathBuilder.java:
##########
@@ -140,79 +139,77 @@ public Future<List<SnapshotFile>> 
listSnapshotDirectory(String snapshotDirectory
               logger.debug("Found {} files in snapshot directory '{}'", 
list.size(), snapshotDirectory);
 
               // Prepare futures to get properties for all the files from 
listing the snapshot directory
-              //noinspection rawtypes
-              List<Future> futures = list.stream()
-                                         .map(fs::props)
-                                         .collect(Collectors.toList());
-
-              CompositeFuture.all(futures)
-                             .onFailure(cause -> {
-                                 logger.debug("Failed to get FileProps", 
cause);
-                                 promise.fail(cause);
-                             })
-                             .onSuccess(ar -> {
-
-                                 // Create a pair of path/fileProps for every 
regular file
-                                 List<SnapshotFile> snapshotList =
-                                 IntStream.range(0, list.size())
-                                          .filter(i -> 
ar.<FileProps>resultAt(i).isRegularFile())
-                                          .mapToObj(i -> {
-                                              long size = 
ar.<FileProps>resultAt(i).size();
-                                              return new 
SnapshotFile(list.get(i),
-                                                                      size);
-                                          })
-                                          .collect(Collectors.toList());
-
-
-                                 if (!includeSecondaryIndexFiles)
-                                 {
-                                     // We are done if we don't include 
secondary index files
-                                     promise.complete(snapshotList);
-                                     return;
-                                 }
-
-                                 // Find index directories and prepare futures 
listing the snapshot directory
-                                 //noinspection rawtypes
-                                 List<Future> idxListFutures =
-                                 IntStream.range(0, list.size())
-                                          .filter(i -> {
-                                              if 
(ar.<FileProps>resultAt(i).isDirectory())
-                                              {
-                                                  Path path = 
Paths.get(list.get(i));
-                                                  int count = 
path.getNameCount();
-                                                  return count > 0
-                                                         && path.getName(count 
- 1)
-                                                                .toString()
-                                                                
.startsWith(".");
-                                              }
-                                              return false;
-                                          })
-                                          .mapToObj(i -> 
listSnapshotDirectory(list.get(i), false))
-                                          .collect(Collectors.toList());
-                                 if (idxListFutures.isEmpty())
-                                 {
-                                     // If there are no secondary index 
directories we are done
-                                     promise.complete(snapshotList);
-                                     return;
-                                 }
-                                 logger.debug("Found {} index directories in 
the '{}' snapshot",
-                                              idxListFutures.size(), 
snapshotDirectory);
-                                 // if we have index directories, list them all
-                                 CompositeFuture.all(idxListFutures)
-                                                .onFailure(promise::fail)
-                                                .onSuccess(idx -> {
-                                                    //noinspection unchecked
-                                                    List<SnapshotFile> 
idxPropList =
-                                                    idx.list()
-                                                       .stream()
-                                                       .flatMap(l -> 
((List<SnapshotFile>) l).stream())
-                                                       
.collect(Collectors.toList());
-
-                                                    // aggregate the results 
and return the full list
-                                                    
snapshotList.addAll(idxPropList);
-                                                    
promise.complete(snapshotList);
-                                                });
-                             });
+              List<Future<FileProps>> futures = list.stream()
+                                                    .map(fs::props)
+                                                    
.collect(Collectors.toList());
+
+              Future.all(futures)

Review Comment:
   CompositeFuture was deprecated. Using Future now which now supports typed 
futures



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to