dlmarion commented on code in PR #5998:
URL: https://github.com/apache/accumulo/pull/5998#discussion_r2580996914
##########
core/src/main/java/org/apache/accumulo/core/client/rfile/RFileScannerBuilder.java:
##########
@@ -70,6 +72,30 @@ RFileSource[] getSources() throws IOException {
return sources;
}
+
+ RFileSource[] getShuffledSources() throws IOException {
+ if (sources == null) {
+ sources = new RFileSource[paths.length];
+ for (int i = 0; i < paths.length; i++) {
+ sources[i] = new RFileSource(getFileSystem(paths[i]).open(paths[i]),
+ getFileSystem(paths[i]).getFileStatus(paths[i]).getLen());
+ }
+ } else {
+ for (int i = 0; i < sources.length; i++) {
+ if (!(sources[i].getInputStream() instanceof FSDataInputStream)) {
+ sources[i] = new RFileSource(new
FSDataInputStream(sources[i].getInputStream()),
+ sources[i].getLength());
+ }
+ }
+ }
+ for (int i = sources.length - 1; i > 0; i--) {
+ int j = rand.nextInt(i + 1);
+ RFileSource temp = sources[i];
+ sources[i] = sources[j];
+ sources[j] = temp;
+ }
+ return sources;
+ }
Review Comment:
```suggestion
RFileSource[] sources = getSources();
List<RFileSource> sourceList = new ArrayList<>();
for (RFileSource s : source) {
sourceList.add(s);
}
Collections.shuffle(sourceList, rand);
return sourceList.toArray(new RFileSource[]{});
}
```
##########
core/src/main/java/org/apache/accumulo/core/client/rfile/RFileScannerBuilder.java:
##########
@@ -36,6 +37,7 @@
import com.google.common.base.Preconditions;
class RFileScannerBuilder implements RFile.InputArguments,
RFile.ScannerFSOptions {
+ private static final SecureRandom rand = new SecureRandom();
Review Comment:
switch to `LazySingletons.RANDOM` on merge to main
--
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]