This is an automated email from the ASF dual-hosted git repository.
vinoyang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git
The following commit(s) were added to refs/heads/master by this push:
new 4ddfc61 [MINOR] Make QuickstartUtil generate random timestamp instead
of 0 (#2340)
4ddfc61 is described below
commit 4ddfc61d70e39bc09dd1aa020bde26284ed35d39
Author: wangxianghu <[email protected]>
AuthorDate: Thu Dec 17 18:00:23 2020 +0800
[MINOR] Make QuickstartUtil generate random timestamp instead of 0 (#2340)
---
.../src/main/java/org/apache/hudi/QuickstartUtils.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git
a/hudi-spark-datasource/hudi-spark/src/main/java/org/apache/hudi/QuickstartUtils.java
b/hudi-spark-datasource/hudi-spark/src/main/java/org/apache/hudi/QuickstartUtils.java
index febdf19..025a828 100644
---
a/hudi-spark-datasource/hudi-spark/src/main/java/org/apache/hudi/QuickstartUtils.java
+++
b/hudi-spark-datasource/hudi-spark/src/main/java/org/apache/hudi/QuickstartUtils.java
@@ -121,12 +121,23 @@ public class QuickstartUtils {
*/
public static OverwriteWithLatestAvroPayload generateRandomValue(HoodieKey
key, String riderDriverSuffix)
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 =
- generateGenericRecord(key.getRecordKey(), "rider-" +
riderDriverSuffix, "driver-" + riderDriverSuffix, 0);
+ generateGenericRecord(key.getRecordKey(), "rider-" +
riderDriverSuffix, "driver-"
+ + riderDriverSuffix, generateRangeRandomTimestamp(7));
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.
*/
public Stream<HoodieRecord> generateInsertsStream(String randomString,
Integer n) {