vamsikarnika commented on code in PR #13803:
URL: https://github.com/apache/hudi/pull/13803#discussion_r2310364497
##########
hudi-common/src/test/java/org/apache/hudi/common/model/TestHoodieLogFile.java:
##########
@@ -77,6 +85,124 @@ void createFromStringWithSuffix() {
assertFileGetters(pathWithSuffix, null, hoodieLogFile, -1, suffix);
}
+ @Test
+ void name() {
+ }
+
+ @Test
+ void testLogPatternMatch() {
+ boolean firstApproach = true; // toggle this to false if you want the
other one
+ int runs = 10;
+ long totalTime = 0;
+ Random random = new Random();
+
+ Pattern logFilePattern1 =
+
Pattern.compile("^\\.(.+)_(.*)\\.(log|archive)\\.(\\d+)(_((\\d+)-(\\d+)-(\\d+))(.cdc)?)?");
+ Pattern logFilePattern2 =
+
Pattern.compile("^\\.([^._]+)_([^.]*)\\.(log|archive)\\.(\\d+)(_((\\d+)-(\\d+)-(\\d+))(\\.cdc)?)?$");
+
+ for (int r = 0; r < runs; r++) {
+ HoodieTimer timer = HoodieTimer.start();
+ for (int i = 1; i < 1_000_000; i++) {
+ String logFileName = generateLogFileName(random);
+ if (firstApproach) {
+ Matcher matcher = logFilePattern1.matcher(logFileName);
+ assertTrue(matcher.find());
+ } else {
+ Matcher matcher = logFilePattern2.matcher(logFileName);
+ assertTrue(matcher.matches());
+ }
+ }
+ long elapsed = timer.endTimer();
+ totalTime += elapsed;
+ System.out.println("Run " + (r + 1) + " took " + elapsed + " ms");
+ }
+
+ System.out.println("===================================");
+ System.out.println("Average time (" + (firstApproach ? "previous" : "new")
+ ") = "
+ + (totalTime / runs) + " ms");
+ }
+
+ @Test
+ void testLogPatternMisMatch() {
Review Comment:
similar to match, numbers for files that do not match regex
Previous Regex -> Average time (find) = 900 ms
New Regex -> - Average time (matches) = 820 ms
--
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]