Skip to content

Commit

Permalink
More detailed attribution
Browse files Browse the repository at this point in the history
  • Loading branch information
mtopolnik authored and gunnarmorling committed Jan 6, 2024
1 parent 7ec968d commit 35b9099
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions data/weather_stations.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Adapted from https://simplemaps.com/data/world-cities
# Licensed under Creative Commons Attribution 4.0 (https://creativecommons.org/licenses/by/4.0/
Tokyo;35.6897
Jakarta;-6.1750
Delhi;28.6100
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/dev/morling/onebrc/CreateMeasurements3.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private static ArrayList<WeatherStation> generateWeatherStations() throws Except
// which we'll use as a "source of city name randomness"
var bigName = new StringBuilder(1 << 20);
try (var rows = new BufferedReader(new FileReader("data/weather_stations.csv"));) {
rows.readLine(); // Skip the attribution line
skipComments(rows);
while (true) {
var row = rows.readLine();
if (row == null) {
Expand All @@ -85,7 +85,7 @@ private static ArrayList<WeatherStation> generateWeatherStations() throws Except
var minLen = Integer.MAX_VALUE;
var maxLen = Integer.MIN_VALUE;
try (var rows = new BufferedReader(new FileReader("data/weather_stations.csv"))) {
rows.readLine(); // Skip the attribution line
skipComments(rows);
final var nameSource = new StringReader(bigName.toString());
final var buf = new char[MAX_NAME_LEN];
final var rnd = ThreadLocalRandom.current();
Expand Down Expand Up @@ -146,6 +146,11 @@ private static ArrayList<WeatherStation> generateWeatherStations() throws Except
return weatherStations;
}

private static void skipComments(BufferedReader rows) throws IOException {
while (rows.readLine().startsWith("#")) {
}
}

private static char readNonSpace(StringReader nameSource) throws IOException {
while (true) {
var n = nameSource.read();
Expand Down

0 comments on commit 35b9099

Please sign in to comment.