Skip to content

Commit

Permalink
Limit names to 100 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
mtopolnik committed Jan 5, 2024
1 parent 12480c4 commit 02965eb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/dev/morling/onebrc/CreateMeasurements3.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.concurrent.ThreadLocalRandom;
Expand Down Expand Up @@ -113,6 +114,9 @@ private static ArrayList<WeatherStation> generateWeatherStations() throws Except
while (names.contains(name)) {
name = name.substring(1) + readNonSpace(nameSource);
}
while (name.getBytes(StandardCharsets.UTF_8).length > 100) {
name = name.substring(0, name.length() - 1);
}
if (name.indexOf(';') != -1) {
throw new Exception("Station name contains a semicolon!");
}
Expand Down

0 comments on commit 02965eb

Please sign in to comment.