Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit f0fa798d authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

trajectory reading: replace String#split by a combination of String#indexOf...

trajectory reading: replace String#split by a combination of String#indexOf String#substring to avoid costly pattern matching.
parent cab7d437
Pipeline #61917 passed with stage
in 50 seconds
...@@ -141,7 +141,7 @@ public class TrajectoryReader { ...@@ -141,7 +141,7 @@ public class TrajectoryReader {
try (BufferedReader in = IOUtils.defaultBufferedReader(this.trajectoryFilePath)) { try (BufferedReader in = IOUtils.defaultBufferedReader(this.trajectoryFilePath)) {
return in.lines() // a stream of lines return in.lines() // a stream of lines
.skip(1) // skip the first line i.e. the header .skip(1) // skip the first line i.e. the header
.map(line -> line.split(SPLITTER)) // split the line into string tokens .map(line -> split(line)) // split the line into string tokens
.map(rowTokens -> parseRowTokens(rowTokens)) // transform those tokens into a pair of java objects (step, agent) .map(rowTokens -> parseRowTokens(rowTokens)) // transform those tokens into a pair of java objects (step, agent)
.collect(Collectors.groupingBy(Pair::getKey, // group all agent objects by the step. .collect(Collectors.groupingBy(Pair::getKey, // group all agent objects by the step.
Collectors.mapping(Pair::getValue, Collectors.toList()))); Collectors.mapping(Pair::getValue, Collectors.toList())));
...@@ -151,6 +151,33 @@ public class TrajectoryReader { ...@@ -151,6 +151,33 @@ public class TrajectoryReader {
} }
} }
/**
* This method is used instead of {@link String#split(String)} since it is faster because no pattern matching is required.
*
* @param line
* @return
*/
private String[] split(@NotNull final String line) {
int tokenCount = 0;
int startIndex = 0;
int endIndex = -1;
do {
endIndex = line.indexOf(SPLITTER, startIndex+1);
startIndex = endIndex;
tokenCount++;
} while(endIndex != -1);
startIndex = -1;
endIndex = -1;
String[] tokens = new String[tokenCount];
for(int i = 0; i < tokenCount; i++) {
endIndex = line.indexOf(SPLITTER, startIndex+1);
tokens[i] = line.substring(startIndex+1, endIndex != -1 ? endIndex : line.length());
startIndex = endIndex;
}
return tokens;
}
/** /**
* transforms the string tokens of the row (i.e. the values generated by the output processor of one row) * transforms the string tokens of the row (i.e. the values generated by the output processor of one row)
* into a {@link Pair} of ({@link Step}, {@link Agent}). * into a {@link Pair} of ({@link Step}, {@link Agent}).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment