zuston commented on code in PR #478:
URL: https://github.com/apache/incubator-uniffle/pull/478#discussion_r1070985328
##########
storage/src/test/java/org/apache/uniffle/storage/handler/impl/LocalFileHandlerTestBase.java:
##########
@@ -44,26 +44,23 @@
public class LocalFileHandlerTestBase {
private static AtomicLong ATOMIC_LONG = new AtomicLong(0L);
- public static void reset() {
- ATOMIC_LONG = new AtomicLong(0L);
- }
-
- public static void writeTestData(
- ShuffleWriteHandler writeHandler,
- int num, int length,
- Map<Long, byte[]> expectedData,
- Set<Long> expectedBlockIds) throws Exception {
+ public static List<ShufflePartitionedBlock> generateBlocks(int num, int
length) {
List<ShufflePartitionedBlock> blocks = Lists.newArrayList();
for (int i = 0; i < num; i++) {
byte[] buf = new byte[length];
new Random().nextBytes(buf);
long blockId = ATOMIC_LONG.incrementAndGet();
blocks.add(new ShufflePartitionedBlock(length, length,
ChecksumUtils.getCrc32(buf), blockId, 100,
buf));
- expectedData.put(blockId, buf);
- expectedBlockIds.add(blockId);
}
- writeHandler.write(blocks);
+ return blocks;
+ }
+
+ public static void writeTestData(List<ShufflePartitionedBlock> blocks,
ShuffleWriteHandler handler,
+ Map<Long, byte[]> expectedData, Set<Long> expectedBlockIds) throws
Exception {
+ handler.write(blocks);
+ blocks.forEach(block -> expectedBlockIds.add(block.getBlockId()));
+ blocks.forEach(block -> expectedData.put(block.getBlockId(),
block.getData()));
Review Comment:
Why not do above two operations in one `foreach` ?
--
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]