[MINOR] Reuse random object (#1222)
This commit is contained in:
committed by
vinoth chandar
parent
c1f8acab34
commit
fd8f1c70c0
@@ -53,6 +53,7 @@ public class TestHoodieCompactionStrategy {
|
|||||||
|
|
||||||
private static final long MB = 1024 * 1024L;
|
private static final long MB = 1024 * 1024L;
|
||||||
private String[] partitionPaths = {"2017/01/01", "2017/01/02", "2017/01/03"};
|
private String[] partitionPaths = {"2017/01/01", "2017/01/02", "2017/01/03"};
|
||||||
|
private static final Random RANDOM = new Random();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnBounded() {
|
public void testUnBounded() {
|
||||||
@@ -228,7 +229,7 @@ public class TestHoodieCompactionStrategy {
|
|||||||
private List<HoodieCompactionOperation> createCompactionOperations(HoodieWriteConfig config,
|
private List<HoodieCompactionOperation> createCompactionOperations(HoodieWriteConfig config,
|
||||||
Map<Long, List<Long>> sizesMap) {
|
Map<Long, List<Long>> sizesMap) {
|
||||||
Map<Long, String> keyToPartitionMap = sizesMap.keySet().stream()
|
Map<Long, String> keyToPartitionMap = sizesMap.keySet().stream()
|
||||||
.map(e -> Pair.of(e, partitionPaths[new Random().nextInt(partitionPaths.length - 1)]))
|
.map(e -> Pair.of(e, partitionPaths[RANDOM.nextInt(partitionPaths.length - 1)]))
|
||||||
.collect(Collectors.toMap(Pair::getKey, Pair::getValue));
|
.collect(Collectors.toMap(Pair::getKey, Pair::getValue));
|
||||||
return createCompactionOperations(config, sizesMap, keyToPartitionMap);
|
return createCompactionOperations(config, sizesMap, keyToPartitionMap);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ import static org.junit.Assert.fail;
|
|||||||
*/
|
*/
|
||||||
public class TestHoodieDeltaStreamer extends UtilitiesTestBase {
|
public class TestHoodieDeltaStreamer extends UtilitiesTestBase {
|
||||||
|
|
||||||
|
private static final Random RANDOM = new Random();
|
||||||
private static final String PROPS_FILENAME_TEST_SOURCE = "test-source.properties";
|
private static final String PROPS_FILENAME_TEST_SOURCE = "test-source.properties";
|
||||||
private static final String PROPS_FILENAME_TEST_INVALID = "test-invalid.properties";
|
private static final String PROPS_FILENAME_TEST_INVALID = "test-invalid.properties";
|
||||||
private static final Logger LOG = LogManager.getLogger(TestHoodieDeltaStreamer.class);
|
private static final Logger LOG = LogManager.getLogger(TestHoodieDeltaStreamer.class);
|
||||||
@@ -634,7 +635,7 @@ public class TestHoodieDeltaStreamer extends UtilitiesTestBase {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Double call(Double lat1, Double lat2, Double lon1, Double lon2) {
|
public Double call(Double lat1, Double lat2, Double lon1, Double lon2) {
|
||||||
return new Random().nextDouble();
|
return RANDOM.nextDouble();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user