xushiyan commented on a change in pull request #4866: URL: https://github.com/apache/hudi/pull/4866#discussion_r814417726
########## File path: hudi-common/src/test/java/org/apache/hudi/common/testutils/HoodieTestDataGenerator.java ########## @@ -269,25 +300,25 @@ public static GenericRecord generateGenericRecord(String rowKey, String partitio rec.put("partition_path", partitionPath); rec.put("rider", riderName); rec.put("driver", driverName); - rec.put("begin_lat", RAND.nextDouble()); - rec.put("begin_lon", RAND.nextDouble()); - rec.put("end_lat", RAND.nextDouble()); - rec.put("end_lon", RAND.nextDouble()); + rec.put("begin_lat", r.nextDouble()); + rec.put("begin_lon", r.nextDouble()); + rec.put("end_lat", r.nextDouble()); + rec.put("end_lon", r.nextDouble()); if (isFlattened) { - rec.put("fare", RAND.nextDouble() * 100); + rec.put("fare", r.nextDouble() * 100); rec.put("currency", "USD"); } else { - rec.put("distance_in_meters", RAND.nextInt()); - rec.put("seconds_since_epoch", RAND.nextLong()); - rec.put("weight", RAND.nextFloat()); + rec.put("distance_in_meters", r.nextInt()); + rec.put("seconds_since_epoch", r.nextLong()); + rec.put("weight", r.nextFloat()); byte[] bytes = "Canada".getBytes(); rec.put("nation", ByteBuffer.wrap(bytes)); - long currentTimeMillis = System.currentTimeMillis(); - Date date = new Date(currentTimeMillis); + long randomMillis = genRandomTimeMillis(r); + Date date = new Date(randomMillis); Review comment: optional: while you're on this, it may worth migrating away from Date to java.time APIs, for standardizing datetime usage in the codebase and be thread-safe where applicable. ########## File path: hudi-common/src/test/java/org/apache/hudi/common/testutils/HoodieTestDataGenerator.java ########## @@ -865,4 +883,31 @@ public int getNumExistingKeys(String schemaStr) { public void close() { existingKeysBySchema.clear(); } + + private static long genRandomTimeMillis(Random r) { + // NOTE: {@code Date} expects a number representing a number of millis elapsed since epoch + // (01/01/1970 00:00:00) until approx year 8099 + // This modulo represents approx 6000 years in millis, which should be sufficient to + // cover all possible use-cases + return Math.abs(r.nextLong()) % 189216000000000L; + } + + private static UUID genPseudoRandomUUID(Random r) { + byte[] bytes = new byte[16]; + r.nextBytes(bytes); + + bytes[6] &= 0x0f; + bytes[6] |= 0x40; + bytes[8] &= 0x3f; + bytes[8] |= 0x80; Review comment: maybe this method deserves some usage guide in javadoc? -- 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: commits-unsubscr...@hudi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org