[MINOR] Make QuickstartUtil generate random timestamp instead of 0 (#2340)
This commit is contained in:
@@ -121,11 +121,22 @@ public class QuickstartUtils {
|
|||||||
*/
|
*/
|
||||||
public static OverwriteWithLatestAvroPayload generateRandomValue(HoodieKey key, String riderDriverSuffix)
|
public static OverwriteWithLatestAvroPayload generateRandomValue(HoodieKey key, String riderDriverSuffix)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
// The timestamp generated is limited to range from 7 days before to now, to avoid generating too many
|
||||||
|
// partitionPaths when user use timestamp as partitionPath filed.
|
||||||
GenericRecord rec =
|
GenericRecord rec =
|
||||||
generateGenericRecord(key.getRecordKey(), "rider-" + riderDriverSuffix, "driver-" + riderDriverSuffix, 0);
|
generateGenericRecord(key.getRecordKey(), "rider-" + riderDriverSuffix, "driver-"
|
||||||
|
+ riderDriverSuffix, generateRangeRandomTimestamp(7));
|
||||||
return new OverwriteWithLatestAvroPayload(Option.of(rec));
|
return new OverwriteWithLatestAvroPayload(Option.of(rec));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate timestamp range from {@param daysTillNow} before to now.
|
||||||
|
*/
|
||||||
|
private static long generateRangeRandomTimestamp(int daysTillNow) {
|
||||||
|
long maxIntervalMillis = daysTillNow * 24 * 60 * 60 * 1000L;
|
||||||
|
return System.currentTimeMillis() - (long)(Math.random() * maxIntervalMillis);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates new inserts, uniformly across the partition paths above. It also updates the list of existing keys.
|
* Generates new inserts, uniformly across the partition paths above. It also updates the list of existing keys.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user